DDS  ver. 1.6
ChannelEventsImpl.h
Go to the documentation of this file.
1 // Copyright 2015 GSI, Inc. All rights reserved.
2 //
3 //
4 //
5 #ifndef DDS_ChannelEventsImpl_h
6 #define DDS_ChannelEventsImpl_h
7 // BOOST
8 #include <boost/ptr_container/ptr_map.hpp>
9 #include <boost/signals2/signal.hpp>
10 
11 namespace dds
12 {
13  namespace protocol_api
14  {
15  // Channel events, which channels and users of channel objects can subscribe on.
17  {
23  };
24 
26  template <class T>
28  {
29  public:
30  typedef boost::signals2::signal<void(T*)> signal_t;
31  typedef boost::signals2::connection connection_t;
32 
33  private:
34  typedef boost::ptr_map<EChannelEvents, signal_t> signalsContainer_t;
35 
36  public:
38  {
39  }
41  {
42  }
43 
44  public:
45  connection_t subscribeOnEvent(EChannelEvents _type, typename signal_t::slot_function_type _subscriber)
46  {
47  return m_sig[_type].connect(_subscriber);
48  }
49 
50  void onEvent(EChannelEvents _type)
51  {
52  try
53  {
54  T* pThis = static_cast<T*>(this);
55  m_sig[_type](pThis);
56  }
57  catch (...)
58  {
59  }
60  }
61 
62  private:
63  signalsContainer_t m_sig;
64  };
65  }
66 }
67 
68 #endif
Definition: ChannelEventsImpl.h:19
Definition: ChannelEventsImpl.h:22
Definition: ChannelEventsImpl.h:21
boost::signals2::connection connection_t
Definition: ChannelEventsImpl.h:31
Definition: dds-agent/src/AgentConnectionManager.h:16
connection_t subscribeOnEvent(EChannelEvents _type, typename signal_t::slot_function_type _subscriber)
Definition: ChannelEventsImpl.h:45
This class implements slots subscription and slots calls associated with certain channel events...
Definition: ChannelEventsImpl.h:27
void onEvent(EChannelEvents _type)
Definition: ChannelEventsImpl.h:50
EChannelEvents
Definition: ChannelEventsImpl.h:16
Definition: ChannelEventsImpl.h:20
Definition: ChannelEventsImpl.h:18
boost::signals2::signal< void(T *)> signal_t
Definition: ChannelEventsImpl.h:30