Go to the documentation of this file.
7 #include <boost/foreach.hpp>
22 void FactoryStorage::destroy() {
27 FactoryStorage::FactoryStorage() : entityMap() {}
40 "Another entity class already defined with the same name. ",
41 "(while adding entity class <%s> inside the factory).",
44 "Another entity class already defined with the same name. "
45 "(while adding entity class <%s> inside the factory).",
51 "Bad entity constructor.");
54 dgDEBUG(30) <<
"Register entity <" << entname <<
"> in the factory."
66 "(while removing entity class <%s>).", entname.c_str());
68 "Entity class not defined yet. "
69 "(while removing entity class <%s>).",
72 dgDEBUG(30) <<
"Deregister entity <" << entname <<
"> from the factory."
80 const std::string &objname)
const {
81 dgDEBUG(15) <<
"New <" << classname <<
">Entity <" << objname <<
">"
84 EntityMap::const_iterator entPtr =
entityMap.find(classname);
88 " (while calling new_entity <%s>)", classname.c_str());
90 return entPtr->second(objname);
102 typedef std::pair<std::string, EntityConstructor_ptr> iter_t;
103 BOOST_FOREACH (
const iter_t &entity,
entityMap)
104 outList.push_back(entity.first);
109 : entityName(entityClassName) {
EntityRegisterer(const std::string &entityClassName, FactoryStorage::EntityConstructor_ptr maker)
Register entity to the global factory.
Entity *(* EntityConstructor_ptr)(const std::string &)
Function pointer providing an entity instance from its name.
~EntityRegisterer()
Unregister entity to the global factory.
EntityMap entityMap
The entity map storing information about how to instantiate an Entity.
This class represents an entity, i.e. a generic computational unit that provides input and output sig...
Provides a way to create Entity objects from their class name.
void dgERRORF(const int, const char *,...)
static FactoryStorage * instance_
\pointer to the unique object of the class
void registerEntity(const std::string &entname, EntityConstructor_ptr ent)
Add a new entity to the factory.
#define dgDEBUGOUT(level)
void listEntities(std::vector< std::string > &list) const
List the available entities.
#define dgDEBUGIN(level)
VP_DEBUG.
void deregisterEntity(const std::string &entname)
Delete an entity from the factory.
bool existEntity(const std::string &name) const
Check if an Entity associated with a particular name has already been registered.
const std::string entityName
Name of the entity registered when the instance has been initialized.
#define dgDEBUGINOUT(level)
Entity * newEntity(const std::string &classname, const std::string &objname) const
Instantiate (and allocate) an entity.
static FactoryStorage * getInstance()
Get pointer to unique object of the class.
dynamic-graph
Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Fri Aug 2 2024 08:36:38