47 #ifndef RTT_COMPONENT_HPP 48 #define RTT_COMPONENT_HPP 54 #include "rtt-config.h" 61 typedef TaskContext* (*ComponentLoaderSignature)(std::string instance_name);
62 typedef std::map<std::string,ComponentLoaderSignature>
FactoryMap;
100 return new C(instance_name);
106 #define ORO_CONCAT_LINE2(x,y) x##y 107 #define ORO_CONCAT_LINE1(x,y) ORO_CONCAT_LINE2(x,y) 108 #define ORO_CONCAT_LINE(x) ORO_CONCAT_LINE1(x,__LINE__) 110 #define ORO_LIST_COMPONENT_TYPE_str(s) ORO_LIST_COMPONENT_TYPE__str(s) 111 #define ORO_LIST_COMPONENT_TYPE__str(s) #s 114 #if defined(OCL_DLL_EXPORT) || defined (RTT_COMPONENT) 117 #pragma warning (disable:4190) 121 #pragma clang diagnostic ignored "-Wreturn-type-c-linkage" 140 #define ORO_CREATE_COMPONENT(CNAME) \ 142 RTT_EXPORT RTT::TaskContext* createComponent(std::string instance_name); \ 143 RTT::TaskContext* createComponent(std::string instance_name) \ 145 return new CNAME(instance_name); \ 147 RTT_EXPORT std::string getComponentType(); \ 148 std::string getComponentType() \ 150 return ORO_LIST_COMPONENT_TYPE_str(CNAME); \ 161 #define ORO_CREATE_COMPONENT_LIBRARY() \ 162 RTT::FactoryMap* RTT::ComponentFactories::Factories = 0; \ 164 RTT_EXPORT RTT::TaskContext* createComponentType(std::string instance_name, std::string type_name) \ 166 if( RTT::ComponentFactories::Instance().count(type_name) ) \ 167 return RTT::ComponentFactories::Instance()[type_name](instance_name); \ 170 RTT_EXPORT std::vector<std::string> getComponentTypeNames() \ 172 std::vector<std::string> ret; \ 173 RTT::FactoryMap::iterator it; \ 174 for(it = RTT::ComponentFactories::Instance().begin(); it != RTT::ComponentFactories::Instance().end(); ++it) { \ 175 ret.push_back(it->first); \ 179 RTT_EXPORT RTT::FactoryMap* getComponentFactoryMap() { return &RTT::ComponentFactories::Instance(); } \ 184 #if !defined(OCL_STATIC) && !defined(RTT_STATIC) && !defined(RTT_DLL_EXPORT) 185 #warning "You're compiling with static library settings. The resulting component library \ 186 will not be loadable at runtime with the deployer.\ 187 Compile with -DRTT_COMPONENT to enable dynamic loadable components, \ 188 or use -DRTT_STATIC to suppress this warning." 193 #define ORO_CREATE_COMPONENT(CLASS_NAME) namespace { namespace ORO_CONCAT_LINE(LOADER_) { RTT::ComponentFactoryLoader<CLASS_NAME> m_cloader(ORO_LIST_COMPONENT_TYPE_str(CLASS_NAME)); } } 194 #define ORO_CREATE_COMPONENT_LIBRARY() __attribute__((weak)) RTT::FactoryMap* RTT::ComponentFactories::Factories = 0; 215 #define ORO_LIST_COMPONENT_TYPE(CLASS_NAME) namespace { namespace ORO_CONCAT_LINE(LOADER_) { RTT::ComponentFactoryLoader<CLASS_NAME> m_cloader(ORO_LIST_COMPONENT_TYPE_str(CLASS_NAME)); } } 220 #define ORO_CREATE_COMPONENT_TYPE( ) ORO_CREATE_COMPONENT_LIBRARY( ) static RTT_HIDE FactoryMap & Instance()
std::map< std::string, ComponentLoaderSignature > FactoryMap
static RTT_HIDE FactoryMap * Factories
ComponentFactoryLoader(std::string type_name)
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
static TaskContext * createComponent(std::string instance_name)