OpenRTM-aist
1.2.1
|
ConnectorDataListener class. More...
#include <ConnectorListener.h>
Public Member Functions | |
virtual | ~ConnectorDataListener () |
Destructor. More... | |
virtual ReturnCode | operator() (ConnectorInfo &info, cdrMemoryStream &data)=0 |
Virtual Callback method. More... | |
Static Public Member Functions | |
static const char * | toString (ConnectorDataListenerType type) |
Convert ConnectorDataListenerType into the string. More... | |
Public Attributes | |
USE_CONNLISTENER_STATUS | |
Additional Inherited Members | |
Public Types inherited from RTC::ConnectorListenerStatus | |
enum | Enum { NO_CHANGE = 0, INFO_CHANGED = 1 << 0, DATA_CHANGED = 1 << 1, BOTH_CHANGED = INFO_CHANGED | DATA_CHANGED } |
ConnectorDataListener class.
This class is abstract base class for listener classes that realize callbacks for various events in the data port's connectors.
Callbacks can be hooked to the various kind of events which occur throgh OutPort side data write action to InPort side data-read action. Two types listener classes exist. One is ConnectorDataListener which receives valid data-port's data value at that time such as buffer-full event, data-send event, and so on. Other is ConnectorListener which does not receive any data such as buffer-empty event, buffer-read-timeout event and so on.
If you want to hook actions which related data-port's data by ConnectorDataListener, a class which inherits this class should be defined, and the functor should receive a connector information and a data value as arguments. And then, the defined class must be set to data-port object through its member function, as follows. Two types of ConnectorDataListeners are available. One is "ConnectorDataListener" which receives marshalled data as data value, the other is "ConnectorDataListenerT" which receives unmarshalled data as data value. The following example is the use of ConnectorDataListenerT.
class MyDataListener : public ConnectorDataListenerT<RTC::TimedLong> { public: MyDataListener(const char* name) : m_name(name) {} virtual ~MyDataListener() {} virtual ReturnCode operator()(ConnectorInfo& info, TimedLong& data) { std::cout << "Data Listener: " << m_name << std::endl; std::cout << "Data: " << data.data << std::endl; std::cout << "Profile::name: " << info.name << std::endl; std::cout << "Profile::id: " << info.id << std::endl; std::cout << "Profile::properties: " << std::endl; std::cout << info.properties; }; std::string m_name; };
The listener class defained as above can be attached to a data-port as follows.
RTC::ReturnCode_t ConsoleIn::onInitialize() { m_outOut. addConnectorDataListener(ON_BUFFER_WRITE, new MyDataListener("ON_BUFFER_WRITE")); :
The first argument "ON_BUFFER_WRITE" specifies hook point of callback, and the following values are available. Data-port can be specified some properties such as interface-type, dataflow-type, subscription type and so on. Available hook points vary by the those settings. The following hook points are available when interface type is CORBA CDR type.
|
virtual |
Destructor.
|
pure virtual |
Virtual Callback method.
This is a the Callback method to various events generated in Connector.
Implemented in RTC::ConnectorDataListenerT< DataType >.
|
inlinestatic |
Convert ConnectorDataListenerType into the string.
Convert ConnectorDataListenerType into the string.
type | The target ConnectorDataListenerType for transformation |
References RTC::CONNECTOR_DATA_LISTENER_NUM.
RTC::ConnectorDataListener::USE_CONNLISTENER_STATUS |