diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2016-07-20 16:28:39 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-08-03 13:43:00 (GMT) |
commit | a354f60ce07cd67bd60161824a4e74bf9068fea4 (patch) | |
tree | 14c272760205567469ddd856a99e98ace6282841 /Source/cmExternalMakefileProjectGenerator.cxx | |
parent | fd59f9ad519c1c311c54569133797d9061e90558 (diff) | |
download | CMake-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.cxx')
-rw-r--r-- | Source/cmExternalMakefileProjectGenerator.cxx | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/Source/cmExternalMakefileProjectGenerator.cxx b/Source/cmExternalMakefileProjectGenerator.cxx index 0e42d75..a527e50 100644 --- a/Source/cmExternalMakefileProjectGenerator.cxx +++ b/Source/cmExternalMakefileProjectGenerator.cxx @@ -33,28 +33,37 @@ std::string cmExternalMakefileProjectGenerator::CreateFullGeneratorName( return fullName; } -std::string cmExternalMakefileProjectGenerator::GetGlobalGeneratorName( - const std::string& fullName) +cmExternalMakefileProjectGeneratorFactory:: + cmExternalMakefileProjectGeneratorFactory(const std::string& n, + const std::string& doc) + : Name(n) + , Documentation(doc) { - // at least one global generator must be supported - assert(!this->SupportedGlobalGenerators.empty()); +} - if (fullName.empty()) { - return ""; - } +cmExternalMakefileProjectGeneratorFactory:: + ~cmExternalMakefileProjectGeneratorFactory() +{ +} - // if we get only the short name, take the first global generator as default - if (fullName == this->GetName()) { - return this->SupportedGlobalGenerators[0]; - } +std::string cmExternalMakefileProjectGeneratorFactory::GetName() const +{ + return this->Name; +} - // otherwise search for the matching global generator - for (std::vector<std::string>::const_iterator it = - this->SupportedGlobalGenerators.begin(); - it != this->SupportedGlobalGenerators.end(); ++it) { - if (this->CreateFullGeneratorName(*it, this->GetName()) == fullName) { - return *it; - } - } - return ""; +std::string cmExternalMakefileProjectGeneratorFactory::GetDocumentation() const +{ + return this->Documentation; +} + +std::vector<std::string> +cmExternalMakefileProjectGeneratorFactory::GetSupportedGlobalGenerators() const +{ + return this->SupportedGlobalGenerators; +} + +void cmExternalMakefileProjectGeneratorFactory::AddSupportedGlobalGenerator( + const std::string& base) +{ + this->SupportedGlobalGenerators.push_back(base); } |