DataPort Class Template Reference
[Data Transfer PortsTask Context Interface]

#include <rtt/DataPort.hpp>

Inheritance diagram for DataPort:

Inheritance graph
[legend]
List of all members.

Detailed Description

template<class T>
class RTT::DataPort< T >

A data port which can be used as a reader and as a writer.


Public Types

typedef T DataType
enum  PortType { ReadPort, WritePort, ReadWritePort }
 This enum classifies if a port is inbound outbound or both.

Public Member Functions

 DataPort (const std::string &name, const DataType &initial_value=DataType())
 Construct an unconnected Port to a writable DataObject.
DataPortoperator= (DataObjectInterface< T > *impl)
 Provide a new implementation for the connection of this port.
void Set (const DataType &data)
 Write data to the connection of this port.
DataType Get () const
 Get the current value of this Port.
void Get (DataType &result) const
 Get the current value of this Port.
virtual PortInterface::PortType getPortType () const
 Get the PortType of this port.
bool connect (typename DataConnectionInterface< T >::shared_ptr conn)
 Connect a readable data object connection to this Port.
virtual ConnectionInterface::shared_ptr connection () const
 Returns the connection in which this Port currently participates.
bool connected () const
 Inspect if this Port is currently connected with another Port.
bool connectTo (ConnectionInterface::shared_ptr other)
 Connect this port to a Connection.
void disconnect ()
 No longer participate in a connection.
DataObjectInterface< T > * data ()
 Get the data object to write to.
const DataObjectInterface<
T > * 
data () const
 Get the data object to read from.
virtual PortInterfaceclone () const
 Create a clone of this port with the same name.
virtual PortInterfaceantiClone () const
 Create the anti-clone (inverse port) of this port with the same name A port for reading will return a new port for writing and vice versa.
virtual TaskObjectcreatePortObject ()
 Create accessor Object for this Port, for addition to a TaskContext Object interface.
ConnectionInterface::shared_ptr createConnection (PortInterface *other, ConnectionTypes::ConnectionType con_type=ConnectionTypes::lockfree)
 Create a connection object from this port to another port.
ConnectionInterface::shared_ptr createConnection (ConnectionTypes::ConnectionType con_type)
 Create a new connection object to which this port is subscribed.
virtual bool connectTo (PortInterface *other)
 Connect to another Port and create a new connection if necessary.
const std::string & getName () const
 Get the name of this Port.
bool setName (const std::string &name)
 Change the name of this unconnected Port.
bool ready () const
 Returns true if this Port is ready to be used.

Protected Attributes

DataConnectionInterface< T
>::shared_ptr 
mconn
 The connection to read from.
std::string portname
DataConnectionInterface< T
>::shared_ptr 
mconn
 The connection to write to.
DataType minitial_value


Constructor & Destructor Documentation

DataPort ( const std::string &  name,
const DataType &  initial_value = DataType() 
) [inline]

Construct an unconnected Port to a writable DataObject.

Parameters:
name The name of this port.
initial_value The initial value of this port's connection when the connection is created. If this port is connected to an existing connection, this value is ignored.


Member Function Documentation

DataPort< T > & operator= ( DataObjectInterface< T > *  impl  ) 

Provide a new implementation for the connection of this port.

If this port is not connected, a new connection is created.

Reimplemented from ReadDataPort.

void Set ( const DataType &  data  )  [inline]

Write data to the connection of this port.

If the port is not connected, this methods sets the initial value of the connection to data.

Parameters:
data The data to write to this port.

Reimplemented from WriteDataPort.

DataType Get (  )  const [inline]

Get the current value of this Port.

If the port is not connected, a default value is returned.

Return values:
this->data()->Get() if this->connected()
initial_value if !this->connected()

Reimplemented from ReadDataPort.

void Get ( DataType &  result  )  const [inline]

Get the current value of this Port.

If the port is not connected, a default value is returned.

Parameters:
result The variable to store the result in.
Postcondition:
this->data()->Get(result) if this->connected()

result == initial_value if !this->connected()

Reimplemented from ReadDataPort.

virtual ConnectionInterface::shared_ptr connection (  )  const [inline, virtual]

Returns the connection in which this Port currently participates.

It is possible that this port is part of a dormant connection, ( the connection object is not in the connected() state), in that case this method will return null, until the dormant connection becomes connected().

Return values:
null if not connected to another Port.

Reimplemented from ReadDataPort.

bool connectTo ( ConnectionInterface::shared_ptr  other  )  [inline, virtual]

Connect this port to a Connection.

If the connection is in the connected() state, this port will participate in that connection, otherwise, the port will become connected once conn becomes connected().

Returns:
true if connection was possible, false otherwise.

Reimplemented from ReadDataPort.

DataObjectInterface<T>* data (  )  [inline]

Get the data object to write to.

The Task may use this to write to a Data Object connected to this port.

Returns:
0 if !connected(), the data object otherwise.

Reimplemented from WriteDataPort.

const DataObjectInterface<T>* data (  )  const [inline]

Get the data object to read from.

The Task may use this to read from a Data object connection connected to this port.

Returns:
0 if !connected(), the Data Object otherwise.

Reimplemented from ReadDataPort.

virtual bool connectTo ( PortInterface other  )  [virtual, inherited]

Connect to another Port and create a new connection if necessary.

bool setName ( const std::string &  name  )  [inherited]

Change the name of this unconnected Port.

One can only change the name when it is not yet connected.

Return values:
true if !this->connected(), the name has changed.
false if this->connected(), the name has not been changed.

bool ready (  )  const [inherited]

Returns true if this Port is ready to be used.

Identical to connected().


The documentation for this class was generated from the following file:
Generated on Fri May 11 11:19:36 2007 for Orocos by  doxygen 1.5.1