OpenRTM  1.0.0
Public Member Functions | List of all members
RTC::InPort< DataType > Class Template Reference

InPort template class. More...

#include <InPort.h>

Inheritance diagram for RTC::InPort< DataType >:
RTC::InPortBase RTC::PortBase RTC::DataPortStatus

Public Member Functions

DATAPORTSTATUS_ENUM InPort (const char *name, DataType &value, int bufsize=64, bool read_block=false, bool write_block=false, int read_timeout=0, int write_timeout=0)
 A constructor.
virtual ~InPort (void)
 Destructor.
virtual const char * name ()
 Get port name.
virtual bool isNew ()
 Check whether the data is newest.
virtual bool isEmpty ()
 Check whether the data is newest.
bool read ()
 Readout the value from DataPort.
virtual void update ()
 Read the newly value to type-T variable which is bound to InPort's buffer.
void operator>> (DataType &rhs)
 Read the newly value data in InPort to type-T variable.
void setOnRead (OnRead< DataType > *on_read)
 Set callback when data is read from the InPort buffer.
void setOnReadConvert (OnReadConvert< DataType > *on_rconvert)
 Set callback when data is readout to the InPort buffer.
- Public Member Functions inherited from RTC::InPortBase
 InPortBase (const char *name, const char *data_type)
 Constructor.
virtual ~InPortBase (void)
 Destructor.
void init (coil::Properties &prop)
 Initializing properties.
coil::Propertiesproperties ()
 Get properties.
const std::vector
< InPortConnector * > & 
connectors ()
 Connector list.
ConnectorInfoList getConnectorProfiles ()
 ConnectorProfile list.
coil::vstring getConnectorIds ()
 ConnectorId list.
coil::vstring getConnectorNames ()
 Connector name list.
InPortConnectorgetConnectorById (const char *id)
 Getting ConnectorProfile by ID.
InPortConnectorgetConnectorByName (const char *name)
 Getting Connector by name.
bool getConnectorProfileById (const char *id, ConnectorInfo &prof)
 Getting ConnectorProfile by name.
bool getConnectorProfileByName (const char *name, ConnectorInfo &prof)
 Getting ConnectorProfile by name.
virtual void activateInterfaces ()
 Activate all Port interfaces.
virtual void deactivateInterfaces ()
 Deactivate all Port interfaces.
void addConnectorDataListener (ConnectorDataListenerType listener_type, ConnectorDataListener *listener, bool autoclean=true)
 Adding BufferDataListener type listener.
void removeConnectorDataListener (ConnectorDataListenerType listener_type, ConnectorDataListener *listener)
 Removing BufferDataListener type listener.
void addConnectorListener (ConnectorListenerType callback_type, ConnectorListener *listener, bool autoclean=true)
 Adding ConnectorListener type listener.
void removeConnectorListener (ConnectorListenerType callback_type, ConnectorListener *listener)
 Removing BufferDataListener type listener.
bool isLittleEndian ()
 return it whether endian setting.
virtual ReturnCode_t connect (ConnectorProfile &connector_profile) throw (CORBA::SystemException)
 [CORBA interface] Connect the Port
- Public Member Functions inherited from RTC::PortBase
 PortBase (const char *name="")
 Constructor.
virtual ~PortBase (void)
 Destructor.
virtual PortProfile * get_port_profile () throw (CORBA::SystemException)
 [CORBA interface] Get the PortProfile of the Port
const PortProfile & getPortProfile () const
 Get the PortProfile of the Port.
virtual ConnectorProfileList * get_connector_profiles () throw (CORBA::SystemException)
 [CORBA interface] Get the ConnectorProfileList of the Port
virtual ConnectorProfile * get_connector_profile (const char *connector_id) throw (CORBA::SystemException)
 [CORBA interface] Get the ConnectorProfile
virtual ReturnCode_t notify_connect (ConnectorProfile &connector_profile) throw (CORBA::SystemException)
 [CORBA interface] Notify the Ports connection
virtual ReturnCode_t disconnect (const char *connector_id) throw (CORBA::SystemException)
 [CORBA interface] Disconnect the Port
virtual ReturnCode_t notify_disconnect (const char *connector_id) throw (CORBA::SystemException)
 [CORBA interface] Notify the Ports disconnection
virtual ReturnCode_t disconnect_all () throw (CORBA::SystemException)
 [CORBA interface] Disconnect the All Ports
void setName (const char *name)
 Set the name of this Port.
const char * getName () const
 Get the name of this Port.
