ug4
|
A factory class which creates instances given a class-name. More...
#include <factory.h>
Classes | |
struct | ClassInfo |
Public Member Functions | |
const std::string & | class_name (const size_t i) const |
const std::string & | class_name (const TBase &cls) const |
SmartPtr< TBase > | create (const char *className) |
SmartPtr< TBase > | create (const std::string &className) |
TBase * | create_raw (const char *className) |
TBase * | create_raw (const std::string &className) |
Factory () | |
size_t | num_classes () const |
template<class TDerived > | |
void | register_class (const char *name) |
Private Types | |
typedef std::map< std::string, ClassInfo > | class_map_t |
typedef std::map< std::string, std::string > | class_name_map_t |
typedef TBase *(* | factory_sig) () |
Private Attributes | |
class_map_t | m_classMap |
contains ClassInfo objects accessible by class-name. More... | |
class_name_map_t | m_classNameMap |
key: type-name, value: class-names More... | |
std::vector< std::string > | m_classNames |
A factory class which creates instances given a class-name.
Given a base-class 'TBase' and an optional boost::mpl sequence of pairs of derived classes and strings 'TPairSeq', the ug::Factory class allows for the creation of instances ofderived classes given a name. Additionally to the classes contained in 'TPairSeq', one may register derived classes at runtime through the 'register_class' method.
Besides creation of registered classes through the 'create' method, one can iterate over all registered classes or obtain a registered class-name given a pointer to the base class.
|
private |
|
private |
|
private |
|
inline |
References func().
|
inline |
|
inline |
References ug::Factory< TBase, TPairSeq >::m_classNameMap, and name.
|
inline |
References ug::Factory< TBase, TPairSeq >::create_raw().
|
inline |
|
inline |
References ug::Factory< TBase, TPairSeq >::m_classMap, and UG_COND_THROW.
|
inline |
Referenced by ug::Factory< TBase, TPairSeq >::create().
|
inline |
References ug::Factory< TBase, TPairSeq >::m_classNames.
|
inline |
|
private |
contains ClassInfo objects accessible by class-name.
Referenced by ug::Factory< TBase, TPairSeq >::create_raw(), and ug::Factory< TBase, TPairSeq >::register_class().
|
private |
key: type-name, value: class-names
Referenced by ug::Factory< TBase, TPairSeq >::class_name(), and ug::Factory< TBase, TPairSeq >::register_class().
|
private |