From 34931a0db279443c0f65555f40a4a155e74ab9c3 Mon Sep 17 00:00:00 2001 From: Peter Soetens Date: Tue, 10 Aug 2010 14:10:53 +0200 Subject: [PATCH] deployment: let 3rd party use RTT_COMPONENT instead of OCL_DLL_EXPORT and fix decorations All plugin functions have OCL_EXPORT, except the lib-local factory, which is a hidden symbol for each dll/so. This cleans up a long standing issue with symbols in wrong places with wrong decorations. Signed-off-by: Peter Soetens --- deployment/ComponentLoader.cpp | 4 +++- ocl/Component.hpp | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/deployment/ComponentLoader.cpp b/deployment/ComponentLoader.cpp index 7dc668a..b2a448c 100644 --- a/deployment/ComponentLoader.cpp +++ b/deployment/ComponentLoader.cpp @@ -25,7 +25,7 @@ * * ***************************************************************************/ -// suppress warning in ComponentLoader.hpp +// suppress warning in Component.hpp #define OCL_STATIC #include "ocl/Component.hpp" #include "ComponentLoader.hpp" @@ -41,6 +41,8 @@ using namespace boost::filesystem; namespace OCL { + // We have our own copy of the Factories object to store all + // loaded component types. This is pointer is only shared with the DeploymentComponent. FactoryMap* ComponentFactories::Factories = 0; } diff --git a/ocl/Component.hpp b/ocl/Component.hpp index cbffffb..5c66e3a 100644 --- a/ocl/Component.hpp +++ b/ocl/Component.hpp @@ -67,7 +67,7 @@ namespace OCL */ OCL_HIDE static FactoryMap* Factories; public: - OCL_API static FactoryMap& Instance() { + OCL_HIDE static FactoryMap& Instance() { if ( Factories == 0) Factories = new FactoryMap(); return *Factories; @@ -103,7 +103,7 @@ namespace OCL #define ORO_LIST_COMPONENT_TYPE__str(s) #s // ORO_CREATE_COMPONENT and ORO_CREATE_COMPONENT_TYPE are only used in shared libraries. -#if defined(OCL_DLL_EXPORT) +#if defined(OCL_DLL_EXPORT) || defined (RTT_COMPONENT) /** * Use this macro to register a single component in a shared library (plug-in). @@ -120,11 +120,11 @@ namespace OCL */ #define ORO_CREATE_COMPONENT(CNAME) \ extern "C" { \ - OCL_API RTT::TaskContext* createComponent(std::string instance_name) \ + OCL_EXPORT RTT::TaskContext* createComponent(std::string instance_name) \ { \ return new CNAME(instance_name); \ } \ - OCL_API std::string getComponentType() \ + OCL_EXPORT std::string getComponentType() \ { \ return ORO_LIST_COMPONENT_TYPE_str(CNAME); \ } \ @@ -139,13 +139,13 @@ extern "C" { \ #define ORO_CREATE_COMPONENT_TYPE() \ OCL::FactoryMap* OCL::ComponentFactories::Factories = 0; \ extern "C" { \ - OCL_API RTT::TaskContext* createComponentType(std::string instance_name, std::string type_name) \ + OCL_EXPORT RTT::TaskContext* createComponentType(std::string instance_name, std::string type_name) \ { \ if( OCL::ComponentFactories::Instance().count(type_name) ) \ return OCL::ComponentFactories::Instance()[type_name](instance_name); \ return 0; \ } \ - OCL_API std::vector getComponentTypeNames() \ + OCL_EXPORT std::vector getComponentTypeNames() \ { \ std::vector ret; \ OCL::FactoryMap::iterator it; \ @@ -154,16 +154,16 @@ extern "C" { \ } \ return ret; \ } \ - OCL_API OCL::FactoryMap* getComponentFactoryMap() { return &OCL::ComponentFactories::Instance(); } \ + OCL_EXPORT OCL::FactoryMap* getComponentFactoryMap() { return &OCL::ComponentFactories::Instance(); } \ } /* extern "C" */ #else -#ifndef OCL_STATIC +#if !defined(OCL_STATIC) && !defined(RTT_STATIC) #warning "You're compiling with static library settings. The resulting component library \ will not be loadable at runtime with the deployer.\ - Compile with -DOCL_DLL_EXPORT to enable dynamic loadable components, \ - or use -DOCL_STATIC to suppress this warning." + Compile with -DRTT_COMPONENT to enable dynamic loadable components, \ + or use -DRTT_STATIC to suppress this warning." #endif // Static OCL library: -- 1.6.3.3