46 #ifndef CONNECTIONMANAGER_HPP_ 47 #define CONNECTIONMANAGER_HPP_ 52 #include "../ConnPolicy.hpp" 53 #include "../os/Mutex.hpp" 54 #include "../base/rtt-base-fwd.hpp" 55 #include "../base/ChannelElementBase.hpp" 56 #include <boost/tuple/tuple.hpp> 57 #include <boost/bind.hpp> 58 #include <boost/shared_ptr.hpp> 100 void addConnection(
ConnID* port_id, base::ChannelElementBase::shared_ptr channel_input,
ConnPolicy policy);
102 bool removeConnection(
ConnID* port_id);
112 bool connected()
const;
117 template<
typename Pred>
121 std::list<ChannelDescriptor>::iterator it = connections.begin();
122 while (it != connections.end())
127 it = connections.erase(it);
142 template<
typename Pred>
145 ChannelDescriptor *new_channel =
146 find_if(pred, copy_old_data);
152 cur_channel = new_channel;
156 template<
typename Pred>
157 ChannelDescriptor *
find_if(Pred pred,
bool copy_old_data) {
161 ChannelDescriptor *channel = cur_channel;
163 if ( pred( copy_old_data, *channel ) )
166 std::list<ChannelDescriptor>::iterator result;
167 for (result = connections.begin(); result != connections.end(); ++result) {
168 if (cur_channel && (result->get<1>() == cur_channel->get<1>()))
continue;
169 if ( pred(
false, *result) ==
true)
187 return cur_channel ? cur_channel->get<1>().
get() : NULL;
208 connection_lock.lock();
215 connection_lock.unlock();
219 void updateCurrentChannel(
bool reset_current);
229 bool findMatchingPort(
ConnID const* conn_id, ChannelDescriptor
const& descriptor);
235 bool eraseConnection(ChannelDescriptor& descriptor);
We can't use typedefs since C++ doesn't allow it for templated classes without specifying all the tem...
std::list< ChannelDescriptor > getChannels() const
Returns a list of all channels managed by this object.
base::ChannelElementBase * getCurrentChannel() const
Returns the first added channel or if select_if was called, the selected channel. ...
ChannelDescriptor * cur_channel
Optimisation in case only one channel is to be managed.
bool delete_if(Pred pred)
Manages connections between ports.
A connection policy object describes how a given connection should behave.
void unlock() const
Unlocks the mutex protecting the channel element list.
void lock() const
Locks the mutex protecting the channel element list.
base::PortInterface * mport
The port for which we manage connections.
os::Mutex connection_resize_mtx
os::Mutex for when it is needed to resize the connections list
boost::tuple< boost::shared_ptr< ConnID >, base::ChannelElementBase::shared_ptr, ConnPolicy > ChannelDescriptor
A Channel (= connection) is described by an opaque ConnID object, the first element of the channel an...
boost::intrusive_ptr< ChannelElementBase > shared_ptr
RTT::os::Mutex connection_lock
Lock that should be taken before the list of connections is accessed or modified. ...
bool isSingleConnection() const
Returns true if this manager manages only one connection.
void select_reader_channel(Pred pred, bool copy_old_data)
Selects a connection as the current channel if pred(connection) is true.
This class is used in places where a permanent representation of a reference to a connection is neede...
An object oriented wrapper around a non recursive mutex.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
std::list< ChannelDescriptor > connections
A list of all our connections.
In the data flow implementation, a channel is created by chaining ChannelElementBase objects...
ChannelDescriptor * find_if(Pred pred, bool copy_old_data)
The base class of every data flow port.
MutexLock is a scope based Monitor, protecting critical sections with a Mutex object through locking ...