Orocos Real-Time Toolkit  2.9.0
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
RTT::internal::ConnectionManager Class Reference

Manages connections between ports. More...

#include <rtt/internal/ConnectionManager.hpp>

Public Types

typedef boost::tuple< boost::shared_ptr< ConnID >, base::ChannelElementBase::shared_ptr, ConnPolicyChannelDescriptor
 A connection is described by an opaque ConnID object, the first element of the connection and the policy of the connection. More...
 
typedef std::list< ChannelDescriptorConnections
 

Public Member Functions

 ConnectionManager (base::PortInterface *port)
 Creates a connection manager to manage the connections of port. More...
 
 ~ConnectionManager ()
 
bool addConnection (ConnID *port_id, base::ChannelElementBase::shared_ptr channel, ConnPolicy policy)
 Helper method for port-to-port connection establishment. More...
 
bool removeConnection (ConnID *port_id, bool disconnect=true)
 
bool removeConnection (base::ChannelElementBase *channel, bool disconnect=true)
 
void disconnect ()
 Disconnect all connections. More...
 
bool connected () const
 Returns true if there is at least one connection registered in this port's list of outputs. More...
 
bool connectedTo (base::PortInterface *port)
 Returns true if there exists a connection to the given port. More...
 
bool disconnect (base::PortInterface *port)
 Removes the connection that connects this port to port. More...
 
bool isSingleConnection () const
 Returns true if this manager manages only one connection. More...
 
Connections getConnections () const
 Returns a list of all connections managed by this object. More...
 
internal::SharedConnectionBase::shared_ptr getSharedConnection () const
 Returns a pointer to the shared connection element this port may be connected to. More...
 
void lock () const
 Locks the mutex protecting the channel element list. More...
 
void unlock () const
 Unlocks the mutex protecting the channel element list. More...
 

Protected Member Functions

Connections::iterator eraseConnection (const Connections::iterator &descriptor, bool disconnect)
 Helper method for disconnect() More...
 

Protected Attributes

base::PortInterfacemport
 The port for which we manage connections. More...
 
std::list< ChannelDescriptorconnections
 A list of all our connections. More...
 
internal::SharedConnectionBase::shared_ptr shared_connection
 A pointer to the shared connection this port may be connected to. More...
 
RTT::os::Mutex connection_lock
 Lock that should be taken before the list of connections is accessed or modified. More...
 

Detailed Description

Manages connections between ports.

This class is used for input and output ports in order to manage their connections. TODO: use the mutex lock !!!

Definition at line 78 of file ConnectionManager.hpp.

Member Typedef Documentation

A connection is described by an opaque ConnID object, the first element of the connection and the policy of the connection.

The policy is only given for read-only access, modifying it will not have any effect on the connection.

Definition at line 87 of file ConnectionManager.hpp.

Definition at line 89 of file ConnectionManager.hpp.

Constructor & Destructor Documentation

RTT::internal::ConnectionManager::ConnectionManager ( base::PortInterface port)

Creates a connection manager to manage the connections of port.

Parameters
portThe port whose connections to manage.

Definition at line 62 of file ConnectionManager.cpp.

RTT::internal::ConnectionManager::~ConnectionManager ( )

Definition at line 67 of file ConnectionManager.cpp.

References disconnect().

Member Function Documentation

bool RTT::internal::ConnectionManager::addConnection ( ConnID port_id,
base::ChannelElementBase::shared_ptr  channel,
ConnPolicy  policy 
)

Helper method for port-to-port connection establishment.

This is the last step in adding a connection to an output port and also validates if the connection is sound.

Returns
false if the connection failed to work, true otherwise.

Definition at line 122 of file ConnectionManager.cpp.

References connection_lock, connections, lock(), and shared_connection.

Referenced by RTT::base::OutputPortInterface::addConnection().

bool RTT::internal::ConnectionManager::connected ( ) const

Returns true if there is at least one connection registered in this port's list of outputs.

