00001 // -*- C++ -*- 00020 #ifndef RTC_OUTPORTPROVIDER_H 00021 #define RTC_OUTPORTPROVIDER_H 00022 00023 #include <string> 00024 00025 #include <coil/Factory.h> 00026 #include <rtm/BufferBase.h> 00027 #include <rtm/NVUtil.h> 00028 #include <rtm/SystemLogger.h> 00029 #include <rtm/DataPortStatus.h> 00030 #include <rtm/OutPortConnector.h> 00031 00032 namespace RTC 00033 { 00034 class ConnectorListeners; 00189 class OutPortProvider 00190 : public DataPortStatus 00191 { 00192 public: 00193 DATAPORTSTATUS_ENUM 00207 virtual ~OutPortProvider(void); 00208 00236 virtual void init(coil::Properties& prop); 00237 00263 virtual void setBuffer(CdrBufferBase* buffer) = 0; 00264 00295 virtual void setListener(ConnectorInfo& info, 00296 ConnectorListeners* listeners) = 0; 00297 00322 virtual void setConnector(OutPortConnector* connector) = 0; 00323 00347 virtual void publishInterfaceProfile(SDOPackage::NVList& properties); 00348 00376 virtual bool publishInterface(SDOPackage::NVList& properties); 00377 00378 protected: 00396 void setPortType(const char* port_type); 00397 00415 void setDataType(const char* data_type); 00416 00434 void setInterfaceType(const char* interface_type); 00435 00453 void setDataFlowType(const char* dataflow_type); 00454 00472 void setSubscriptionType(const char* subs_type); 00473 00474 protected: 00482 SDOPackage::NVList m_properties; 00490 mutable Logger rtclog; 00491 00492 private: 00493 std::string m_portType; 00494 std::string m_dataType; 00495 std::string m_interfaceType; 00496 std::string m_dataflowType; 00497 std::string m_subscriptionType; 00498 00499 00500 public: 00508 struct publishInterfaceProfileFunc 00509 { 00510 publishInterfaceProfileFunc(SDOPackage::NVList& prop) : m_prop(prop) {} 00511 void operator()(OutPortProvider* provider) 00512 { 00513 provider->publishInterfaceProfile(m_prop); 00514 } 00515 SDOPackage::NVList& m_prop; 00516 }; 00517 00525 struct publishInterfaceFunc 00526 { 00527 publishInterfaceFunc(SDOPackage::NVList& prop) 00528 : m_prop(prop), provider_(0) {} 00529 void operator()(OutPortProvider* provider) 00530 { 00531 if (provider->publishInterface(m_prop)) 00532 { 00533 provider_ = provider; 00534 } 00535 } 00536 SDOPackage::NVList& m_prop; 00537 OutPortProvider* provider_; 00538 }; 00539 }; 00540 00548 typedef ::coil::GlobalFactory<OutPortProvider> OutPortProviderFactory; 00549 00550 }; // namespace RTC 00551 #endif // RTC_OUTPORTPROVIDER_H