RTT::DataPort< T > Class Template Reference
[Data Transfer PortsTask Context Interface]

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

#include <rtt/DataPort.hpp>

Inherits RTT::DataPortBase< T >.

List of all members.

Public Types

typedef T DataType
enum  PortType { ReadPort, WritePort, ReadWritePort }
 

This enum classifies if a port is inbound outbound or both.


enum  ConnectionModel { Buffered, Data }
 

This enum classifies the kind of data connections that are available through ports: buffered or data.


typedef Event< void(PortInterface *) NewDataOnPortEvent )

Public Member Functions

 DataPort (const std::string &name, const DataType &initial_value=DataType())
 Construct an unconnected Port to a writable DataObject.
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)
 Get the current value of this Port.
virtual PortInterface::PortType getPortType () const
 Get the PortType of this port.
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 (ConnectionTypes::ConnectionType con_type)
 Create a new connection object to which this port is subscribed.
ConnectionInterface::shared_ptr createConnection (DataSourceBase::shared_ptr data)
virtual
ConnectionInterface::shared_ptr 
createConnection (BufferBase::shared_ptr buf)
 Create a new connection object using a buffered connection implementation.
virtual ConnectionModel getConnectionModel () const
virtual const TypeInfogetTypeInfo () const
bool connect (ConnectionInterface::shared_ptr conn)
virtual
ConnectionInterface::shared_ptr 
connection () const
bool connected () const
bool connectTo (ConnectionInterface::shared_ptr other)
virtual bool connectTo (PortInterface *other)
 Connect to another Port and create a new connection if necessary.
void disconnect ()
const DataObjectInterface< T > * data () const
 Get the data object to read from.
DataObjectInterface< T > * data ()
 Get the data object to write to.
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.
void signal ()
 Call this method to signal that new data is available on this port.
NewDataOnPortEvent * getNewDataOnPortEvent ()
 Returns an Event object which is triggered every time new data is made available on this port.
virtual int serverProtocol () const
 Returns the protocol over which this port can be accessed.

Protected Attributes

minitial_value
DataConnection< T >::shared_ptr mconn
 The connection to read from.
std::string portname
NewDataOnPortEvent * new_data_on_port_event

Friends

class ConnectionInterface

Detailed Description

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

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

Definition at line 300 of file DataPort.hpp.


Constructor & Destructor Documentation

template<class T>
RTT::DataPort< T >::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.

Definition at line 316 of file DataPort.hpp.


Member Function Documentation

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

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

  • If this port is already connected, this method returns false.
  • If the other port has a connection, this method is equivalent to 'this->connectTo( other->connection() )'.
  • If the other port is not connected, a new connection is created and both ports are connected.
    Returns:
    true upon success, false otherwise.

Referenced by RTT::ReadBufferPort< T >::antiClone().

virtual ConnectionInterface::shared_ptr RTT::PortInterface::createConnection ( BufferBase::shared_ptr  buf  )  [virtual, inherited]

Create a new connection object using a buffered connection implementation.

Returns:
null if this->connected() or this->getConnectionModel() != Buffered else a valid connection object is returned.

Reimplemented in RTT::Corba::CorbaPort.

template<class T >
DataObjectInterface<T>* RTT::DataPortBase< T >::data (  )  [inline, inherited]

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.

Definition at line 115 of file DataPort.hpp.

template<class T >
const DataObjectInterface<T>* RTT::DataPortBase< T >::data (  )  const [inline, inherited]

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.

Definition at line 108 of file DataPort.hpp.

template<class T>
void RTT::DataPort< T >::Get ( DataType &  result  )  [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()

Definition at line 372 of file DataPort.hpp.

template<class T>
DataType RTT::DataPort< T >::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()

Definition at line 350 of file DataPort.hpp.

template<class T>
void RTT::DataPort< T >::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.

Definition at line 326 of file DataPort.hpp.

bool RTT::PortInterface::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.

The documentation for this class was generated from the following file:
Generated on Thu Dec 23 13:22:41 2010 for Orocos Real-Time Toolkit by  doxygen 1.6.3