const PortProfile & getProfile () const
 Get the PortProfile of the Port.
void setPortRef (PortService_ptr port_ref)
 Set the object reference of this Port.
PortService_ptr getPortRef ()
 Get the object reference of this Port.
void setOwner (RTObject_ptr owner)
 Set the owner RTObject of the Port.
void setOnPublishInterfaces (ConnectionCallback *on_publish)
 Setting callback called on publish interfaces.
void setOnSubscribeInterfaces (ConnectionCallback *on_subscribe)
 Setting callback called on publish interfaces.
void setOnConnected (ConnectionCallback *on_connected)
 Setting callback called on connection established.
void setOnUnsubscribeInterfaces (ConnectionCallback *on_subscribe)
 Setting callback called on unsubscribe interfaces.
void setOnDisconnected (ConnectionCallback *on_disconnected)
 Setting callback called on disconnected.
void setOnConnectionLost (ConnectionCallback *on_connection_lost)
 Setting callback called on connection lost.
void setPortConnectListenerHolder (PortConnectListeners *portconnListeners)
 Setting PortConnectListener holder.

Additional Inherited Members

- Public Types inherited from RTC::DataPortStatus
enum  Enum {
  PORT_OK = 0, PORT_ERROR, BUFFER_ERROR, BUFFER_FULL,
  BUFFER_EMPTY, BUFFER_TIMEOUT, SEND_FULL, SEND_TIMEOUT,
  RECV_EMPTY, RECV_TIMEOUT, INVALID_ARGS, PRECONDITION_NOT_MET,
  CONNECTION_LOST, UNKNOWN_ERROR
}
 DataPortStatus return codes. More...
- Static Public Member Functions inherited from RTC::DataPortStatus
static const char * toString (DataPortStatus::Enum status)
 Convert DataPortStatus into the string.
- Public Attributes inherited from RTC::InPortBase
DATAPORTSTATUS_ENUM typedef
std::vector< InPortConnector * > 
ConnectorList
- Protected Types inherited from RTC::PortBase
typedef coil::Guard< coil::MutexGuard
- Protected Member Functions inherited from RTC::InPortBase
virtual ReturnCode_t publishInterfaces (ConnectorProfile &connector_profile)
 Publish interface information.
virtual ReturnCode_t subscribeInterfaces (const ConnectorProfile &connector_profile)
 Subscribe to the interface.
virtual void unsubscribeInterfaces (const ConnectorProfile &connector_profile)
 Disconnect the interface connection.
void initProviders ()
 InPort provider initialization.
void initConsumers ()
 OutPort consumer initialization.
bool checkEndian (const coil::Properties &prop, bool &littleEndian)
 Checking endian flag of serializer.
InPortProvidercreateProvider (ConnectorProfile &cprof, coil::Properties &prop)
 InPort provider creation.
OutPortConsumercreateConsumer (const ConnectorProfile &cprof, coil::Properties &prop)
 InPort provider creation.
InPortConnectorcreateConnector (ConnectorProfile &cprof, coil::Properties &prop, InPortProvider *provider)
 InPortPushConnector creation.
InPortConnectorcreateConnector (const ConnectorProfile &cprof, coil::Properties &prop, OutPortConsumer *consumer)
 InPortPullConnector creation.
- Protected Attributes inherited from RTC::InPortBase
bool m_singlebuffer
 Buffer mode.
CdrBufferBasem_thebuffer
 Buffer.
coil::Properties m_properties
 Properties.
coil::vstring m_providerTypes
 Available providers.
coil::vstring m_consumerTypes
 Available consumers.
ConnectorList m_connectors
 Connection list.
bool m_littleEndian
 Connected Endian.
ConnectorListeners m_listeners
 ConnectorDataListener listener.

Detailed Description

template<class DataType>
class RTC::InPort< DataType >

InPort template class.

This is a template class that implements InPort. <T> is the type defined in BasicDataType.idl and must be the structure which has both Time type tm and type-T data as a member. InPort has a ring buffer internally, and stores the received data externally in this buffer one by one. The size of ring buffer can be specified according to the argument of constructor, though the default size is 64. Unread data and data which is already read are managed with the flag, and the data can be handled by the isNew(), write(), read(), isFull() and isEmpty() method etc.

Since
0.2.0

Constructor & Destructor Documentation

template<class DataType >
DATAPORTSTATUS_ENUM RTC::InPort< DataType >::InPort ( const char *  name,
DataType &  value,
int  bufsize = 64,
bool  read_block = false,
bool  write_block = false,
int  read_timeout = 0,
int  write_timeout = 0 
)
inline

