fw4spl
SlotConnection.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 #ifndef __FWCOM_SLOTCONNECTION_HPP__
7 #define __FWCOM_SLOTCONNECTION_HPP__
8 
9 #include "fwCom/SlotConnectionBase.hpp"
10 
11 #include "fwCom/SlotBase.hpp"
12 
13 namespace fwCom
14 {
15 
16 template < typename F >
17 struct Signal;
18 
19 template < typename F >
21 
26 template < typename ... A >
27 struct SlotConnection< void (A ...) > : SlotConnectionBase
28 {
32  typedef void SignatureType ( A ... );
34 
35  typedef SPTR ( SelfType ) sptr;
36 
38  typedef SPTR ( SignalType ) SignalSptrType;
39  typedef WPTR ( SignalType ) SignalWptrType;
40 
42  typedef SPTR ( SlotWrapperType ) SlotWrapperSptrType;
43 
45  typedef SPTR ( SlotRunType ) SlotRunSptrType;
46 
47  typedef std::pair< bool, SlotRunType* > PairType;
50  static sptr New( const SignalSptrType &signal, const SlotRunSptrType &slot );
52 
54  static sptr New( const SignalSptrType &signal,
55  const SPTR( SlotBase ) &slot,
56  const SlotWrapperSptrType &slotWrapper
57  );
58 
60  void disconnect();
61 
62  ~SlotConnection();
63 
64 
66  SlotConnection( const SignalSptrType &signal, const SlotRunSptrType &slot );
67 
69  SlotConnection( const SignalSptrType &signal,
70  const SPTR( SlotBase ) &slot,
71  const SlotWrapperSptrType &slotWrapper
72  );
73 
74 
75  protected:
76 
77  template < typename F >
78  friend struct Signal;
79 
81  void connectNoLock();
82 
83 
85  void disconnectSignalNoLock(const SignalSptrType &sig);
86 
88  void disconnectSlotNoLock(const SPTR( SlotBase ) &slot);
89 
91  void disconnectWeakLock();
92 
97  SlotConnectionBase::BlockerSptrType getBlocker();
98 
100  void unblock();
101 
103  SignalWptrType m_signal;
104 
106  WPTR( SlotBase ) m_connectedSlot;
107 
109  SlotWrapperSptrType m_slotWrapper;
110 
115  PairType m_pair;
116 
118  SlotConnectionBase::BlockerWptrType m_weakBlocker;
119 
120  mutable ::fwCore::mt::ReadWriteMutex m_mutex;
121 };
122 
123 
124 } // namespace fwCom
125 
126 #endif /* __FWCOM_SLOTCONNECTION_HPP__ */
127 
#define SPTR(_cls_)
Namespace containing fw4spl communication tools.
Definition: DumpEditor.hpp:30
#define WPTR(_cls_)
This namespace fwCore provides common foundations for FW4SPL.
Definition: BaseObject.hpp:16
SignalWptrType m_signal
Related Signal.
Base class for Slot connection implementation. This class is for internal use purpose.
Base class for Slot implementations.
Definition: SlotBase.hpp:46