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 00190 class InPortProvider 00191 : public DataPortStatus 00192 { 00193 public: 00194 DATAPORTSTATUS_ENUM 00208 InPortProvider(); 00209 00223 virtual ~InPortProvider(void); 00224 00252 virtual void init(coil::Properties& prop) = 0; 00253 00279 virtual void setBuffer(BufferBase<cdrMemoryStream>* buffer) = 0; 00280 00311 virtual void setListener(ConnectorInfo& info, 00312 ConnectorListeners* listeners) = 0; 00313 00338 virtual void setConnector(InPortConnector* connector) = 0; 00339 00363 virtual void publishInterfaceProfile(SDOPackage::NVList& properties); 00364 00392 virtual bool publishInterface(SDOPackage::NVList& properties); 00393 00394 protected: 00412 void setInterfaceType(const char* interface_type); 00413 00431 void setDataFlowType(const char* dataflow_type); 00432 00450 void setSubscriptionType(const char* subs_type); 00451 00452 00453 protected: 00461 SDOPackage::NVList m_properties; 00462 00470 mutable Logger rtclog; 00471 00472 private: 00473 std::string m_interfaceType; 00474 std::string m_dataflowType; 00475 std::string m_subscriptionType; 00476 00477 public: 00478 // functors 00486 struct publishInterfaceProfileFunc 00487 { 00488 publishInterfaceProfileFunc(SDOPackage::NVList& prop) : m_prop(prop) {} 00489 void operator()(InPortProvider* provider) 00490 { 00491 provider->publishInterfaceProfile(m_prop); 00492 } 00493 SDOPackage::NVList& m_prop; 00494 }; 00495 00503 struct publishInterfaceFunc 00504 { 00505 publishInterfaceFunc(SDOPackage::NVList& prop) 00506 : m_prop(prop), provider_(0) {} 00507 void operator()(InPortProvider* provider) 00508 { 00509 if (provider->publishInterface(m_prop)) 00510 { 00511 provider_ = provider; 00512 } 00513 } 00514 SDOPackage::NVList& m_prop; 00515 InPortProvider* provider_; 00516 }; 00517 00518 00519 }; 00520 00528 typedef ::coil::GlobalFactory<InPortProvider> InPortProviderFactory; 00529 00530 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) 00531 EXTERN template class DLL_PLUGIN ::coil::GlobalFactory<InPortProvider>; 00532 #endif 00533 }; // namespace RTC 00534 #endif // RTC_INPORTPROVIDER_H