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

DataInPort.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00020 /*
00021  * $Log: DataInPort.h,v $
00022  * Revision 1.6  2007/01/21 17:16:58  n-ando
00023  * Invalid kanji code was deleted.
00024  *
00025  * Revision 1.5  2007/01/21 09:43:22  n-ando
00026  * - A bug about memory access violation to m_providers still exists.
00027  *   This bug arises on Fedora5/gcc4 environment.
00028  *   To escape the bug temporarily dummy variable (m_dummy) is defined.
00029  * - Some functors were moved to cpp file.
00030  *
00031  * Revision 1.4  2007/01/14 22:57:48  n-ando
00032  * A bug fix about template argument for buffer-type in constructor.
00033  *
00034  * Revision 1.3  2007/01/12 14:29:48  n-ando
00035  * A trivial bug fix.
00036  *
00037  * Revision 1.2  2007/01/06 17:43:39  n-ando
00038  * The behavior on notify_connect() and notify_disconnect() are now
00039  * implemented in protected functions(ex. publisherInterfaces()).
00040  *
00041  * Revision 1.1  2006/12/02 18:27:49  n-ando
00042  * The first commitment.
00043  *
00044  *
00045  */
00046 
00047 #ifndef DataInPort_h
00048 #define DataInPort_h
00049 
00050 #include <rtm/PortBase.h>
00051 #include <rtm/BufferBase.h>
00052 #include <rtm/InPortCorbaProvider.h>
00053 #include <rtm/InPortTcpSockProvider.h>
00054 #include <rtm/OutPortCorbaConsumer.h>
00055 #include <rtm/NVUtil.h>
00056 #include <rtm/InPort.h>
00057 #include <stdio.h>
00058 
00059 namespace RTC
00060 {
00071   class DataInPort
00072     : public virtual PortBase
00073   {
00074 
00075   public:
00076     template <class DataType, template <class DataType> class Buffer>
00077     DataInPort(const char* name, InPort<DataType, Buffer>& inport,
00078                Properties& prop)
00079       : PortBase(name)
00080     {
00081       // PortProfile::properties を設定
00082       addProperty("port.port_type", "DataInPort");
00083 
00084       // CORBA InPort Provider
00085       m_providers.push_back(new InPortCorbaProvider<DataType>(inport));
00086       m_providers.back()->publishInterfaceProfile(m_profile.properties);
00087 
00088       // TCP Socket InPort Provider
00089       m_providers.push_back(new InPortTcpSockProvider<DataType>(inport, prop));
00090       m_providers.back()->publishInterfaceProfile(m_profile.properties);
00091 
00092       // CORBA OutPort Consumer
00093       m_consumers.push_back(new OutPortCorbaConsumer<DataType>(inport));
00094 
00095       // dummy var
00096       m_dummy.push_back(1);
00097     }
00098 
00099     virtual ~DataInPort();
00100 
00101   protected:
00102     virtual ReturnCode_t
00103     publishInterfaces(ConnectorProfile& connector_profile);
00104 
00105     virtual ReturnCode_t
00106     subscribeInterfaces(const ConnectorProfile& connector_profile);
00107 
00108     virtual void
00109     unsubscribeInterfaces(const ConnectorProfile& connector_profile);
00110     
00111     struct publish;
00112     struct subscribe;
00113     struct unsubscribe;
00114 
00115   private:
00116     /*
00117      * Bug
00118      *
00119      * Fedora5/gcc4.1.1. にて DataInPort の先頭領域のメモリ破壊が
00120      * 起こっている模様。
00121      * (gdbでかなり粘って追ってみたが断念)
00122      * もともともは std::vector<InPortProvider*> m_providers が先頭
00123      * このままだと、
00124      * $vec->_M_impl._M_start:  begin() に相当?
00125      * $vec->_M_impl._M_finish: end() に相当?
00126      * においてい _M_start が不可解な位置を指すため、
00127      * m_providers に対して for_each を適用するとSegvで落ちる。
00128      *
00129      * FreeBSD6.0/gcc3.4.4ではこの現象は発生せず。
00130      */
00131     std::vector<int> m_dummy;
00132     std::vector<InPortProvider*> m_providers;
00133     std::vector<OutPortConsumer*> m_consumers;
00134   };
00135 }; // namespace RTC
00136 
00137 #endif // DataInPort_h

Generated on Fri Oct 5 05:15:59 2007 for OpenRTM by  doxygen 1.4.1