fw4spl
HasSlots.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_HASSLOTS_HPP__
8 #define __FWCOM_HASSLOTS_HPP__
9 
10 #include "fwCom/config.hpp"
11 #include "fwCom/Slots.hpp"
12 #include "fwCom/util/convert_function_type.hpp"
13 
14 namespace fwCom
15 {
16 
17 struct SlotBase;
18 
22 class HasSlots
23 {
24 
25 public:
26 
27  typedef std::shared_ptr< HasSlots > sptr;
28  typedef std::shared_ptr< const HasSlots > csptr;
29 
30  HasSlots()
31  {
32  }
33  virtual ~HasSlots()
34  {
35  }
36 
37  SPTR( SlotBase ) slot( const Slots::SlotKeyType & key ) const
38  {
39  return m_slots[key];
40  }
41 
42  template< typename SlotType >
43  SPTR( SlotType ) slot( const Slots::SlotKeyType & key ) const
44  {
45  SPTR( SlotType ) slot = std::dynamic_pointer_cast< SlotType >( this->slot(key) );
46  return slot;
47  }
48 
49  template<typename F, typename A>
50  SPTR(Slot< typename ::fwCom::util::convert_function_type< F >::type >) newSlot( const Slots::SlotKeyType & key, F f,
51  A a );
52 
53 protected:
54 
56  HasSlots( const HasSlots& );
57 
59  HasSlots& operator=( const HasSlots& );
60 
61  Slots m_slots;
62 };
63 
64 } // namespace fwCom
65 
66 #endif // __FWCOM_HASSLOTS_HPP__
#define SPTR(_cls_)
Namespace containing fw4spl communication tools.
Definition: DumpEditor.hpp:30
This class proposes a mapping between a SlotKeyType and a SlotBase.
Definition: HasSlots.hpp:22
This class proposes a mapping between a SlotKeyType and a SlotBase.
Definition: Slots.hpp:33
HasSlots & operator=(const HasSlots &)
Copy operator forbidden.
Base class for Slot implementations.
Definition: SlotBase.hpp:46