Orocos Real-Time Toolkit  2.8.3
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members

The Interface of a TaskContext which exposes its data-flow ports. More...

#include <rtt/DataFlowInterface.hpp>

Inheritance diagram for RTT::DataFlowInterface:
RTT::Service RTT::internal::GlobalService RTT::marsh::MarshallingService RTT::scripting::ProgramService RTT::scripting::ScriptingService RTT::scripting::StateMachineService

Public Types

typedef std::vector< base::PortInterface * > Ports
 A sequence of pointers to ports. More...
 
typedef std::vector< std::string > PortNames
 A sequence of names of ports. More...
 
typedef boost::function< void(base::PortInterface *)> SlotFunction
 

Public Member Functions

 DataFlowInterface (Service *parent=0)
 Construct the DataFlow interface of a Service. More...
 
 ~DataFlowInterface ()
 
base::PortInterfaceaddPort (const std::string &name, base::PortInterface &port)
 Name and add a Port to the interface of this task and add a Service with the same name of the port. More...
 
base::PortInterfaceaddPort (base::PortInterface &port)
 Add a Port to the interface of this task and add a Service with the same name of the port. More...
 
base::InputPortInterfaceaddEventPort (const std::string &name, base::InputPortInterface &port, SlotFunction callback=SlotFunction())
 Name and add an Event triggering Port to the interface of this task and add a Service with the same name of the port. More...
 
base::InputPortInterfaceaddEventPort (base::InputPortInterface &port, SlotFunction callback=SlotFunction())
 Add an Event triggering Port to the interface of this task and add a Service with the same name of the port. More...
 
void removePort (const std::string &name)
 Remove a Port from this interface. More...
 
Ports getPorts () const
 Get all ports of this interface. More...
 
PortNames getPortNames () const
 Get all port names of this interface. More...
 
base::PortInterfacegetPort (const std::string &name) const
 Get an added port. More...
 
std::string getPortDescription (const std::string &name) const
 Get the description of an added Port. More...
 
bool setPortDescription (const std::string &name, const std::string description)
 Sets the description for the service of an added port. More...
 
TaskContextgetOwner () const
 Returns the component this interface belongs to. More...
 
ServicegetService () const
 Returns the service this interface belongs to. More...
 
base::PortInterfaceaddLocalPort (base::PortInterface &port)
 Add a Port to this task without registering a service for it. More...
 
base::InputPortInterfaceaddLocalEventPort (base::InputPortInterface &port, SlotFunction callback=SlotFunction())
 Add an Event triggering Port to this task without registering a service for it. More...
 
void removeLocalPort (const std::string &name)
 Remove a locally added Port from this interface. More...
 
template<class Type >
Type * getPortType (const std::string &name)
 Get a port of a specific type. More...
 
void clear ()
 Remove all added ports from this interface and all associated TaskObjects. More...
 
void dataOnPort (base::PortInterface *port)
 Used by the input ports to notify this class of new data. More...
 

Protected Member Functions

ServicecreatePortObject (const std::string &name)
 Create a Service through which one can access a Port. More...
 
bool chkPtr (const std::string &where, const std::string &name, const void *ptr)
 

Protected Attributes

Ports mports
 All our ports. More...
 
Servicemservice
 The parent Service. More...
 

Detailed Description

The Interface of a TaskContext which exposes its data-flow ports.

Definition at line 59 of file DataFlowInterface.hpp.

Member Typedef Documentation

typedef std::vector<std::string> RTT::DataFlowInterface::PortNames

A sequence of names of ports.

Definition at line 70 of file DataFlowInterface.hpp.

A sequence of pointers to ports.

Definition at line 65 of file DataFlowInterface.hpp.

Definition at line 72 of file DataFlowInterface.hpp.

Constructor & Destructor Documentation

RTT::DataFlowInterface::DataFlowInterface ( Service parent = 0)

Construct the DataFlow interface of a Service.

Parameters
parentIf not null, a Service will be added to parent for each port added to this interface.

Definition at line 48 of file DataFlowInterface.cpp.

RTT::DataFlowInterface::~DataFlowInterface ( )

Definition at line 52 of file DataFlowInterface.cpp.

Member Function Documentation

base::InputPortInterface& RTT::DataFlowInterface::addEventPort ( const std::string &  name,
base::InputPortInterface port,
SlotFunction  callback = SlotFunction() 
)
inline

Name and add an Event triggering Port to the interface of this task and add a Service with the same name of the port.

