13 #ifndef FFA_GENERIC_FACTORY_H
14 #define FFA_GENERIC_FACTORY_H
35 template <
class T,
class Key = std::
string,
class ArgType =
int>
51 T*
create(
const Key& key, ArgType
id)
54 typename CreatorMap::iterator creator =
myCreatorMap.find(key);
56 creator->second.invoke(
id,retVal);
59 std::cerr <<
"\n *** FFaGenericFactory: No creator defined for "
66 void getKeys(std::vector<Key>& keys)
const
70 for (
const typename CreatorMap::value_type& creator :
myCreatorMap)
71 keys.push_back(creator.first);
Macros for definition of dynamic callback objects.
Template for singleton classes.
Template singelton class defining a general object creation factory.
Definition: FFaGenericFactory.H:37
bool registerCreator(const Key &key, const CreatorCB &creator)
Registers a new object creation method on key.
Definition: FFaGenericFactory.H:45
void getKeys(std::vector< Key > &keys) const
Gets a list of all registered object creator keys.
Definition: FFaGenericFactory.H:66
FFaDynCB2< ArgType, T *& > CreatorCB
Type alias for object creation callback.
Definition: FFaGenericFactory.H:39
T * create(const Key &key, ArgType id)
Invokes the object creation method for given key.
Definition: FFaGenericFactory.H:51
std::map< Key, CreatorCB > CreatorMap
Key --> creator callback mapping.
Definition: FFaGenericFactory.H:41
void clear()
Clears the object creator map myCreatorMap.
Definition: FFaGenericFactory.H:75
CreatorMap myCreatorMap
Object creator callbacks container.
Definition: FFaGenericFactory.H:78
Template for singleton classes.
Definition: FFaSingelton.H:26
static void removeInstance()
Deletes the dynamically allocated instance.
Definition: FFaSingelton.H:47