Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

OutPortCorbaProvider.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00020 /*
00021  * $Log: OutPortCorbaProvider.h,v $
00022  * Revision 1.3  2007/01/14 23:01:53  n-ando
00023  * Now object reference is duplicate to set property.
00024  *
00025  * Revision 1.2  2007/01/06 17:57:35  n-ando
00026  * Interface subscription/unsubscription functions (subscribeInterface()
00027  * and unsubscribeInterface()) are added.
00028  *
00029  * Revision 1.1  2006/12/02 18:48:21  n-ando
00030  * The first commitment.
00031  *
00032  * Revision 1.1  2006/11/27 09:44:42  n-ando
00033  * The first commitment.
00034  *
00035  */
00036 
00037 #ifndef OutPortCorbaProvider_h
00038 #define OutPortCorbaProvider_h
00039 
00040 #include <rtm/idl/DataPortSkel.h>
00041 #include <rtm/BufferBase.h>
00042 #include <rtm/OutPortProvider.h>
00043 
00044 namespace RTC
00045 {
00055   template <class DataType>
00056   class OutPortCorbaProvider
00057     : public OutPortProvider,
00058       public virtual POA_RTC::OutPortAny,
00059       public virtual PortableServer::RefCountServantBase
00060   {
00061   public:
00069     OutPortCorbaProvider(BufferBase<DataType>& buffer)
00070       : m_buffer(buffer)
00071     {
00072       CORBA::Any any_var;
00073       DataType   tmp_var;
00074       any_var <<= tmp_var;
00075       
00076       // PortProfile setting
00077       setDataType(any_var.type()->name());
00078       setInterfaceType("CORBA_Any");
00079       setDataFlowType("Push, Pull");
00080       setSubscriptionType("Any");
00081 
00082       // ConnectorProfile setting
00083       m_objref = this->_this();
00084       CORBA_SeqUtil::push_back(m_properties,
00085                                NVUtil::newNV("dataport.corba_any.outport_ref",
00086                                              RTC::OutPortAny::_duplicate(m_objref)));
00087     }
00088     
00096     virtual ~OutPortCorbaProvider()
00097     {}
00098 
00099     CORBA::Any* get()
00100     {
00101       DataType data;
00102       CORBA::Any_var tmp = new CORBA::Any();
00103       m_buffer.read(data);
00104       tmp <<= data;
00105       return tmp._retn();
00106     }
00107 
00108    
00109   private:
00110     BufferBase<DataType>& m_buffer;
00111     OutPortAny_var m_objref;
00112   };
00113 };     // namespace RTC
00114 #endif // OutPortCorbaProvider_h
00115 

Generated on Mon Jan 15 12:15:35 2007 for OpenRTM by  doxygen 1.4.1