fw4spl
Connection.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_CONNECTION_HPP__
7 #define __FWCOM_CONNECTION_HPP__
8 
9 #include "fwCom/config.hpp"
10 
11 #include "fwCom/SlotConnectionBase.hpp"
12 
13 namespace fwCom
14 {
15 
17 struct Connection
18 {
20  struct Blocker
21  {
22  Blocker()
23  {
24  }
25 
26  Blocker( Connection connection )
27  : m_blocker(connection.getBlocker())
28  {
29  }
30 
32  void reset()
33  {
34  m_blocker.reset();
35  }
36 
37  protected:
38  SlotConnectionBase::BlockerSptrType m_blocker;
39  };
40 
41  Connection()
42  {
43  }
44 
45  Connection(const SlotConnectionBase::sptr &connection) : m_connectionBase(connection)
46  {
47  }
48 
50  void disconnect()
51  {
52  SlotConnectionBase::sptr connection(m_connectionBase.lock());
53  if(connection)
54  {
55  connection->disconnect();
56  }
57  }
58 
60  bool expired() const
61  {
62  return m_connectionBase.expired();
63  }
64 
65  protected:
66 
68  SlotConnectionBase::BlockerSptrType getBlocker()
69  {
70  SlotConnectionBase::BlockerSptrType blocker;
71  SlotConnectionBase::sptr connection(m_connectionBase.lock());
72  if(connection)
73  {
74  blocker = connection->getBlocker();
75  }
76  return blocker;
77  }
78 
79  SlotConnectionBase::wptr m_connectionBase;
80 
81 };
82 
83 
84 } // namespace fwCom
85 
86 #endif /* __FWCOM_CONNECTION_HPP__ */
87 
Class allowing to block a Connection.
Definition: Connection.hpp:20
Namespace containing fw4spl communication tools.
Definition: DumpEditor.hpp:30
bool expired() const
Returns whether this Connection is expired or not.
Definition: Connection.hpp:60
Class managing Signal-Slot connections.
Definition: Connection.hpp:17
void reset()
Unblock the related Connection.
Definition: Connection.hpp:32
SlotConnectionBase::BlockerSptrType getBlocker()
Returns a Blocker.
Definition: Connection.hpp:68
void disconnect()
Disconnect related Connection.
Definition: Connection.hpp:50