9 #ifndef CT_FACTORY_BASE 10 #define CT_FACTORY_BASE 14 #include <unordered_map> 68 template <
class T,
typename ... Args>
75 T*
create(
const std::string& name, Args... args) {
77 return m_creators.at(name)(args...);
78 }
catch (std::out_of_range&) {
79 throw CanteraError(
"Factory::create",
"No such type: '{}'", name);
84 void reg(
const std::string& name, std::function<T*(Args...)> f) {
89 std::unordered_map<std::string, std::function<T*(Args...)>> m_creators;
virtual ~FactoryBase()
destructor
FactoryBase()
Constructor.
Base class for factories.
virtual void deleteFactory()=0
Virtual abstract function that deletes the factory.
T * create(const std::string &name, Args... args)
Create an object using the object construction function corresponding to "name" and the provided cons...
static void deleteFactories()
static function that deletes all factories in the internal registry maintained in a static variable ...
Base class for exceptions thrown by Cantera classes.
Factory class that supports registering functions to create objects.
void reg(const std::string &name, std::function< T *(Args...)> f)
Register a new object construction function.
static std::vector< FactoryBase * > s_vFactoryRegistry
statically held list of Factories.
Namespace for the Cantera kernel.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...