メインページ | ネームスペース一覧 | クラス階層 | 構成 | ファイル一覧 | ネームスペースメンバ | 構成メンバ | ファイルメンバ

RtcInPort.h

説明を見る。
00001 // -*- C++ -*-
00021 #ifndef __RtcInPort_h__
00022 #define __RtcInPort_h__
00023 
00024 #include "rtm/RtcInPortBase.h"
00025 #include "rtm/idl/RTCDataTypeSkel.h"
00026 #include <iostream>
00027 
00028 namespace RTM
00029 {
00030   using namespace std;
00057   template <class T> class InPortAny
00058         : public InPortBase
00059   {
00060   public:
00086         InPortAny(const char* name, T& value, int bufsize=64)
00087           : m_Buffer(bufsize), m_Value(value)
00088         {
00089           // Set PortProfile
00090           m_Profile.name = CORBA::string_dup(name);
00091           CORBA::Any var;
00092           var <<= m_Value;
00093           m_Profile.port_type = var.type();
00094           
00095           // Initializing ring buffer
00096           for (int i = 0 ; i <= m_Buffer.buff_length(); i++)
00097                 {
00098                   m_Buffer.put(value);
00099                 }
00100         };
00101 
00125         InPortAny(const char* name, int bufsize=64)
00126           : m_Buffer(bufsize), m_Value(m_Dummy)
00127         {
00128           // Set PortProfile
00129           m_Profile.name = CORBA::string_dup(name);
00130           CORBA::Any var;
00131           var <<= m_Value;
00132           m_Profile.port_type = var.type();
00133           
00134           // Initializing ring buffer
00135           for (int i = 0 ; i <= m_Buffer.buff_length(); i++)
00136                 {
00137                   m_Buffer.put(m_Value);
00138                 }
00139         };
00140         
00141         
00155         virtual ~InPortAny(){};
00156 
00170         virtual void put(const CORBA::Any& value)
00171           throw (RTM::InPort::Disconnected, CORBA::SystemException)
00172         {
00173           T* tmp;
00174 
00175           if (value >>= tmp)
00176                 m_Buffer.put(*tmp);
00177         }
00178         
00192         virtual void initBuffer(T& value)
00193         {
00194           for (int i = 0 ; i <= m_Buffer.buff_length(); i++)
00195                 {
00196                   m_Buffer.put(value);
00197                 }
00198         }
00199 
00200 
00215         virtual T read()
00216         {
00217           m_Value = m_Buffer.get_new();
00218           return m_Value;
00219         };
00220         
00236         virtual bool operator>>(T& rhs)
00237         {
00238           rhs = m_Buffer.get_new();
00239           return true;
00240         };
00241         
00242 
00243   private:
00251         T& m_Value;
00252 
00260         T  m_Dummy;
00261 
00269         T* m_Tmp;
00270 
00278         RingBuffer<T> m_Buffer;
00279 
00280   };
00281   
00282 }; // End of namesepace RTM
00283 
00284 #endif // __RtcInPort_h__

OpenRTMに対してThu Dec 16 15:29:05 2004に生成されました。 doxygen 1.3.6