Parameters
nameThe name to give to the port.
portThe port to add.
callback(Optional) provide a function which will be called asynchronously when new data arrives on this port. You can add more functions by using the port directly using base::PortInterface::getNewDataOnPort().

Definition at line 114 of file DataFlowInterface.hpp.

References RTT::base::PortInterface::setName().

InputPortInterface & RTT::DataFlowInterface::addEventPort ( base::InputPortInterface port,
SlotFunction  callback = SlotFunction() 
)

Add an Event triggering Port to the interface of this task and add a Service with the same name of the port.

When data arrives on this port your TaskContext will be woken up and updateHook will be executed.

Parameters
portThe port to add.
callback(Optional) provide a function which will be called when new data arrives on this port. The callback function will be called in sequence with updateHook(), so asynchronously with regard to the arrival of data on the port.
Returns
port

Definition at line 97 of file DataFlowInterface.cpp.

References addLocalEventPort(), RTT::Service::addService(), chkPtr(), RTT::Handle::connect(), createPortObject(), RTT::Handle::disconnect(), RTT::base::PortInterface::getName(), RTT::Service::hasService(), mservice, RTT::Service::provides(), RTT::Service::removeService(), and RTT::Warning.

InputPortInterface & RTT::DataFlowInterface::addLocalEventPort ( base::InputPortInterface port,
SlotFunction  callback = SlotFunction() 
)

Add an Event triggering Port to this task without registering a service for it.

When data arrives on this port your TaskContext will be woken up and updateHook will be executed.

Parameters
portThe port to add.
callback(Optional) provide a function which will be called when new data arrives on this port. The callback function will be called in sequence with updateHook(), so asynchronously with regard to the arrival of data on the port.
Returns
port

Definition at line 135 of file DataFlowInterface.cpp.

References addLocalPort(), RTT::Error, RTT::base::PortInterface::getName(), RTT::Service::getName(), RTT::Service::getOwner(), RTT::Info, mservice, and RTT::base::InputPortInterface::signalInterface().

Referenced by addEventPort().

PortInterface & RTT::DataFlowInterface::addLocalPort ( base::PortInterface port)

Add a Port to this task without registering a service for it.

If a port with the same name already exists, addPort will replace it with port and log a warning.

Returns
port

Definition at line 82 of file DataFlowInterface.cpp.

References RTT::base::PortInterface::getName(), mports, removeLocalPort(), RTT::base::PortInterface::setInterface(), and RTT::Warning.

Referenced by addLocalEventPort(), and addPort().

base::PortInterface& RTT::DataFlowInterface::addPort ( const std::string &  name,
base::PortInterface port 
)
inline

Name and add a Port to the interface of this task and add a Service with the same name of the port.

Parameters
nameThe name to give to the port.
portThe port to add.

Definition at line 89 of file DataFlowInterface.hpp.

References RTT::base::PortInterface::setName().

PortInterface & RTT::DataFlowInterface::addPort ( base::PortInterface port)

Add a Port to the interface of this task and add a Service with the same name of the port.

If a port or service with the name already exists, addPort will replace them with port and log a warning.

Parameters
portThe port to add.
Returns
port

Definition at line 59 of file DataFlowInterface.cpp.

References addLocalPort(), RTT::Service::addService(), chkPtr(), createPortObject(), RTT::base::PortInterface::getName(), RTT::Service::hasService(), mservice, RTT::Service::provides(), RTT::Service::removeService(), and RTT::Warning.

bool RTT::DataFlowInterface::chkPtr ( const std::string &  where,
const std::string &  name,
const void *  ptr 
)
protected

Definition at line 263 of file DataFlowInterface.cpp.

References RTT::Error.

Referenced by addEventPort(), and addPort().

void RTT::DataFlowInterface::clear ( )

Remove all added ports from this interface and all associated TaskObjects.

Definition at line 251 of file DataFlowInterface.cpp.

References mports, mservice, and RTT::Service::removeService().

Service * RTT::DataFlowInterface::createPortObject ( const std::string &  name)
protected

Create a Service through which one can access a Port.

Parameters
nameThe port name

Definition at line 236 of file DataFlowInterface.cpp.

References RTT::base::PortInterface::createPortObject(), RTT::Service::doc(), getPort(), and getPortDescription().

Referenced by addEventPort(), and addPort().

void RTT::DataFlowInterface::dataOnPort ( base::PortInterface port)

Used by the input ports to notify this class of new data.

