fw4spl
ActionCallbackBase.cpp
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 #include <fwTools/fwID.hpp>
8 #include <fwServices/IService.hpp>
9 #include <fwServices/macros.hpp>
10 
11 #include "fwGui/IActionSrv.hpp"
12 #include "fwGui/ActionCallbackBase.hpp"
13 
14 #include <fwServices/op/Get.hpp>
15 
16 namespace fwGui
17 {
18 
19 //-----------------------------------------------------------------------------
20 
21 const ActionCallbackBase::RegistryKeyType ActionCallbackBase::REGISTRY_KEY = "::fwGui::ActionCallback";
22 
23 //-----------------------------------------------------------------------------
24 
26 {
27 }
28 
29 //-----------------------------------------------------------------------------
30 
32 {
33 }
34 
35 //-----------------------------------------------------------------------------
36 
37 void ActionCallbackBase::setSID(std::string sid)
38 {
39  this->m_sid = sid;
40 }
41 
42 //-----------------------------------------------------------------------------
43 
45 {
46  OSLM_ASSERT("Service "<<m_sid<<" doesn't exist.", ::fwTools::fwID::exist(m_sid ));
47  ::fwServices::IService::sptr service = ::fwServices::get( m_sid );
48  OSLM_ASSERT("Service "<<m_sid<<" not instanced.", service);
49  service->update();
50 }
51 
52 //-----------------------------------------------------------------------------
53 
54 void ActionCallbackBase::check(bool checked)
55 {
56  OSLM_ASSERT("Service "<<m_sid<<" doesn't exist.", ::fwTools::fwID::exist(m_sid ));
57  ::fwServices::IService::sptr service = ::fwServices::get( m_sid );
58  OSLM_ASSERT("Service "<<m_sid<<" not instanced.", service);
59  ::fwGui::IActionSrv::sptr action = ::fwGui::IActionSrv::dynamicCast(service);
60  OSLM_ASSERT("Service "<<m_sid<<" is not an action.", action);
61  checked = (checked == action->getActiveStateValue());
62  if (action->getIsActive() != checked)
63  {
64  action->setIsActive(checked);
65  }
66 }
67 
68 //-----------------------------------------------------------------------------
69 
70 
71 } // namespace fwGui
72 
73 
#define OSLM_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:310
The namespace fwGui contains the base interface for IHM services.
Definition: SJobBar.hpp:23
static FWTOOLS_API bool exist(IDType _id)
Definition: fwID.cpp:33
FWGUI_API ActionCallbackBase()
Constructor.
virtual FWGUI_API void setSID(std::string sid)
Sets service ID updated in executed method.
virtual FWGUI_API void check(bool checked)
Called method when callback is checked.
virtual FWGUI_API void execute() override
Called method when callback is executed.
virtual FWGUI_API ~ActionCallbackBase()
Destructor. Do nothing.