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.
{@code
class MyDataListener extends ConnectorDataListenerT {
public MyDataListener(final String name){
super(TimedLong.class);
m_name = name;
}
public ReturnCode operator(ConnectorBase.ConnectorInfo info, TimedLong data) {
System.out.println("Listener: "+m_name);
System.out.println("Data: "+data.data);
System.out.println("Profile::name: "+info.name);
System.out.println("Profile::id: "+info.id);
System.out.println("Profile::properties: ");
System.out.println(info.properties);
};
public String m_name;
};
}
The listener class defained as above can be attached to a
data-port as follows.
{@code
protected ReturnCode_t onInitialize() {
m_outOut.addConnectorDataListener(
ConnectorDataListenerType.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.
OutPort:
- - Push type: Available hook event varies by subscription type.
- - Flush: No ON_BUFFER* events since flush-type has no buffer.
- - ON_SEND
- - ON_RECEIVED
- - ON_RECEIVER_FULL
- - ON_RECEIVER_TIMEOUT
- - ON_RECEIVER_ERROR
- .
- - New type:
- - ON_BUFFER_WRITE
- - ON_BUFFER_FULL
- - ON_BUFFER_WRITE_TIMEOUT
- - ON_BUFFER_OVERWRITE
- - ON_BUFFER_READ
- - ON_SEND
- - ON_RECEIVED
- - ON_RECEIVER_FULL
- - ON_RECEIVER_TIMEOUT
- - ON_RECEIVER_ERROR
- .
- - Periodic type:
- - ON_BUFFER_WRITE
- - ON_BUFFER_FULL
- - ON_BUFFER_WRITE_TIMEOUT
- - ON_BUFFER_READ
- - ON_SEND
- - ON_RECEIVED
- - ON_RECEIVER_FULL
- - ON_RECEIVER_TIMEOUT
- - ON_RECEIVER_ERROR
- .
- .
.
- - Pull type:
- - ON_BUFFER_WRITE
- - ON_BUFFER_FULL
- - ON_BUFFER_WRITE_TIMEOUT
- - ON_BUFFER_OVERWRITE
- - ON_BUFFER_READ
- - ON_SEND
- .
.
InPort:
- - Push type:
- - ON_BUFFER_WRITE
- - ON_BUFFER_FULL
- - ON_BUFFER_WRITE_TIMEOUT
- - ON_BUFFER_WRITE_OVERWRITE
- - ON_BUFFER_READ
- - ON_BUFFER_READ_TIMEOUT
- - ON_RECEIVED
- - ON_RECEIVER_FULL
- - ON_RECEIVER_TIMEOUT
- - ON_RECEIVER_ERROR
- .
- - Pull type