Definition at line 128 of file DataFlowInterface.cpp.

References RTT::Service::getOwner(), and mservice.

TaskContext * RTT::DataFlowInterface::getOwner ( ) const

Returns the component this interface belongs to.

Definition at line 55 of file DataFlowInterface.cpp.

References RTT::Service::getOwner(), and mservice.

Referenced by RTT::base::PortInterface::createPortObject(), RTT::corba::CorbaDispatcher::Instance(), and RTT::mqueue::MQSendRecv::setupStream().

PortInterface * RTT::DataFlowInterface::getPort ( const std::string &  name) const

Get an added port.

Parameters
nameThe port name
Returns
a pointer to a port or null if it does not exist.

Definition at line 209 of file DataFlowInterface.cpp.

References mports.

Referenced by RTT::corba::CDataFlowInterface_i::_default_POA(), RTT::TaskContext::connectPorts(), createPortObject(), and RTT::corba::CDataFlowInterface_i::deregisterChannel().

std::string RTT::DataFlowInterface::getPortDescription ( const std::string &  name) const

Get the description of an added Port.

Parameters
nameThe port name
Returns
The description or "" if it does not exist.

Definition at line 218 of file DataFlowInterface.cpp.

References mports.

Referenced by createPortObject().

DataFlowInterface::PortNames RTT::DataFlowInterface::getPortNames ( ) const

Get all port names of this interface.

Returns
A sequence of strings containing the port names.
Deprecated:
by getNames()

Definition at line 200 of file DataFlowInterface.cpp.

References mports.

Referenced by RTT::corba::CDataFlowInterface_i::_default_POA().

DataFlowInterface::Ports RTT::DataFlowInterface::getPorts ( ) const

Get all ports of this interface.

Returns
A sequence of pointers to ports.

Definition at line 196 of file DataFlowInterface.cpp.

References mports.

Referenced by RTT::TaskContext::connectPorts(), and RTT::TaskContext::disconnect().

template<class Type >
Type* RTT::DataFlowInterface::getPortType ( const std::string &  name)
inline

Get a port of a specific type.

Definition at line 239 of file DataFlowInterface.hpp.

Service* RTT::DataFlowInterface::getService ( ) const
inline

Returns the service this interface belongs to.

The returned service is a service living in the component returned by getOwner() or in one of its sub-services.

Definition at line 198 of file DataFlowInterface.hpp.

void RTT::DataFlowInterface::removeLocalPort ( const std::string &  name)

Remove a locally added Port from this interface.

This will remove all connections and callbacks assosiated with this port.

Parameters
portThe port to remove.
Note
this function will not check if a service with the same name as name exists, and will not remove it. So use removePort() in case you want to get rid of the service as well.

Definition at line 184 of file DataFlowInterface.cpp.

References mports.

Referenced by addLocalPort().

void RTT::DataFlowInterface::removePort ( const std::string &  name)

Remove a Port from this interface.

This will remove all services, connections and callbacks assosiated with this port.

Parameters
portThe port to remove.
Note
Since services are refcounted, removePort may effectively delete the this object in case no Service::shared_ptr exists to this DataFlowInterface. In order to prevent such cleanup, create a Service::shared_ptr to this object before calling removePort().

Definition at line 163 of file DataFlowInterface.cpp.

References RTT::Service::getOwner(), RTT::Service::hasService(), mports, mservice, RTT::Service::provides(), and RTT::Service::removeService().

bool RTT::DataFlowInterface::setPortDescription ( const std::string &  name,
const std::string  description 
)

Sets the description for the service of an added port.

It's prefered to use getPort(name)->doc(description) instead of this method, since this function only updates the documentation of the service representing this port, and not the documentation stored in the port.

Parameters
nameThe port name
descriptionThe new description for this port's service
Returns
true if the port was found and the description was set, false otherwise.

Definition at line 227 of file DataFlowInterface.cpp.

References RTT::Service::getService(), and mservice.

Referenced by RTT::base::PortInterface::doc().

Member Data Documentation

Ports RTT::DataFlowInterface::mports
protected
Service* RTT::DataFlowInterface::mservice
protected

The parent Service.

May be null in exceptional cases.

Definition at line 279 of file DataFlowInterface.hpp.

Referenced by addEventPort(), addLocalEventPort(), addPort(), clear(), dataOnPort(), getOwner(), removePort(), RTT::Service::Service(), and setPortDescription().


The documentation for this class was generated from the following files: