summaryrefslogtreecommitdiffstats
path: root/Source/cmExternalMakefileProjectGenerator.h
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2016-07-20 16:28:39 (GMT)
committerBrad King <brad.king@kitware.com>2016-08-03 13:43:00 (GMT)
commita354f60ce07cd67bd60161824a4e74bf9068fea4 (patch)
tree14c272760205567469ddd856a99e98ace6282841 /Source/cmExternalMakefileProjectGenerator.h
parentfd59f9ad519c1c311c54569133797d9061e90558 (diff)
downloadCMake-a354f60ce07cd67bd60161824a4e74bf9068fea4.zip
CMake-a354f60ce07cd67bd60161824a4e74bf9068fea4.tar.gz
CMake-a354f60ce07cd67bd60161824a4e74bf9068fea4.tar.bz2
Refactor extra generator registration to use factories
This will allow additional information about the availability and capabilities of extra generators to be queried without actually creating them. Instead of a static NewFactory() method like the main generator factories have, use a static GetFactory() method to get a pointer to a statically allocated extra generator factory. This simplifies memory management.
Diffstat (limited to 'Source/cmExternalMakefileProjectGenerator.h')
-rw-r--r--Source/cmExternalMakefileProjectGenerator.h55
1 files changed, 48 insertions, 7 deletions
diff --git a/Source/cmExternalMakefileProjectGenerator.h b/Source/cmExternalMakefileProjectGenerator.h
index 5d4d54d..6ae5533 100644
--- a/Source/cmExternalMakefileProjectGenerator.h
+++ b/Source/cmExternalMakefileProjectGenerator.h
@@ -35,11 +35,6 @@ class cmExternalMakefileProjectGenerator
public:
virtual ~cmExternalMakefileProjectGenerator() {}
- ///! Get the name for this generator.
- virtual std::string GetName() const = 0;
- /** Get the documentation entry for this generator. */
- virtual void GetDocumentation(cmDocumentationEntry& entry,
- const std::string& fullName) const = 0;
virtual void EnableLanguage(std::vector<std::string> const& languages,
cmMakefile*, bool optional);
@@ -55,8 +50,6 @@ public:
return this->SupportedGlobalGenerators;
}
- ///! Get the name of the global generator for the given full name
- std::string GetGlobalGeneratorName(const std::string& fullName);
/** Create a full name from the given global generator name and the
* extra generator name
*/
@@ -66,11 +59,59 @@ public:
///! Generate the project files, the Makefiles have already been generated
virtual void Generate() = 0;
+ void SetName(const std::string& n) { Name = n; }
+ std::string GetName() const { return Name; }
+
protected:
///! Contains the names of the global generators support by this generator.
std::vector<std::string> SupportedGlobalGenerators;
///! the global generator which creates the makefiles
const cmGlobalGenerator* GlobalGenerator;
+
+ std::string Name;
+};
+
+class cmExternalMakefileProjectGeneratorFactory
+{
+public:
+ cmExternalMakefileProjectGeneratorFactory(const std::string& n,
+ const std::string& doc);
+ virtual ~cmExternalMakefileProjectGeneratorFactory();
+
+ std::string GetName() const;
+ std::string GetDocumentation() const;
+ std::vector<std::string> GetSupportedGlobalGenerators() const;
+ std::vector<std::string> Aliases;
+
+ virtual cmExternalMakefileProjectGenerator*
+ CreateExternalMakefileProjectGenerator() const = 0;
+
+ void AddSupportedGlobalGenerator(const std::string& base);
+
+private:
+ std::string Name;
+ std::string Documentation;
+ std::vector<std::string> SupportedGlobalGenerators;
+};
+
+template <class T>
+class cmExternalMakefileProjectGeneratorSimpleFactory
+ : public cmExternalMakefileProjectGeneratorFactory
+{
+public:
+ cmExternalMakefileProjectGeneratorSimpleFactory(const std::string& n,
+ const std::string& doc)
+ : cmExternalMakefileProjectGeneratorFactory(n, doc)
+ {
+ }
+
+ cmExternalMakefileProjectGenerator* CreateExternalMakefileProjectGenerator()
+ const
+ {
+ T* p = new T;
+ p->SetName(GetName());
+ return p;
+ }
};
#endif