Orocos Real-Time Toolkit
2.9.0
|
Manages connections between ports. More...
#include <rtt/internal/ConnectionManager.hpp>
Public Types | |
typedef boost::tuple< boost::shared_ptr< ConnID >, base::ChannelElementBase::shared_ptr, ConnPolicy > | ChannelDescriptor |
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< ChannelDescriptor > | Connections |
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::PortInterface * | mport |
The port for which we manage connections. More... | |
std::list< ChannelDescriptor > | connections |
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... | |
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.
typedef boost::tuple<boost::shared_ptr<ConnID>, base::ChannelElementBase::shared_ptr, ConnPolicy> RTT::internal::ConnectionManager::ChannelDescriptor |
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.
typedef std::list<ChannelDescriptor> RTT::internal::ConnectionManager::Connections |
Definition at line 89 of file ConnectionManager.hpp.
RTT::internal::ConnectionManager::ConnectionManager | ( | base::PortInterface * | port | ) |
Creates a connection manager to manage the connections of port.
port | The 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().
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.
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 | ( | ) |
Disconnect all connections.
Definition at line 101 of file ConnectionManager.cpp.
References connection_lock, connections, eraseConnection(), and lock().
Referenced by RTT::base::OutputPortInterface::disconnect(), ~ConnectionManager(), and RTT::base::OutputPortInterface::~OutputPortInterface().
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().
|
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().
|
inline |
Returns a list of all connections managed by this object.
Definition at line 136 of file ConnectionManager.hpp.
|
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().
|
inline |
Returns true if this manager manages only one connection.
Definition at line 131 of file ConnectionManager.hpp.
|
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 |
||
) |
Definition at line 139 of file ConnectionManager.cpp.
References connection_lock, connections, eraseConnection(), RTT::internal::ConnID::isSameID(), and lock().
Referenced by disconnect(), and RTT::base::PortInterface::removeConnection().
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().
|
inline |
Unlocks the mutex protecting the channel element list.
Definition at line 157 of file ConnectionManager.hpp.
|
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().
|
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().
|
protected |
The port for which we manage connections.
Definition at line 171 of file ConnectionManager.hpp.
Referenced by eraseConnection().
|
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().