SignalBase.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Wed Jan 18 14:11:38 CET 2006 SignalBase.hpp
3 
4  SignalBase.hpp - description
5  -------------------
6  begin : Wed January 18 2006
7  copyright : (C) 2006 Peter Soetens
8  email : peter.soetens@mech.kuleuven.be
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 #ifndef ORO_SIGNAL_BASE_HPP
40 #define ORO_SIGNAL_BASE_HPP
41 
42 #include <boost/intrusive_ptr.hpp>
43 #include <boost/function.hpp>
44 
45 #include "../rtt-config.h"
46 
47 #if defined(OROBLD_OS_NO_ASM)
48 #define ORO_SIGNAL_USE_RT_LIST
49 #else
50 #define ORO_SIGNAL_USE_LIST_LOCK_FREE
51 #endif
52 
53 #include "../os/Atomic.hpp"
54 #ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE
55 #include "ListLockFree.hpp"
56 #include <boost/shared_ptr.hpp>
57 #else
58 #ifdef ORO_SIGNAL_USE_RT_LIST
59 #include "../os/Mutex.hpp"
60 #include "../os/rt_list.hpp"
61 #else
62 #include "../os/Mutex.hpp"
63 #include <list>
64 #endif
65 #endif
66 
67 namespace RTT
68 {
69  namespace internal {
70 
71  class SignalBase;
72 
80  class RTT_API ConnectionBase
81  {
82  protected:
83  RTT_API friend void intrusive_ptr_add_ref(ConnectionBase*);
84  RTT_API friend void intrusive_ptr_release(ConnectionBase*);
85  bool mconnected;
87 
93 
97  void ref();
101  void deref();
102 
103  protected:
104  virtual ~ConnectionBase();
105  public:
107 
108  typedef boost::intrusive_ptr<ConnectionBase> shared_ptr;
109 
110  inline bool connected() { return mconnected && m_sig; }
111  bool connect();
112  bool disconnect();
113  void destroy();
114  private:
116  const ConnectionBase& operator=( const ConnectionBase& );
117  };
118 
119  RTT_API void intrusive_ptr_add_ref( ConnectionBase* p );
120  RTT_API void intrusive_ptr_release( ConnectionBase* p );
121 
128  class RTT_API SignalBase
129  {
130  public:
132 #ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE
134 #else
135 #ifdef ORO_SIGNAL_USE_RT_LIST
136  typedef RTT::os::rt_list< connection_t > connections_list;
137 #else
138  typedef std::list< connection_t > connections_list;
139 #endif
140  typedef connections_list::iterator iterator;
141  typedef connections_list::iterator const_iterator;
142 #endif
143  protected:
144  friend class ConnectionBase;
145 
146  void conn_setup( connection_t conn );
147 
148  void conn_connect( connection_t conn );
149 
150  void conn_disconnect( connection_t conn );
151 
152  void conn_destroy( connection_t conn );
153  protected:
154  connections_list mconnections;
155 #ifdef ORO_SIGNAL_USE_LIST_LOCK_FREE
156  // no mutexes involved
157 #else
158 
161  void cleanup();
162 
164  iterator itend;
165 #ifdef ORO_SIGNAL_USE_RT_LIST
166  int disconcount;
167 #else
168  int concount;
169 #endif
170 #endif
171  bool emitting;
172  SignalBase();
173  public:
180  virtual ~SignalBase();
181 
186  void disconnect();
187 
193  void destroy();
194 
204  void reserve(size_t conns);
208  virtual int arity() const = 0;
209  private:
210  SignalBase(const SignalBase& );
211  const SignalBase& operator=( const SignalBase& );
212 
213  };
214  }// namespace detail
215 
216 }
217 #endif
void RTT_API intrusive_ptr_add_ref(RTT::internal::IntrusiveStorage *p)
ListLockFree< connection_t > connections_list
Definition: SignalBase.hpp:133
void RTT_API intrusive_ptr_release(RTT::internal::IntrusiveStorage *p)
boost::intrusive_ptr< ConnectionBase > shared_ptr
Definition: SignalBase.hpp:108
connections_list mconnections
Definition: SignalBase.hpp:154
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
An object oriented wrapper around a recursive mutex.
Definition: Mutex.hpp:218
ConnectionBase::shared_ptr connection_t
Definition: SignalBase.hpp:131


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