cmGlobalGeneratorFactory.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2012 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmGlobalGeneratorFactory_h
  11. #define cmGlobalGeneratorFactory_h
  12. #include "cmStandardIncludes.h"
  13. class cmake;
  14. class cmGlobalGenerator;
  15. struct cmDocumentationEntry;
  16. /** \class cmGlobalGeneratorFactory
  17. * \brief Responable for creating cmGlobalGenerator instances
  18. *
  19. * Subclasses of this class generate instances of cmGlobalGenerator.
  20. */
  21. class cmGlobalGeneratorFactory
  22. {
  23. public:
  24. virtual ~cmGlobalGeneratorFactory() {}
  25. /** Create a GlobalGenerator */
  26. virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& n,
  27. cmake* cm) const = 0;
  28. /** Get the documentation entry for this factory */
  29. virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
  30. /** Get the names of the current registered generators */
  31. virtual void GetGenerators(std::vector<std::string>& names) const = 0;
  32. /** Determine whether or not this generator supports toolsets */
  33. virtual bool SupportsToolset() const = 0;
  34. /** Determine whether or not this generator supports platforms */
  35. virtual bool SupportsPlatform() const = 0;
  36. };
  37. template <class T>
  38. class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory
  39. {
  40. public:
  41. /** Create a GlobalGenerator */
  42. cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
  43. cmake* cm) const CM_OVERRIDE
  44. {
  45. if (name != T::GetActualName()) {
  46. return CM_NULLPTR;
  47. }
  48. return new T(cm);
  49. }
  50. /** Get the documentation entry for this factory */
  51. void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE
  52. {
  53. T::GetDocumentation(entry);
  54. }
  55. /** Get the names of the current registered generators */
  56. void GetGenerators(std::vector<std::string>& names) const CM_OVERRIDE
  57. {
  58. names.push_back(T::GetActualName());
  59. }
  60. /** Determine whether or not this generator supports toolsets */
  61. bool SupportsToolset() const CM_OVERRIDE { return T::SupportsToolset(); }
  62. /** Determine whether or not this generator supports platforms */
  63. bool SupportsPlatform() const CM_OVERRIDE { return T::SupportsPlatform(); }
  64. };
  65. #endif