QtDesignPatterns/abstractfactorypattern/factoryproducer.h

23 lines
424 B
C++

#include "abstractfactory.h"
class FactoryProducer
{
public:
FactoryProducer(){}
AbstractFactory *getFactory(string type)
{
if (type.compare("ShapeFactory") == 0)
{
return new ShapeFactory();
}
else if (type.compare("ColorFactory") == 0)
{
return new ColorFactory();
}
else
{
return nullptr;
}
}
};