A factory for creating elements based on their type. More...
|Exception thrown if an Unknown element is being created. More...|
|typedef Element *(*||Callback )(const char *)|
|typedef map< string, Callback >||Map|
|void||add (const string &key, Callback cb)|
|Register a callback with the factory. |
|Element *||create (const string &key, const char *arg)|
|Create an element. |
|static bool||can_create (const string &key)|
|Checks whether a type exists. |
|There is only one factory map. |
|A class which registers defined callbacks upon creation. |
A factory for creating elements based on their type.
Elements are created via their string represented type. They are initialized via a c-style string. If this string is null, then a default value is assigned to the element.
An exception is throw on element creationg failure.
Similar to Dispatcher.
|void ElementFactory::add||(||const string &||key,|
|bool ElementFactory::can_create||(||const string &||key||)||
|Element * ElementFactory::create||(||const string &||key,|
|const char *||arg|
There is only one factory map.
Creating additional factory objects is therefore safe. No need to pass a global factory around in the various classes.
A class which registers defined callbacks upon creation.
Callbacks are thus registered once [static] and before the factory is actually used.