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