fw4spl
Proxy.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2016.
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 
7 #ifndef __FWSERVICES_REGISTRY_PROXY_HPP__
8 #define __FWSERVICES_REGISTRY_PROXY_HPP__
9 
10 #include <vector>
11 
12 
13 #include <fwCore/base.hpp>
14 #include <fwCore/mt/types.hpp>
15 
16 #include <fwCom/SignalBase.hpp>
17 #include <fwCom/SlotBase.hpp>
18 
19 #include "fwServices/config.hpp"
20 
21 namespace fwServices
22 {
23 namespace registry
24 {
25 
31 class FWSERVICES_CLASS_API Proxy : public ::fwCore::BaseObject
32 {
33 
34 public:
35 
36  fwCoreClassDefinitionsWithFactoryMacro((Proxy)(::fwCore::BaseObject), (()), std::make_shared< Proxy >);
37 
38  typedef std::string ChannelKeyType;
39 
44  struct SigSlots
45  {
46  typedef std::set< ::fwCom::SignalBase::sptr > SignalContainerType;
47  typedef std::set< ::fwCom::SlotBase::sptr > SlotContainerType;
48  SignalContainerType m_signals;
49  SlotContainerType m_slots;
50  SlotContainerType::iterator m_lastConnectedSlot;
51 
53  };
54 
55  typedef std::map< ChannelKeyType, SPTR(SigSlots) > ChannelMapType;
56 
58  FWSERVICES_API Proxy();
59 
61  FWSERVICES_API virtual ~Proxy();
62 
64  FWSERVICES_API static Proxy::sptr getDefault();
65 
67  FWSERVICES_API void connect(ChannelKeyType channel, ::fwCom::SignalBase::sptr signal);
68 
70  FWSERVICES_API void connect(ChannelKeyType channel, ::fwCom::SlotBase::sptr slot);
71 
73  FWSERVICES_API void disconnect(ChannelKeyType channel, ::fwCom::SignalBase::sptr signal);
74 
76  FWSERVICES_API void disconnect(ChannelKeyType channel, ::fwCom::SlotBase::sptr slot);
77 
78 protected:
79 
81  ChannelMapType m_channels;
82 
84  mutable ::fwCore::mt::ReadWriteMutex m_channelMutex;
85 
87  static Proxy::sptr s_currentProxy;
88 
89 };
90 
91 } // namespace registry
92 } // namespace fwServices
93 
94 #endif // __FWSERVICES_REGISTRY_PROXY_HPP__
Contains fwAtomsFilter::registry details.
Base class for all FW4SPL&#39;s classes.
Definition: BaseObject.hpp:22
::boost::shared_mutex ReadWriteMutex
Defines a single writer, multiple readers mutex.
static Proxy::sptr s_currentProxy
The global instance of the proxy.
Definition: Proxy.hpp:87
Namespace fwServices is dedicated to (mimic) the dynamic affectation of methods to (pure data) object...
ChannelMapType m_channels
Association channels, SigSlot.
Definition: Proxy.hpp:81
Structure to regsiter signal and slot informations Contains a signal container, a slot container and ...
Definition: Proxy.hpp:44
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
mutable::fwCore::mt::ReadWriteMutex m_channelMutex
Used to protect the m_channels access.
Definition: Proxy.hpp:84
This class defines a proxy for signal/slot connections.
Definition: Proxy.hpp:31