InPortCorbaCdrProvider.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
21 
22 #ifdef WIN32
23 #pragma warning( disable : 4290 )
24 #endif
25 
26 namespace RTC
27 {
36  : m_buffer(0)
37  {
38  // PortProfile setting
39  setInterfaceType("corba_cdr");
40 
41  // ConnectorProfile setting
42  m_objref = this->_this();
43 
44  // set InPort's reference
45  CORBA::ORB_ptr orb = ::RTC::Manager::instance().getORB();
46  CORBA::String_var ior = orb->object_to_string(m_objref.in());
49  NVUtil::newNV("dataport.corba_cdr.inport_ior", ior.in()));
52  NVUtil::newNV("dataport.corba_cdr.inport_ref", m_objref));
53  }
54 
63  {
64  try
65  {
66  PortableServer::ObjectId_var oid;
67  oid = _default_POA()->servant_to_id(this);
68  _default_POA()->deactivate_object(oid);
69  }
70  catch (PortableServer::POA::ServantNotActive &e)
71  {
72  RTC_ERROR(("%s", e._name()));
73  }
74  catch (PortableServer::POA::WrongPolicy &e)
75  {
76  RTC_ERROR(("%s", e._name()));
77  }
78  catch (...)
79  {
80  // never throws exception
81  RTC_ERROR(("Unknown exception caught."));
82  }
83  }
84 
86  {
87  }
88 
98  {
99  m_buffer = buffer;
100  }
101 
110  ConnectorListeners* listeners)
111  {
112  m_profile = info;
113  m_listeners = listeners;
114  }
115 
124  {
125  m_connector = connector;
126  }
127 
135  ::OpenRTM::PortStatus
136  InPortCorbaCdrProvider::put(const ::OpenRTM::CdrData& data)
137  throw (CORBA::SystemException)
138  {
139  RTC_PARANOID(("InPortCorbaCdrProvider::put()"));
140 
141  if (m_buffer == 0)
142  {
143  cdrMemoryStream cdr;
144  cdr.put_octet_array(&(data[0]), data.length());
145  onReceiverError(cdr);
146  return ::OpenRTM::PORT_ERROR;
147  }
148 
149  RTC_PARANOID(("received data size: %d", data.length()))
150  cdrMemoryStream cdr;
151  // set endian type
152  bool endian_type = m_connector->isLittleEndian();
153  RTC_TRACE(("connector endian: %s", endian_type ? "little":"big"));
154  cdr.setByteSwapFlag(endian_type);
155  cdr.put_octet_array(&(data[0]), data.length());
156 
157  RTC_PARANOID(("converted CDR data size: %d", cdr.bufSize()));
158  onReceived(cdr);
160 
161  return convertReturn(ret, cdr);
162  }
163 
171  ::OpenRTM::PortStatus
173  const cdrMemoryStream& data)
174  {
175  switch(status)
176  {
178  onBufferWrite(data);
179  return ::OpenRTM::PORT_OK;
180  break;
181 
183  onReceiverError(data);
184  return ::OpenRTM::PORT_ERROR;
185  break;
186 
188  onBufferFull(data);
189  onReceiverFull(data);
190  return ::OpenRTM::BUFFER_FULL;
191  break;
192 
194  // never come here
195  return ::OpenRTM::BUFFER_EMPTY;
196  break;
197 
199  onReceiverError(data);
200  return ::OpenRTM::PORT_ERROR;
201  break;
202 
204  onBufferWriteTimeout(data);
205  onReceiverTimeout(data);
206  return ::OpenRTM::BUFFER_TIMEOUT;
207  break;
208 
209  default:
210  return ::OpenRTM::UNKNOWN_ERROR;
211  }
212 
213  onReceiverError(data);
214  return ::OpenRTM::UNKNOWN_ERROR;
215  }
216 
217 }; // namespace RTC
218 
219 
220 extern "C"
221 {
230  {
232  factory.addFactory("corba_cdr",
237  }
238 };
SDOPackage::NameValue newNV(const char *name, Value value)
Create NameValue.
Definition: NVUtil.h:79
void onBufferWriteTimeout(const cdrMemoryStream &data)
Notify an ON_BUFFER_WRITE_TIMEOUT event to listeners.
ConnectorListeners class.
#define RTC_ERROR(fmt)
Error log output macro.
Definition: SystemLogger.h:422
RT-Component.
SDOPackage::NVList m_properties
Properties to hold port profile.
AbstractClass * Creator()
Creator template.
void onReceiverError(const cdrMemoryStream &data)
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
ReturnCode addFactory(const Identifier &id, Creator creator, Destructor destructor)
Add factory.
CORBA::ORB_ptr getORB()
Get the pointer to ORB.
Definition: Manager.cpp:832
static GlobalFactory< AbstractClass, Identifier, Compare, Creator, Destructor > & instance()
Create instance.
Definition: Singleton.h:131
static Manager & instance()
Get instance of the manager.
Definition: Manager.cpp:140
virtual ~InPortCorbaCdrProvider(void)
Destructor.
void onReceiverTimeout(const cdrMemoryStream &data)
Notify an ON_RECEIVER_TIMEOUT event to listeners.
GlobalFactory template class.
Enum
DataPortStatus return codes.
Definition: BufferStatus.h:84
InPortProvider.
InPortCorbaCdrProvider class.
#define RTC_PARANOID(fmt)
Paranoid level log output macro.
Definition: SystemLogger.h:555
virtual void setListener(ConnectorInfo &info, ConnectorListeners *listeners)
Set the listener.
void onBufferWrite(const cdrMemoryStream &data)
Notify an ON_BUFFER_WRITE event to listeners.
void onReceiverFull(const cdrMemoryStream &data)
Notify an ON_RECEIVER_FULL event to listeners.
InPortCorbaCdrProvider class.
virtual void setConnector(InPortConnector *connector)
set Connector
void InPortCorbaCdrProviderInit(void)
Module initialization.
#define RTC_TRACE(fmt)
prop
Organization::get_organization_property ();.
void setInterfaceType(const char *interface_type)
Set the interface type.
::OpenRTM::InPortCdr_var m_objref
virtual bool isLittleEndian()
Whether this connector&#39;s endian is little.
void Destructor(AbstractClass *&obj)
Destructor template.
Class represents a set of properties.
Definition: Properties.h:101
virtual void setBuffer(BufferBase< cdrMemoryStream > *buffer)
Setting outside buffer&#39;s pointer.
virtual void init(coil::Properties &prop)
Initializing configuration.
void onReceived(const cdrMemoryStream &data)
Notify an ON_RECEIVED event to listeners.
void push_back(CorbaSequence &seq, SequenceElement elem)
Push the new element back to the CORBA sequence.
::OpenRTM::PortStatus convertReturn(BufferStatus::Enum status, const cdrMemoryStream &data)
Return codes conversion.
void onBufferFull(const cdrMemoryStream &data)
Notify an ON_BUFFER_FULL event to listeners.
virtual ReturnCode write(const DataType &value, long int sec=-1, long int nsec=-1)=0
Write data into the buffer.
BufferBase abstract class.
Definition: BufferBase.h:104
virtual ::OpenRTM::PortStatus put(const ::OpenRTM::CdrData &data)
[CORBA interface] Write data into the buffer


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Jun 10 2019 14:07:52