00001 // -*- C++ -*- 00020 #ifndef RTC_INPORTPROVIDER_H 00021 #define RTC_INPORTPROVIDER_H 00022 00023 #include <string> 00024 00025 #include <coil/Factory.h> 00026 00027 #include <rtm/BufferBase.h> 00028 #include <rtm/NVUtil.h> 00029 #include <rtm/SystemLogger.h> 00030 #include <rtm/DataPortStatus.h> 00031 #include <rtm/InPortConnector.h> 00032 00033 namespace RTC 00034 { 00035 class ConnectorListeners; 00036 class ConnectorInfo; 00037 00057 class InPortProvider 00058 : public DataPortStatus 00059 { 00060 public: 00061 DATAPORTSTATUS_ENUM 00075 InPortProvider(); 00076 00090 virtual ~InPortProvider(void); 00091 00106 virtual void init(coil::Properties& prop) = 0; 00107 00123 virtual void setBuffer(BufferBase<cdrMemoryStream>* buffer) = 0; 00124 00132 virtual void setListener(ConnectorInfo& info, 00133 ConnectorListeners* listeners) = 0; 00134 00142 virtual void setConnector(InPortConnector* connector) = 0; 00143 00161 virtual void publishInterfaceProfile(SDOPackage::NVList& properties); 00162 00180 virtual bool publishInterface(SDOPackage::NVList& properties); 00181 00182 protected: 00200 void setInterfaceType(const char* interface_type); 00201 00219 void setDataFlowType(const char* dataflow_type); 00220 00238 void setSubscriptionType(const char* subs_type); 00239 00240 00241 protected: 00249 SDOPackage::NVList m_properties; 00250 00258 mutable Logger rtclog; 00259 00260 private: 00261 std::string m_interfaceType; 00262 std::string m_dataflowType; 00263 std::string m_subscriptionType; 00264 00265 public: 00266 // functors 00274 struct publishInterfaceProfileFunc 00275 { 00276 publishInterfaceProfileFunc(SDOPackage::NVList& prop) : m_prop(prop) {} 00277 void operator()(InPortProvider* provider) 00278 { 00279 provider->publishInterfaceProfile(m_prop); 00280 } 00281 SDOPackage::NVList& m_prop; 00282 }; 00283 00291 struct publishInterfaceFunc 00292 { 00293 publishInterfaceFunc(SDOPackage::NVList& prop) 00294 : m_prop(prop), provider_(0) {} 00295 void operator()(InPortProvider* provider) 00296 { 00297 if (provider->publishInterface(m_prop)) 00298 { 00299 provider_ = provider; 00300 } 00301 } 00302 SDOPackage::NVList& m_prop; 00303 InPortProvider* provider_; 00304 }; 00305 00306 00307 }; 00308 00309 typedef ::coil::GlobalFactory<InPortProvider> InPortProviderFactory; 00310 00311 }; // namespace RTC 00312 #endif // RTC_INPORTPROVIDER_H