ConnectionManager.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Thu Oct 22 11:59:08 CEST 2009 ConnectionManager.hpp
3 
4  ConnectionManager.hpp - description
5  -------------------
6  begin : Thu October 22 2009
7  copyright : (C) 2009 Peter Soetens
8  email : peter@thesourcworks.com
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 
39 /*
40  * ConnectionManager.hpp
41  *
42  * Created on: Oct 9, 2009
43  * Author: kaltan
44  */
45 
46 #ifndef CONNECTIONMANAGER_HPP_
47 #define CONNECTIONMANAGER_HPP_
48 
49 
50 #include "ConnID.hpp"
51 #include "List.hpp"
52 #include "SharedConnection.hpp"
53 #include "../ConnPolicy.hpp"
54 #include "../os/Mutex.hpp"
55 #include "../base/rtt-base-fwd.hpp"
56 #include "../base/ChannelElementBase.hpp"
57 #include <boost/tuple/tuple.hpp>
58 #include <boost/function.hpp>
59 #include <boost/bind.hpp>
60 #include <boost/shared_ptr.hpp>
61 
62 #include <rtt/os/Mutex.hpp>
63 #include <rtt/os/MutexLock.hpp>
64 #include <list>
65 
66 
67 namespace RTT
68 {
69 
70  namespace internal
71  {
78  class RTT_API ConnectionManager
79  {
80  public:
87  typedef boost::tuple<boost::shared_ptr<ConnID>, base::ChannelElementBase::shared_ptr, ConnPolicy> ChannelDescriptor;
88 
89  typedef std::list<ChannelDescriptor> Connections;
90 
98 
104  bool addConnection(ConnID* port_id, base::ChannelElementBase::shared_ptr channel, ConnPolicy policy);
105 
106  bool removeConnection(ConnID* port_id, bool disconnect = true);
107  bool removeConnection(base::ChannelElementBase* channel, bool disconnect = true);
108 
112  void disconnect();
113 
117  bool connected() const;
118 
121  bool connectedTo(base::PortInterface* port);
122 
123 
125  bool disconnect(base::PortInterface* port);
126 
131  bool isSingleConnection() const { return connections.size() == 1; }
132 
136  Connections getConnections() const {
137  return connections;
138  }
139 
144  return shared_connection;
145  }
146 
147 // /**
148 // * Locks the mutex protecting the channel element list.
149 // * */
150 // void lock() const {
151 // connection_lock.lock();
152 // };
153 
154 // /**
155 // * Unlocks the mutex protecting the channel element list.
156 // * */
157 // void unlock() const {
158 // connection_lock.unlock();
159 // }
160 
161  protected:
162 
167  Connections::iterator eraseConnection(const Connections::iterator& descriptor, bool disconnect);
168 
173 
178  std::list< ChannelDescriptor > connections;
179 
184  };
185 
186  }
187 
188 }
189 
190 #endif /* CONNECTIONMANAGER_HPP_ */
boost::intrusive_ptr< SharedConnectionBase > shared_ptr
internal::SharedConnectionBase::shared_ptr shared_connection
std::list< ChannelDescriptor > Connections
boost::tuple< boost::shared_ptr< ConnID >, base::ChannelElementBase::shared_ptr, ConnPolicy > ChannelDescriptor
boost::intrusive_ptr< ChannelElementBase > shared_ptr
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
std::list< ChannelDescriptor > connections
internal::SharedConnectionBase::shared_ptr getSharedConnection() const


rtt
Author(s): RTT Developers
autogenerated on Fri Oct 25 2019 03:59:32