fw4spl
SObjFromSlot.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2015-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 "ctrlSelection/updater/SObjFromSlot.hpp"
8 
9 #include <fwCom/Slot.hxx>
10 #include <fwCom/Slots.hxx>
11 
12 #include <fwServices/macros.hpp>
13 
14 namespace ctrlSelection
15 {
16 
17 namespace updater
18 {
19 
20 const ::fwCom::Slots::SlotKeyType SObjFromSlot::s_ADD_OR_SWAP_SLOT = "addOrSwap";
21 const ::fwCom::Slots::SlotKeyType SObjFromSlot::s_ADD_SLOT = "add";
22 const ::fwCom::Slots::SlotKeyType SObjFromSlot::s_SWAP_OBJ_SLOT = "swapObj";
23 const ::fwCom::Slots::SlotKeyType SObjFromSlot::s_REMOVE_SLOT = "remove";
24 const ::fwCom::Slots::SlotKeyType SObjFromSlot::s_REMOVE_IF_PRESENT_SLOT = "removeIfPresent";
25 
26 static const std::string s_OBJECT = "object";
27 
28 //-----------------------------------------------------------------------------
29 
31 
32 //-----------------------------------------------------------------------------
33 
35 {
37  newSlot(s_ADD_SLOT, &SObjFromSlot::add, this);
38  newSlot(s_SWAP_OBJ_SLOT, &SObjFromSlot::swap, this);
39  newSlot(s_REMOVE_SLOT, &SObjFromSlot::remove, this);
41 }
42 
43 //-----------------------------------------------------------------------------
44 
46 {
47 }
48 
49 //-----------------------------------------------------------------------------
50 
52 {
53 }
54 
55 //-----------------------------------------------------------------------------
56 
58 {
59 }
60 
61 //-----------------------------------------------------------------------------
62 
64 {
65 }
66 
67 //-----------------------------------------------------------------------------
68 
70 {
71 }
72 
73 //-----------------------------------------------------------------------------
74 
75 void SObjFromSlot::info( std::ostream& )
76 {
77 }
78 
79 //-----------------------------------------------------------------------------
80 
81 void SObjFromSlot::add(::fwData::Object::sptr obj)
82 {
83  this->setOutput(s_OBJECT, obj);
84 }
85 
86 //-----------------------------------------------------------------------------
87 
88 void SObjFromSlot::addOrSwap(::fwData::Object::sptr obj)
89 {
90  FW_DEPRECATED("addOrSwap", "add", "18.0");
91  this->setOutput(s_OBJECT, obj);
92 }
93 
94 //-----------------------------------------------------------------------------
95 
96 void SObjFromSlot::swap(::fwData::Object::sptr obj)
97 {
98  FW_DEPRECATED("addOrSwap", "add", "18.0");
99  this->setOutput(s_OBJECT, obj);
100 }
101 
102 //-----------------------------------------------------------------------------
103 
105 {
106  this->setOutput(s_OBJECT, nullptr);
107 }
108 
109 //-----------------------------------------------------------------------------
110 
112 {
113  FW_DEPRECATED("removeIfPresent", "remove", "18.0");
114  this->setOutput(s_OBJECT, nullptr);
115 }
116 
117 //-----------------------------------------------------------------------------
118 
119 } // updater
120 } // ctrlSelection
virtual CTRLSELECTION_API void info(std::ostream &_sstream) override
Implements info method derived from IService. Print classname.
void add(::fwData::Object::sptr obj)
Registers the given object in the OSR.
virtual CTRLSELECTION_API void stopping() override
Implements stopping method derived from IService. Do nothing.
void addOrSwap(::fwData::Object::sptr obj)
Adds or swap the object into the composite with the key given by config.
void swap(::fwData::Object::sptr obj)
Swaps the object into the composite with the key given by config.
static const ::fwCom::Slots::SlotKeyType s_REMOVE_IF_PRESENT_SLOT
Registers the given object in the OSR.
virtual CTRLSELECTION_API void configuring() override
Configures the service.
virtual CTRLSELECTION_API void updating() override
Implements updating method derived from IService. Do nothing.
static const ::fwCom::Slots::SlotKeyType s_ADD_SLOT
Registers the given object in the OSR.
static const ::fwCom::Slots::SlotKeyType s_REMOVE_SLOT
Registers the given object in the OSR.
CTRLSELECTION_API SObjFromSlot() noexcept
Constructor. Do nothing.
Registers/unregisters the object given by the slots.
FWSERVICES_API void setOutput(const ::fwServices::IService::KeyType &key, const ::fwData::Object::sptr &object, size_t index=0)
Register an output object at a given key in the OSR, replacing it if it already exists.
Definition: IService.cpp:80
virtual CTRLSELECTION_API ~SObjFromSlot() noexcept
Destructor. Do nothing.
virtual CTRLSELECTION_API void starting() override
Implements starting method derived from IService. Do nothing.
static const ::fwCom::Slots::SlotKeyType s_SWAP_OBJ_SLOT
Registers the given object in the OSR.
An updater is use to register/unregister object in the OSR when it receives specific signals (declare...
Definition: IUpdaterSrv.hpp:24
This class defines a composite object.
void remove()
Adds the object from the composite with the key given by config.
The namespace ctrlSelection contains several interfaces for manager, updater and wrapper.
Definition: BookmarkSrv.hpp:15
static const ::fwCom::Slots::SlotKeyType s_ADD_OR_SWAP_SLOT
Registers the given object in the OSR.
#define FW_DEPRECATED(oldFnName, newFnName, version)
Use this macro when deprecating a function to warn the developer.
Definition: spyLog.hpp:344
void removeIfPresent()
Unregisters the object in the OSR.