InPortPullConnector.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
21 #include <rtm/OutPortConsumer.h>
22 #include <rtm/ConnectorListener.h>
23 
24 namespace RTC
25 {
34  OutPortConsumer* consumer,
35  ConnectorListeners& listeners,
36  CdrBufferBase* buffer)
37  : InPortConnector(info, buffer), m_consumer(consumer),
38  m_listeners(listeners)
39  {
40  if (buffer == 0)
41  {
43  }
44  if (m_buffer == 0 || m_consumer == 0)
45  {
46  throw std::bad_alloc();
47  return;
48  }
49  m_buffer->init(info.properties.getNode("buffer"));
52 
53  onConnect();
54  }
55 
64  {
65  onDisconnect();
66  disconnect();
67  }
68 
77  InPortPullConnector::read(cdrMemoryStream& data)
78  {
79  RTC_TRACE(("InPortPullConnector::read()"));
80  if (m_consumer == 0)
81  {
82  return PORT_ERROR;
83  }
84  return m_consumer->get(data);
85  }
86 
95  {
96  RTC_TRACE(("disconnect()"));
97  // delete consumer
98  if (m_consumer != 0)
99  {
101  cfactory.deleteObject(m_consumer);
102  }
103  m_consumer = 0;
104 
105  return PORT_OK;
106  }
107 
116  {
117  std::string buf_type;
118  buf_type = info.properties.getProperty("buffer_type",
119  "ring_buffer");
120  return CdrBufferFactory::instance().createObject(buf_type);
121  }
122 
131  {
133  }
134 
143  {
145  }
146 };
147 
ConnectorListeners class.
ConnectorInfo m_profile
ConnectorInfo.
coil::Properties properties
Connection properties.
RT-Component.
ConnectorListeners & m_listeners
A reference to a ConnectorListener.
ConnectorListenerHolder connector_[CONNECTOR_LISTENER_NUM]
ConnectorListenerType listener array The ConnectorListenerType listener is stored.
virtual void setBuffer(CdrBufferBase *buffer)=0
Setting outside buffer&#39;s pointer.
OutPortConsumer class.
void onConnect()
Invoke callback when connection is established.
static GlobalFactory< AbstractClass, Identifier, Compare, Creator, Destructor > & instance()
Create instance.
Definition: Singleton.h:131
GlobalFactory template class.
CdrBufferBase * m_buffer
Connector&#39;s buffer.
CdrBufferBase * createBuffer(ConnectorInfo &info)
create buffer
virtual ReturnCode read(cdrMemoryStream &data)
Destructor.
const std::string & getProperty(const std::string &key) const
Search for the property with the specified key in this property.
Definition: Properties.cpp:160
#define RTC_TRACE(fmt)
void deleteObject(const Identifier &id, AbstractClass *&obj)
Delete factory object.
void onDisconnect()
Invoke callback when connection is destroied.
OutPortConsumer * m_consumer
the pointer to the OutPortConsumer
::RTC::BufferStatus::Enum ReturnCode
virtual ReturnCode get(cdrMemoryStream &data)=0
Receive data.
virtual void setListener(ConnectorInfo &info, ConnectorListeners *listeners)=0
Set the listener.
InPortPull type connector class.
OutPortConsumer abstract class.
Properties & getNode(const std::string &key)
Get node of properties.
Definition: Properties.cpp:460
virtual ~InPortPullConnector()
Destructor.
void notify(const ConnectorInfo &info)
Notify listeners.
virtual void init(const coil::Properties &prop)=0
Set the buffer.
BufferBase abstract class.
Definition: BufferBase.h:104
DATAPORTSTATUS_ENUM InPortPullConnector(ConnectorInfo info, OutPortConsumer *consumer, ConnectorListeners &listeners, CdrBufferBase *buffer=0)
Constructor.
connector listener class
virtual ReturnCode disconnect()
Disconnect connection.


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Feb 28 2022 23:00:43