Lagrangian Particle Code for The Simulation of 2D/3D Fluid Dynamics
 All Classes Files Functions Variables Typedefs Friends Pages
registrar.h
Go to the documentation of this file.
1 
18 #ifndef __REGISTRAR_H__
19 #define __REGISTRAR_H__
20 
21 #include "geometry.h"
22 #include "state.h"
23 
24 
25 
46 template<typename Derived>
48 public:
62  GeometryRegistrar(std::string name);
63 
72  static Geometry* createFunc();
73 };
74 
75 
76 
78 // Start of GeometryRegistrar
80 
81 template<typename Derived>
83  return new Derived();
84 }
85 
86 
87 template<typename Derived>
89  GeometryFactory& factory = GeometryFactory::instance(); // & cannot be omitted
90  factory.registerGeometry(name, GeometryRegistrar<Derived>::createFunc); // second arg is function pointer
91 }
92 
94 // Start of GeometryRegistrar
96 
97 
98 
99 
100 
101 
102 
103 
124 template<typename Derived>
126 public:
140  StateRegistrar(std::string name);
149  static State* createFunc();
150 };
151 
152 
154 // Start of StateRegistrar
156 
157 template<typename Derived>
159  return new Derived();
160 }
161 
162 template<typename Derived>
164  StateFactory& factory = StateFactory::instance(); // note here is the difference from the GeometryRegistrar class
166 }
167 
169 // End of StateRegistrar
171 
172 #endif // __REGISTRAR_H__
173 
void registerGeometry(std::string name, GeoCreateFunc func)
Registers (links) the geometry name name with the function func for creating objects in the Geometry ...
Definition: geometry.cpp:71
The abstract factory class for creating objects in the State family.
Definition: state.h:240
A template class for the registration of classes in the State family.
Definition: registrar.h:125
static State * createFunc()
This function creates an object of the Derived class and returns a pointer to the State class...
Definition: registrar.h:158
An abstract class for the initialization of the geometry of fluid objects.
Definition: geometry.h:38
The abstract factory class for creating objects in the Geometry family.
Definition: geometry.h:226
An abstract class for the initialization of the state of fluid objects.
Definition: state.h:41
static Geometry * createFunc()
This function creates an object of the Derived class and returns a pointer to the Geometry class...
Definition: registrar.h:82
static StateFactory & instance()
Returns reference to a Singleton object of class StateFactory.
Definition: state.cpp:75
GeometryRegistrar(std::string name)
constructor
Definition: registrar.h:88
StateRegistrar(std::string name)
constructor
Definition: registrar.h:163
This header file contains classes for the initialization of the state of fluid objects.
This header file contains classes for the initialization of the geometry of fluid objects...
static GeometryFactory & instance()
Returns reference to a Singleton object of class GeometryFactory.
Definition: geometry.cpp:66
A template class for the registration of classes in the Geometry family.
Definition: registrar.h:47
void registerState(std::string name, StateCreateFunc func)
Registers (links) the state name name with the function func for creating objects in the State family...
Definition: state.cpp:89