Skip to content
Snippets Groups Projects
Commit e6d83d81 authored by Thomas Moulard's avatar Thomas Moulard
Browse files

Make DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN more robust.

The previous implementation was not namespace independent.
Fix this by specifying types properly.
parent 56d545a3
No related branches found
No related tags found
No related merge requests found
......@@ -75,8 +75,6 @@ class DYNAMIC_GRAPH_DLLAPI FactoryStorage
void listEntities(std::vector <std::string>& outList);
void commandLine( const std::string& cmdLine,std::istringstream& cmdArgs,
std::ostream& os );
};
DYNAMIC_GRAPH_DLLAPI extern FactoryStorage g_factory;
......@@ -104,25 +102,26 @@ class DYNAMIC_GRAPH_DLLAPI EntityRegisterer
~EntityRegisterer( void );
};
} // namespace dynamicgraph
/*! This macro should be used to automatically register an entity
* of classType to the g_factory. It is then possible to create it
* with the g_factory.
*/
#define DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(classType,className) \
#define DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(classType, className) \
const std::string classType::CLASS_NAME = className; \
extern "C" { \
Entity *EntityMaker##_##classType( const std::string& objname ) \
::dynamicgraph::Entity* \
EntityMaker##_##classType(const std::string& objname) \
{ \
return new classType( objname ); \
return new classType (objname); \
} \
EntityRegisterer reg##_##classType( className, \
&EntityMaker##_##classType ); \
::dynamicgraph::EntityRegisterer \
reg##_##classType (className, \
&EntityMaker##_##classType); \
} \
struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
} // namespace dynamicgraph
#endif /* #ifndef __FACTORY_HH__ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment