OutPortPullConnector.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
21 #include <rtm/OutPortProvider.h>
22 
23 namespace RTC
24 {
34  ConnectorListeners& listeners,
35  CdrBufferBase* buffer)
36  : OutPortConnector(info),
37  m_provider(provider),
38  m_listeners(listeners),
39  m_buffer(buffer)
40  {
41  // create buffer
42  if (m_buffer == 0)
43  {
44  m_buffer = createBuffer(info);
45  }
46 
47  if (m_provider == 0 || m_buffer == 0) { throw std::bad_alloc(); }
48 
49  m_buffer->init(info.properties.getNode("buffer"));
51  m_provider->setConnector(this);
52  // m_provider->init(m_profile /* , m_listeners */);
54 
55  onConnect();
56  }
57 
66  {
67  onDisconnect();
68  disconnect();
69  }
70 
79  OutPortPullConnector::write(const cdrMemoryStream& data)
80  {
81  m_buffer->write(data);
82  return PORT_OK;
83  }
84 
93  {
94  RTC_TRACE(("disconnect()"));
95  // delete provider
96  if (m_provider != 0)
97  {
99  cfactory.deleteObject(m_provider);
100  }
101  m_provider = 0;
102 
103  // delete buffer
104  if (m_buffer != 0)
105  {
107  bfactory.deleteObject(m_buffer);
108  }
109  m_buffer = 0;
110 
111  return PORT_OK;
112  }
113 
128  {
129  return m_buffer;
130  }
131 
140  {
141  std::string buf_type;
142  buf_type = info.properties.getProperty("buffer_type",
143  "ring_buffer");
144  return CdrBufferFactory::instance().createObject(buf_type);
145  }
146 
155  {
157  }
158 
167  {
169  }
170 };
171 
ConnectorListeners class.
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.
CdrBufferBase * m_buffer
the pointer to the buffer
virtual void setConnector(OutPortConnector *connector)=0
set Connector
CdrBufferBase * createBuffer(ConnectorInfo &info)
create buffer
virtual ReturnCode disconnect()
disconnect
ConnectorInfo m_profile
PortProfile of the Port.
static GlobalFactory< AbstractClass, Identifier, Compare, Creator, Destructor > & instance()
Create instance.
Definition: Singleton.h:131
GlobalFactory template class.
virtual void setListener(ConnectorInfo &info, ConnectorListeners *listeners)=0
Set the listener.
virtual ~OutPortPullConnector()
Destructor.
OutPortProvider * m_provider
the pointer to the OutPortProvider
#define RTC_TRACE(fmt)
virtual CdrBufferBase * getBuffer()
Getting Buffer.
void deleteObject(const Identifier &id, AbstractClass *&obj)
Delete factory object.
OutPortProvider class.
DATAPORTSTATUS_ENUM OutPortPullConnector(ConnectorInfo info, OutPortProvider *provider, ConnectorListeners &listeners, CdrBufferBase *buffer=0)
Constructor.
::RTC::BufferStatus::Enum ReturnCode
void onDisconnect()
Invoke callback when connection is destroied.
OutPortPull type connector class.
Properties & getNode(const std::string &key)
Get node of properties.
Definition: Properties.cpp:455
virtual ReturnCode write(const DataType &value, long int sec=-1, long int nsec=-1)=0
Write data into the buffer.
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
virtual ReturnCode write(const cdrMemoryStream &data)
Writing data.
virtual void setBuffer(CdrBufferBase *buffer)=0
Setting outside buffer&#39;s pointer.
void onConnect()
Invoke callback when connection is established.
const std::string & getProperty(const std::string &key) const
Search for the property with the specified key in this property.
Definition: Properties.cpp:156


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