fw4spl
HasSignals.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 __FWCOM_HASSIGNALS_HPP__
8 #define __FWCOM_HASSIGNALS_HPP__
9 
10 #include "fwCom/config.hpp"
11 #include "fwCom/Signals.hpp"
12 
13 namespace fwCom
14 {
15 
16 struct SignalBase;
17 
22 {
23 
24 public:
25 
26  typedef std::shared_ptr< HasSignals > sptr;
27  typedef std::shared_ptr< const HasSignals > csptr;
28 
29  HasSignals()
30  {
31  }
32  virtual ~HasSignals()
33  {
34  }
35 
36  SPTR( SignalBase ) signal( const Signals::SignalKeyType & key ) const
37  {
38  return m_signals[key];
39  }
40 
41  template< typename SignalType >
42  SPTR( SignalType ) signal( const Signals::SignalKeyType & key ) const
43  {
44  SPTR( SignalType ) Signal = std::dynamic_pointer_cast< SignalType >( this->signal(key) );
45  return Signal;
46  }
47 
48  template<typename SignalType>
49  SPTR( SignalType ) newSignal(const Signals::SignalKeyType & key)
50  {
51  SPTR( SignalType ) sig = std::make_shared< SignalType > ();
52  m_signals(key, sig);
53  return sig;
54  }
55 
56 protected:
57 
59  HasSignals( const HasSignals& );
60 
62  HasSignals& operator=( const HasSignals& );
63 
64  Signals m_signals;
65 };
66 
67 } // namespace fwCom
68 
69 #endif // __FWCOM_HASSIGNALS_HPP__
#define SPTR(_cls_)
Namespace containing fw4spl communication tools.
Definition: DumpEditor.hpp:30
HasSignals & operator=(const HasSignals &)
Copy operator forbidden.
This class proposes a mapping between a SignalKeyType and a SignalBase.
Definition: Signals.hpp:28
Signal base class.
Definition: SignalBase.hpp:23
This class proposes a mapping between a SignalKeyType and a SignalBase.
Definition: HasSignals.hpp:21