| Cantera 3.0.0

Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private 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]

## 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, that is, arguments to the constructor.

Definition at line 69 of file FactoryBase.h.

## Public Member Functions
T * | create (const string &name, Args... args)
| Create an object using the object construction function corresponding to "name" and the provided constructor arguments.
void | reg (const string &name, function< T *(Args...)> f)
| Register a new object construction function.
void | addAlias (const string &original, const string &alias)
| Add an alias for an existing registered type.
string | canonicalize (const string &name)
| Get the canonical name registered for a type.
bool | exists (const string &name) const
| Returns true if `name` is registered with this factory.
Public Member Functions inherited from FactoryBase
virtual | ~FactoryBase ()
| destructor

## Protected Member Functions
void | addDeprecatedAlias (const string &original, const string &alias)
| Add a deprecated alias for an existing registered type.
Protected Member Functions inherited from FactoryBase
| FactoryBase ()
| Constructor.
virtual void | deleteFactory ()=0
| Virtual abstract function that deletes the factory.

## Private Attributes
std::unordered_map< string, function< T *(Args...)> > | m_creators
std::unordered_map< string, string > | m_synonyms
| Map of synonyms to canonical names.
std::unordered_map< string, string > | m_deprecated_names
| Map of deprecated synonyms to canonical names.

## 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

## Constructor & Destructor Documentation

## ◆ ~Factory()

template<class T , typename ... Args>

virtual ~Factory | ( |  | ) |
| inline virtual

Definition at line 71 of file FactoryBase.h.

## Member Function Documentation

## ◆ create()

template<class T , typename ... Args>

T * create | ( | const 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()

template<class T , typename ... Args>

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

Register a new object construction function.

Definition at line 80 of file FactoryBase.h.

## ◆ addAlias()

template<class T , typename ... Args>

void addAlias | ( | const string & | original,
|  | const string & | alias
| ) |  |
| inline

Add an alias for an existing registered type.

Definition at line 85 of file FactoryBase.h.

## ◆ canonicalize()

template<class T , typename ... Args>

string canonicalize | ( | const string & | name | ) |
| inline

Get the canonical name registered for a type.

Definition at line 94 of file FactoryBase.h.

## ◆ exists()

template<class T , typename ... Args>

bool exists | ( | const string & | name | ) | const
| inline

Returns true if `name` is registered with this factory.

Definition at line 110 of file FactoryBase.h.

## ◆ addDeprecatedAlias()

template<class T , typename ... Args>

void addDeprecatedAlias | ( | const string & | original,
|  | const string & | alias
| ) |  |
| inline protected

Add a deprecated alias for an existing registered type.

Definition at line 116 of file FactoryBase.h.

## Member Data Documentation

## ◆ m_creators

template<class T , typename ... Args>

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

Definition at line 126 of file FactoryBase.h.

## ◆ m_synonyms

template<class T , typename ... Args>

std::unordered_map<string, string> m_synonyms
| private

Map of synonyms to canonical names.

Definition at line 129 of file FactoryBase.h.

## ◆ m_deprecated_names

template<class T , typename ... Args>

std::unordered_map<string, string> m_deprecated_names
| private

Map of deprecated synonyms to canonical names.

Use of these names will show a deprecation warning.

Definition at line 133 of file FactoryBase.h.

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

- FactoryBase.h