Lagrangian Particle Code for The Simulation of 2D/3D Fluid Dynamics
|
The abstract factory class for creating objects in the State family. More...
#include <state.h>
Public Types | |
typedef State *(* | StateCreateFunc )() |
Defines a function pointer pointing to a function which creates objects in the State family. | |
Public Member Functions | |
void | registerState (std::string name, StateCreateFunc func) |
Registers (links) the state name name with the function func for creating objects in the State family. More... | |
Static Public Member Functions | ||||
static StateFactory & | instance () | |||
Returns reference to a Singleton object of class StateFactory. More... | ||||
This function creates an object of the class linked to the
Example usage: StateFactory& factory = StateFactory::instance();
State* newState = factory.createState(name);
| ||||
State * | createState (std::string name) | |||
The abstract factory class for creating objects in the State family.
Created on: 2014/06/07
|
static |
Returns reference to a Singleton object of class StateFactory.
None |
Example usage:
void StateFactory::registerState | ( | std::string | name, |
StateCreateFunc | func | ||
) |
Registers (links) the state name name with the function func for creating objects in the State family.
After registration, name can be used as an argument in the createState member function for creating objects of the linked type in the State family
[in] | name | the state name |
[in] | func | the function pointer pointing to the function that creates objects of a specific type in the State family |