00001 // -*- C++ -*- 00020 #ifndef InPortCorbaProvider_h 00021 #define InPortCorbaProvider_h 00022 00023 #include <rtm/idl/DataPortSkel.h> 00024 #include <rtm/BufferBase.h> 00025 #include <rtm/InPortProvider.h> 00026 #include <rtm/CORBA_SeqUtil.h> 00027 #include <rtm/Manager.h> 00028 00029 #ifdef WIN32 00030 #pragma warning( disable : 4290 ) 00031 #endif 00032 00033 namespace RTC 00034 { 00060 template <class DataType> 00061 class InPortCorbaProvider 00062 : public InPortProvider, 00063 public virtual POA_RTC::InPortAny, 00064 public virtual PortableServer::RefCountServantBase 00065 { 00066 public: 00092 InPortCorbaProvider(BufferBase<DataType>& buffer) 00093 : InPortProvider(), m_buffer(buffer) 00094 { 00095 CORBA::Any any_var; 00096 DataType tmp_var; 00097 any_var <<= tmp_var; 00098 00099 // PortProfile setting 00100 setDataType(any_var.type()->name()); 00101 setInterfaceType("CORBA_Any"); 00102 setDataFlowType("Push, Pull"); 00103 setSubscriptionType("Any"); 00104 00105 // ConnectorProfile setting 00106 m_objref = this->_this(); 00107 00108 // set InPort's reference 00109 CORBA::ORB_ptr orb = ::RTC::Manager::instance().getORB(); 00110 CORBA_SeqUtil:: 00111 push_back(m_properties, 00112 NVUtil::newNV("dataport.corba_any.inport_ior", 00113 orb->object_to_string(m_objref.in()))); 00114 CORBA_SeqUtil:: 00115 push_back(m_properties, 00116 NVUtil::newNV("dataport.corba_any.inport_ref", 00117 RTC::InPortAny::_duplicate(m_objref))); 00118 } 00119 00133 virtual ~InPortCorbaProvider(void) 00134 { 00135 } 00136 00154 virtual void put(const CORBA::Any& data) 00155 throw (CORBA::SystemException) 00156 { 00157 RTC_PARANOID(("put()")); 00158 const DataType* tmp; 00159 if (data >>= tmp) 00160 { 00161 m_buffer.write(*tmp); 00162 } 00163 return; 00164 } 00165 00166 private: 00167 BufferBase<DataType>& m_buffer; 00168 RTC::InPortAny_var m_objref; 00169 }; // class InPortCorbaProvider 00170 }; // namespace RTC 00171 00172 #ifdef WIN32 00173 #pragma warning( default : 4290 ) 00174 #endif 00175 00176 #endif // InPortCorbaProvider_h 00177