fw4spl
Slots.hxx
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 
7 #ifndef __FWCOM_SLOTS_HXX__
8 #define __FWCOM_SLOTS_HXX__
9 
10 
11 #ifndef __FWCOM_SLOTS_HPP__
12 #error fwCom/Slots.hpp not included
13 #endif
14 
15 #include "fwCom/Slot.hpp"
16 #include "fwCom/Slot.hxx"
17 
18 
19 namespace fwCom
20 {
21 
22 template<typename F, typename ... A>
23 Slots& Slots::operator()( const SlotKeyType &key, F f, A ... a )
24 {
25  SPTR( SlotBase ) slotBase = std::dynamic_pointer_cast< SlotBase >( ::fwCom::newSlot(f, a ...) );
26  return this->operator()(key, slotBase);
27 }
28 
29 // Only define it when fwCom/HasSlots.hpp has been included
30 // This saves us a file like fwCom/HasSlots.hxx
31 #ifdef __FWCOM_HASSLOTS_HPP__
32 
33 template<typename F, typename A>
34 SPTR(Slot< typename ::fwCom::util::convert_function_type< F >::type >)
35 HasSlots::newSlot( const ::fwCom::Slots::SlotKeyType & key, F f, A a )
36 {
37  auto slot = ::fwCom::newSlot(f, a);
38  this->m_slots(key, slot);
39  return slot;
40 }
41 
42 #endif
43 
44 } // namespace fwCom
45 
46 #endif //__FWCOM_SLOTS_HXX__
#define SPTR(_cls_)
Namespace containing fw4spl communication tools.
Definition: DumpEditor.hpp:30
SlotMapType m_slots
Association < key , SPTR( SlotBase ) >
Definition: Slots.hpp:80
This class proposes a mapping between a SlotKeyType and a SlotBase.
Definition: Slots.hpp:33
Base class for Slot implementations.
Definition: SlotBase.hpp:46
FWCOM_API Slots & operator()(const SlotKeyType &key, const std::shared_ptr< SlotBase > &slot)
Registers SlotBase in m_slots.