Cantera  2.3.0
Public Member Functions | Protected Attributes | List of all members
Factory< T, Args > Class Template Reference

Factory class that supports registering functions to create objects. More...

#include <FactoryBase.h>

Inheritance diagram for Factory< T, Args >:
[legend]
Collaboration diagram for Factory< T, Args >:
[legend]

Public Member Functions

T * create (const std::string &name, Args... args)
 Create an object using the object construction function corresponding to "name" and the provided constructor arguments. More...
 
void reg (const std::string &name, std::function< T *(Args...)> f)
 Register a new object construction function. More...
 
- Public Member Functions inherited from FactoryBase
virtual ~FactoryBase ()
 destructor More...
 

Protected Attributes

std::unordered_map< std::string, std::function< T *(Args...)> > m_creators
 

Additional Inherited Members

- Static Public Member Functions inherited from FactoryBase
static void deleteFactories ()
 static function that deletes all factories in the internal registry maintained in a static variable More...
 
- Protected Member Functions inherited from FactoryBase
 FactoryBase ()
 Constructor. More...
 
virtual void deleteFactory ()=0
 Virtual abstract function that deletes the factory. More...
 

Detailed Description

template<class T, typename ... Args>
class Cantera::Factory< T, Args >

Factory class that supports registering functions to create objects.

Template arguments for the class are the base type created by the factory, followed by the types of any arguments which need to be passed to the functions used to create objects, e.g. arguments to the constructor.

Definition at line 69 of file FactoryBase.h.

Member Function Documentation

◆ create()

T* create ( const std::string &  name,
Args...  args 
)
inline

Create an object using the object construction function corresponding to "name" and the provided constructor arguments.

Definition at line 75 of file FactoryBase.h.

◆ reg()

void reg ( const std::string &  name,
std::function< T *(Args...)>  f 
)
inline

Register a new object construction function.

Definition at line 84 of file FactoryBase.h.


The documentation for this class was generated from the following file: