fw4spl
SBooleanSlotCaller.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
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 #include "gui/action/SBooleanSlotCaller.hpp"
8 
9 #include <fwCom/Slot.hpp>
10 #include <fwCom/Slot.hxx>
11 #include <fwCom/Slots.hpp>
12 #include <fwCom/Slots.hxx>
13 
14 #include <fwCore/base.hpp>
15 
16 #include <fwGui/dialog/MessageDialog.hpp>
17 
18 #include <fwRuntime/Extension.hpp>
19 #include <fwRuntime/helper.hpp>
20 
21 #include <fwServices/macros.hpp>
22 
23 #include <fwTools/fwID.hpp>
24 
25 #include <boost/regex.hpp>
26 
27 namespace gui
28 {
29 namespace action
30 {
31 
32 fwServicesRegisterMacro( ::fwGui::IActionSrv, ::gui::action::SBooleanSlotCaller );
33 
34 //-----------------------------------------------------------------------------
35 
37 {
38 }
39 
40 //-----------------------------------------------------------------------------
41 
43 {
44 }
45 
46 //-----------------------------------------------------------------------------
47 
49 {
50  for(SlotInfoType info : m_slotInfos)
51  {
52  HasSlotIDType HasSlotId = info.first;
53  ::fwCom::Slots::SlotKeyType slotKey = info.second;
54 
55  if (::fwTools::fwID::exist(HasSlotId))
56  {
57  ::fwTools::Object::sptr obj = ::fwTools::fwID::getObject(HasSlotId);
58  ::fwCom::HasSlots::sptr hasSlots = std::dynamic_pointer_cast< ::fwCom::HasSlots >(obj);
59  SLM_ASSERT("Object with id " << HasSlotId << " is not a HasSlots", hasSlots);
60 
61  ::fwCom::SlotBase::sptr slot = hasSlots->slot(slotKey);
62 
63  slot->asyncRun(this->getIsActive());
64  }
65  }
66 }
67 
68 //-----------------------------------------------------------------------------
69 
70 } // namespace action
71 } // namespace gui
GUI_API void updating() override
This method run the specified slots.
virtual GUI_API ~SBooleanSlotCaller() noexcept
Destructor. Do nothing.
The namespace gui contains the basic services to build the application IHM.
static FWTOOLS_API bool exist(IDType _id)
Definition: fwID.cpp:33
GUI_API SBooleanSlotCaller() noexcept
Constructor. Do nothing.
This class proposes a mapping between a SlotKeyType and a SlotBase.
Definition: HasSlots.hpp:22
FWGUI_API bool getIsActive() const
Return true if action service is active.
Definition: IActionSrv.cpp:198
Defines the service interface managing the menu items.
Definition: IActionSrv.hpp:24
#define SLM_ASSERT(message, cond)
work like &#39;assert&#39; from &#39;cassert&#39;, with in addition a message logged by spylog (with FATAL loglevel) ...
Definition: spyLog.hpp:308
virtual GUI_API void info(std::ostream &_sstream) override
This method gives information about the class.
Definition: SSlotCaller.cpp:65
This action runs a slot given by HasSlot id and slot key with a boolean in paramter representing the ...
static FWTOOLS_API std::shared_ptr< ::fwTools::Object > getObject(IDType requestID)
Retrieve the object attached to the given id. Return a null sptr if no correspondence exist...
Definition: fwID.cpp:117