From e6d83d817c586702090c8f1ff36aee3ad26dd7f4 Mon Sep 17 00:00:00 2001 From: Thomas Moulard <thomas.moulard@gmail.com> Date: Thu, 23 Dec 2010 23:17:07 +0100 Subject: [PATCH] Make DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN more robust. The previous implementation was not namespace independent. Fix this by specifying types properly. --- include/dynamic-graph/factory.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/include/dynamic-graph/factory.h b/include/dynamic-graph/factory.h index 760a73a..5c2e192 100644 --- a/include/dynamic-graph/factory.h +++ b/include/dynamic-graph/factory.h @@ -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__ */ -- GitLab