A constructor.

constructor. This is bound to type-T variable given as a parameter.

Parameters
nameA name of the InPort. This name is referred by InPortBase::name().
valuetype-T variable that is bound to this InPort.
bufsizeBuffer length of internal ring buffer of InPort (The default value:64)
read_blockFlag of reading block. When there are not unread data at reading data, set whether to block data until receiving the next data. (The default value:false)
write_blockFlag of writing block. If the buffer was full at writing data, set whether to block data until the buffer has space. (The default value:false)
read_timeoutData reading timeout time (millisecond) when not specifying read blocking. (The default value:0)
write_timeoutData writing timeout time (millisecond) when not specifying writing block. (The default value:0)
template<class DataType >
virtual RTC::InPort< DataType >::~InPort ( void  )
inlinevirtual

Destructor.

Destructor

Member Function Documentation

template<class DataType >
virtual bool RTC::InPort< DataType >::isEmpty ( void  )
inlinevirtual

Check whether the data is newest.

Check whether the data stored at a current buffer position is newest.

Returns
Newest data check result ( true:Newest data. Data has not been readout yet. false:Past data.Data has already been readout.)

References RTC::InPortBase::m_connectors, RTC::PortBase::m_connectorsMutex, RTC_DEBUG, and RTC_TRACE.

template<class DataType >
virtual bool RTC::InPort< DataType >::isNew ( )
inlinevirtual

Check whether the data is newest.

Check whether the data stored at a current buffer position is newest.

Returns
Newest data check result ( true:Newest data. Data has not been readout yet. false:Past data.Data has already been readout.)

References RTC::InPortBase::m_connectors, RTC::PortBase::m_connectorsMutex, RTC_DEBUG, and RTC_TRACE.

template<class DataType >
virtual const char* RTC::InPort< DataType >::name ( )
inlinevirtual

Get port name.

Get port name.

Returns
The port name
template<class DataType >
void RTC::InPort< DataType >::operator>> ( DataType &  rhs)
inline

Read the newly value data in InPort to type-T variable.

Read the newly data set in InPort and set to specified data variable.

Parameters
rhsThe type-T variable to read from InPort's buffer

References RTC::InPort< DataType >::read().

template<class DataType >
bool RTC::InPort< DataType >::read ( )
inlinevirtual

Readout the value from DataPort.

Readout the value from DataPort

  • When Callback functor OnRead is already set, OnRead will be invoked before reading from the buffer held by DataPort.
  • When the buffer held by DataPort can detect the underflow, and when it detected the underflow at reading, callback functor OnUnderflow will be invoked.
  • When callback functor OnReadConvert is already set, the return value of operator() of OnReadConvert will be the return value of read().
  • When timeout of reading is already set by setReadTimeout(), it waits for only timeout time until the state of the buffer underflow is reset, and if OnUnderflow is already set, this will be invoked to return.
Returns
Readout result (Successful:true, Failed:false)

Implements RTC::InPortBase.

References RTC::DataPortStatus::BUFFER_EMPTY, RTC::DataPortStatus::BUFFER_TIMEOUT, RTC::InPortBase::m_connectors, RTC::PortBase::m_connectorsMutex, RTC::DataPortStatus::PORT_OK, RTC_DEBUG, RTC_ERROR, RTC_TRACE, and RTC_WARN.

Referenced by RTC::InPort< DataType >::operator>>(), and RTC::InPort< DataType >::update().

template<class DataType >
void RTC::InPort< DataType >::setOnRead ( OnRead< DataType > *  on_read)
inline

Set callback when data is read from the InPort buffer.

Set the callback object that is invoked right before data is read from the InPort's buffer

Parameters
on_readOnRead<DataType> type object
template<class DataType >
void RTC::InPort< DataType >::setOnReadConvert ( OnReadConvert< DataType > *  on_rconvert)
inline

Set callback when data is readout to the InPort buffer.

Set the callback object that is invoked when data is readout to the InPort's buffer. The return value of callback object is the return result of the read() method.

Parameters
on_rconvertOnReadConvert<DataType> type object
template<class DataType >
virtual void RTC::InPort< DataType >::update ( void  )
inlinevirtual

Read the newly value to type-T variable which is bound to InPort's buffer.

Read the newly value to type-T data which is bound to InPort's buffer. The type-T variable must be bound to InPort in constructor. Since this method assumes to be used for polymorphic, its argument and the return value do not depend on type.

References RTC::InPort< DataType >::read().