ConnectionInterface Class Reference

#include <rtt/ConnectionInterface.hpp>

Inheritance diagram for ConnectionInterface:

BufferConnection DataConnection

List of all members.


Detailed Description

An Object which manages and maintains a communication connection between Ports.

Creating a Connection
When connections are created, they are initially not connected, and hence, no port 'knows' of this connection object. In order to establish the connection between ports, call connect() explicitly on the newly created connection object. As long as that does not happen, it only keeps track of readers and writers, but does not connect them.
Connection Management
A connection object has two states: connected() or !connected(). In both states, any number of readers and writers may subscribe to this connection. If the state is !connected(), all subscribers will only be connected when the connect() method is called. If the state is connected(), every newly added subscriber is directly connected to the connection.
It is possible that a PortInterface participates in multiple 'dormant' (ie !connected()) connections while only one connection is connected() at the same time. If one tries to connect() a connection in which one ore more subscribers are already participating in the connection, the connect() method fails.

Reference counting
ConnectionInterface objects are reference counted. That means that if no object holds a pointer to this object, it will be destroyed. This can only happen if all ports disconnect from this connection.
Thread Safety
Although this interface may be implemented thread-safe, the DataConnection and BufferConnection classes have not been made thread-safe. This means that multiple threads calling connect()/disconnect() on the same or related connections may crash the system. Since connection setup is seen as an application configuration step, executed by a single configurator, Locking was not added. If this policy does not match your application setup, write your own ConnectionInterface subclass, or submit a bug report.
See also:
PortInterface

Definition at line 101 of file ConnectionInterface.hpp.


Public Types

typedef boost::intrusive_ptr
< ConnectionInterface
shared_ptr

Public Member Functions

virtual DataSourceBase::shared_ptr getDataSource () const =0
 Get a Data source representing the current value of this connection.
virtual BufferBase::shared_ptr getBuffer () const =0
 Returns the buffer and its associated status of this connection, if this connection is buffered.
virtual bool connect ()
 Connect all readers and writers.
virtual bool connected () const
 Get Connection status.
virtual bool disconnect ()
 Disconnect all readers and writers.
virtual bool addPort (PortInterface *p)
 Add a Port to the connection.
virtual bool removePort (PortInterface *p)
 Remove a Port from the connection.
virtual const TypeInfogetTypeInfo () const =0
 Get the data type of this port.
virtual int serverProtocol () const
 Returns the protocol over which this connection can be accessed.

Protected Types

typedef std::vector
< PortInterface * > 
PList

Protected Member Functions

friend void::intrusive_ptr_add_ref (ConnectionInterface *p)
friend void::intrusive_ptr_release (ConnectionInterface *p)

Protected Attributes

oro_atomic_t refcount
PList ports
bool mconnected

Member Function Documentation

virtual DataSourceBase::shared_ptr getDataSource (  )  const [pure virtual]

Get a Data source representing the current value of this connection.

This function always returns a meaningful data source.

Implemented in BufferConnection, and DataConnection.

virtual BufferBase::shared_ptr getBuffer (  )  const [pure virtual]

Returns the buffer and its associated status of this connection, if this connection is buffered.

Otherwise, this returns the null pointer.

Implemented in BufferConnection, and DataConnection.

bool connect (  )  [virtual]

Connect all readers and writers.

If a reader or writer is already connected to another connection, this method fails.

Returns:
false if at least one reader or writer was already participating in a connection or if connected()

Definition at line 59 of file ConnectionInterface.cpp.

bool addPort ( PortInterface p  )  [virtual]

Add a Port to the connection.

If this->connected(), also immediately connect p to this connection.

Parameters:
p A port which wants to read or write data from this connection.
Returns:
true if p has the correct type and could be added

Definition at line 89 of file ConnectionInterface.cpp.

References PortInterface::connect(), and ConnectionInterface::connected().

bool removePort ( PortInterface p  )  [virtual]

Remove a Port from the connection.

If this->connected(), also immediately disconnect p from this connection.

Parameters:
p A port which no longer wants to read or write data from this connection.
Returns:
true if p was present.

Definition at line 97 of file ConnectionInterface.cpp.


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

Generated on Mon Jan 19 16:53:57 2009 for OrocosReal-TimeToolkit by  doxygen 1.5.6