6 #ifndef DYNAMIC_GRAPH_FACTORY_HH
7 #define DYNAMIC_GRAPH_FACTORY_HH
8 #include <dynamic-graph/dynamic-graph-api.h>
9 #include <dynamic-graph/exception-factory.h>
11 #include <boost/noncopyable.hpp>
12 #include <dynamic-graph/fwd.hh>
26 #define DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(CLASSTYPE, CLASSNAME) \
27 const std::string CLASSTYPE::CLASS_NAME = CLASSNAME; \
29 ::dynamicgraph::Entity *EntityMaker_##CLASSTYPE( \
30 const std::string &objname) { \
31 return new CLASSTYPE(objname); \
33 ::dynamicgraph::EntityRegisterer reg_##CLASSTYPE(CLASSNAME, \
34 &EntityMaker_##CLASSTYPE); \
36 struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
85 typedef Entity *(*EntityConstructor_ptr)(
const std::string &);
137 const std::string &objname)
const;
165 typedef std::map<std::string, EntityConstructor_ptr> EntityMap;
196 const std::string entityName;
This class automatically register an Entity to the global factory at initialization and unregister it...
~EntityRegisterer()
Unregister entity to the global factory.
EntityRegisterer(const std::string &entityClassName, FactoryStorage::EntityConstructor_ptr maker)
Register entity to the global factory.
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.
static void destroy()
Destroy the unique instance of the class.
Entity *(* EntityConstructor_ptr)(const std::string &)
Function pointer providing an entity instance from its name.
bool existEntity(const std::string &name) const
Check if an Entity associated with a particular name has already been registered.
static FactoryStorage * getInstance()
Get pointer to unique object of the class.
void listEntities(std::vector< std::string > &list) const
List the available entities.
Entity * newEntity(const std::string &classname, const std::string &objname) const
Instantiate (and allocate) an entity.
void registerEntity(const std::string &entname, EntityConstructor_ptr ent)
Add a new entity to the factory.
void deregisterEntity(const std::string &entname)
Delete an entity from the factory.