Definition at line 109 of file ConnectionManager.cpp.

References connections.

Referenced by RTT::base::OutputPortInterface::connected().

bool RTT::internal::ConnectionManager::connectedTo ( base::PortInterface port)

Returns true if there exists a connection to the given port.

Definition at line 112 of file ConnectionManager.cpp.

References connection_lock, connections, RTT::base::PortInterface::getPortID(), and lock().

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

void RTT::internal::ConnectionManager::disconnect ( )
bool RTT::internal::ConnectionManager::disconnect ( base::PortInterface port)

Removes the connection that connects this port to port.

Definition at line 72 of file ConnectionManager.cpp.

References RTT::base::PortInterface::getPortID(), and removeConnection().

ConnectionManager::Connections::iterator RTT::internal::ConnectionManager::eraseConnection ( const Connections::iterator &  descriptor,
bool  disconnect 
)
protected

Helper method for disconnect()

Unconditionally removes the given connection and returns the next connection in the list or connections.end()

Definition at line 78 of file ConnectionManager.cpp.

References connections, RTT::Debug, RTT::base::ChannelElementBase::disconnect(), RTT::base::PortInterface::getEndpoint(), RTT::base::PortInterface::getName(), mport, and shared_connection.

Referenced by disconnect(), and removeConnection().

Connections RTT::internal::ConnectionManager::getConnections ( ) const
inline

Returns a list of all connections managed by this object.

Definition at line 136 of file ConnectionManager.hpp.

internal::SharedConnectionBase::shared_ptr RTT::internal::ConnectionManager::getSharedConnection ( ) const
inline

Returns a pointer to the shared connection element this port may be connected to.

Definition at line 143 of file ConnectionManager.hpp.

Referenced by RTT::OutputPort< T >::clear(), and RTT::base::PortInterface::getSharedConnection().

bool RTT::internal::ConnectionManager::isSingleConnection ( ) const
inline

Returns true if this manager manages only one connection.

Returns

Definition at line 131 of file ConnectionManager.hpp.

void RTT::internal::ConnectionManager::lock ( ) const
inline

Locks the mutex protecting the channel element list.

Definition at line 150 of file ConnectionManager.hpp.

Referenced by addConnection(), connectedTo(), disconnect(), and removeConnection().

bool RTT::internal::ConnectionManager::removeConnection ( ConnID port_id,
bool  disconnect = true 
)
bool RTT::internal::ConnectionManager::removeConnection ( base::ChannelElementBase channel,
bool  disconnect = true 
)

Definition at line 154 of file ConnectionManager.cpp.

References connection_lock, connections, eraseConnection(), and lock().

void RTT::internal::ConnectionManager::unlock ( ) const
inline

Unlocks the mutex protecting the channel element list.

Definition at line 157 of file ConnectionManager.hpp.

Member Data Documentation

RTT::os::Mutex RTT::internal::ConnectionManager::connection_lock
mutableprotected

Lock that should be taken before the list of connections is accessed or modified.

Definition at line 188 of file ConnectionManager.hpp.

Referenced by addConnection(), connectedTo(), disconnect(), and removeConnection().

std::list< ChannelDescriptor > RTT::internal::ConnectionManager::connections
protected

A list of all our connections.

Only non-null if two or more connections were added.

Definition at line 177 of file ConnectionManager.hpp.

Referenced by addConnection(), connected(), connectedTo(), disconnect(), eraseConnection(), and removeConnection().

base::PortInterface* RTT::internal::ConnectionManager::mport
protected

The port for which we manage connections.

Definition at line 171 of file ConnectionManager.hpp.

Referenced by eraseConnection().

internal::SharedConnectionBase::shared_ptr RTT::internal::ConnectionManager::shared_connection
protected

A pointer to the shared connection this port may be connected to.

Definition at line 182 of file ConnectionManager.hpp.

Referenced by addConnection(), and eraseConnection().


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