fw4spl
src/fwData/PlaneList.cpp
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 #include "fwData/registry/macros.hpp"
8 #include "fwData/Exception.hpp"
9 #include "fwData/PlaneList.hpp"
10 
11 #include <fwCom/Signal.hpp>
12 #include <fwCom/Signal.hxx>
13 
14 #include <fwCore/base.hpp>
15 
16 fwDataRegisterMacro( ::fwData::PlaneList );
17 
18 namespace fwData
19 {
20 
21 const ::fwCom::Signals::SignalKeyType PlaneList::s_PLANE_ADDED_SIG = "planeAdded";
22 const ::fwCom::Signals::SignalKeyType PlaneList::s_PLANE_REMOVED_SIG = "planeRemoved";
23 const ::fwCom::Signals::SignalKeyType PlaneList::s_VISIBILITY_MODIFIED_SIG = "visibilityModified";
24 
25 //------------------------------------------------------------------------------
26 
28 {
30  newSignal< PlaneAddedSignalType >(s_PLANE_ADDED_SIG);
31  newSignal< PlaneRemovedSignalType >(s_PLANE_REMOVED_SIG);
32  newSignal< VisibilityModifiedSignalType >(s_VISIBILITY_MODIFIED_SIG);
33 }
34 
35 //------------------------------------------------------------------------------
36 
38 {
40 }
41 
42 //------------------------------------------------------------------------------
43 
44 void PlaneList::shallowCopy(const Object::csptr &_source )
45 {
46  PlaneList::csptr other = PlaneList::dynamicConstCast(_source);
47  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
48  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
49  + " to " + this->getClassname()), !other );
50  this->fieldShallowCopy( _source );
51 
52  this->m_vPlanes = other->m_vPlanes;
53 }
54 
55 //------------------------------------------------------------------------------
56 
57 void PlaneList::cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache)
58 {
59  PlaneList::csptr other = PlaneList::dynamicConstCast(_source);
60  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
61  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
62  + " to " + this->getClassname()), !other );
63  this->fieldDeepCopy( _source, cache );
64 
65  this->m_vPlanes.clear();
66  for(const ::fwData::Plane::sptr& plane : other->m_vPlanes)
67  {
68  Plane::sptr newPlane = ::fwData::Object::copy(plane, cache);
69  this->m_vPlanes.push_back( newPlane );
70  }
71 }
72 
73 } // namespace fwData
74 
75 
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_VISIBILITY_MODIFIED_SIG
Signal emitted when a plane is added.
Definition: PlaneList.hpp:73
#define SLM_TRACE_FUNC()
Trace contextual function signature.
Definition: spyLog.hpp:329
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Implements data exception class.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_PLANE_REMOVED_SIG
Signal emitted when a plane is added.
Definition: PlaneList.hpp:69
virtual const std::string & getClassname() const override
return full object&#39;s classname with its namespace, i.e. fwCore::BaseObject
Definition: PlaneList.hpp:30
PlaneListContainer m_vPlanes
Planes container.
Definition: PlaneList.hpp:81
FWDATA_API void shallowCopy(const Object::csptr &_source) override
Defines shallow copy.
FWDATA_API void fieldDeepCopy(const ::fwData::Object::csptr &source)
A deep copy of fields (objects in m_children)
static FWDATA_API::fwData::Object::sptr copy(const ::fwData::Object::csptr &source)
return a copy of the source. if source is a null pointer, return a null pointer.
FWDATA_API PlaneList(::fwData::Object::Key key)
Constructor.
This class defines a list of planes.
Definition: PlaneList.hpp:26
Contains the representation of the data objects used in the framework.
FWDATA_API void fieldShallowCopy(const ::fwData::Object::csptr &source)
A shallow copy of fields (objects in m_children)
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_PLANE_ADDED_SIG
Signal emitted when a plane is added.
Definition: PlaneList.hpp:65
virtual FWDATA_API ~PlaneList()
Destructor.
FWDATA_API void cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache) override
Defines deep copy.