cmGlobalGeneratorFactory.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 cmGlobalGenerator;
  14. struct cmDocumentationEntry;
  15. /** \class cmGlobalGeneratorFactory
  16. * \brief Responable for creating cmGlobalGenerator instances
  17. *
  18. * Subclasses of this class generate instances of cmGlobalGenerator.
  19. */
  20. class cmGlobalGeneratorFactory
  21. {
  22. public:
  23. virtual ~cmGlobalGeneratorFactory() {}
  24. /** Create a GlobalGenerator */
  25. virtual cmGlobalGenerator* CreateGlobalGenerator(
  26. const std::string& n) const = 0;
  27. /** Get the documentation entry for this factory */
  28. virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
  29. /** Get the names of the current registered generators */
  30. virtual void GetGenerators(std::vector<std::string>& names) const = 0;
  31. };
  32. template<class T>
  33. class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory
  34. {
  35. public:
  36. /** Create a GlobalGenerator */
  37. virtual cmGlobalGenerator* CreateGlobalGenerator(
  38. const std::string& name) const {
  39. if (name != T::GetActualName()) return 0;
  40. return new T; }
  41. /** Get the documentation entry for this factory */
  42. virtual void GetDocumentation(cmDocumentationEntry& entry) const {
  43. T::GetDocumentation(entry); }
  44. /** Get the names of the current registered generators */
  45. virtual void GetGenerators(std::vector<std::string>& names) const {
  46. names.push_back(T::GetActualName()); }
  47. };
  48. #endif