cmake/Source/cmGlobalGeneratorFactory.h

76 lines
2.2 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2013-03-16 19:13:01 +02:00
#ifndef cmGlobalGeneratorFactory_h
#define cmGlobalGeneratorFactory_h
2017-07-20 19:35:53 +02:00
#include "cmConfigure.h"
2016-10-30 18:24:19 +01:00
2017-04-14 19:02:05 +02:00
#include <string>
#include <vector>
2013-03-16 19:13:01 +02:00
class cmGlobalGenerator;
2017-04-14 19:02:05 +02:00
class cmake;
2013-03-16 19:13:01 +02:00
struct cmDocumentationEntry;
/** \class cmGlobalGeneratorFactory
* \brief Responable for creating cmGlobalGenerator instances
*
* Subclasses of this class generate instances of cmGlobalGenerator.
*/
class cmGlobalGeneratorFactory
{
public:
virtual ~cmGlobalGeneratorFactory() {}
/** Create a GlobalGenerator */
2016-07-09 11:21:54 +02:00
virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& n,
cmake* cm) const = 0;
2013-03-16 19:13:01 +02:00
/** Get the documentation entry for this factory */
virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
/** Get the names of the current registered generators */
virtual void GetGenerators(std::vector<std::string>& names) const = 0;
2016-03-13 13:35:51 +01:00
/** Determine whether or not this generator supports toolsets */
virtual bool SupportsToolset() const = 0;
2016-10-30 18:24:19 +01:00
/** Determine whether or not this generator supports platforms */
virtual bool SupportsPlatform() const = 0;
2013-03-16 19:13:01 +02:00
};
2016-07-09 11:21:54 +02:00
template <class T>
2013-03-16 19:13:01 +02:00
class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory
{
public:
/** Create a GlobalGenerator */
2016-10-30 18:24:19 +01:00
cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
cmake* cm) const CM_OVERRIDE
2016-07-09 11:21:54 +02:00
{
2016-10-30 18:24:19 +01:00
if (name != T::GetActualName()) {
return CM_NULLPTR;
}
2016-07-09 11:21:54 +02:00
return new T(cm);
}
2013-03-16 19:13:01 +02:00
/** Get the documentation entry for this factory */
2016-10-30 18:24:19 +01:00
void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE
2016-07-09 11:21:54 +02:00
{
T::GetDocumentation(entry);
}
2013-03-16 19:13:01 +02:00
/** Get the names of the current registered generators */
2016-10-30 18:24:19 +01:00
void GetGenerators(std::vector<std::string>& names) const CM_OVERRIDE
2016-07-09 11:21:54 +02:00
{
names.push_back(T::GetActualName());
}
2016-03-13 13:35:51 +01:00
/** Determine whether or not this generator supports toolsets */
2016-10-30 18:24:19 +01:00
bool SupportsToolset() const CM_OVERRIDE { return T::SupportsToolset(); }
/** Determine whether or not this generator supports platforms */
bool SupportsPlatform() const CM_OVERRIDE { return T::SupportsPlatform(); }
2013-03-16 19:13:01 +02:00
};
#endif