fw4spl
src/fwData/PointList.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 "fwData/PointList.hpp"
8 
9 #include "fwData/Exception.hpp"
10 #include "fwData/registry/macros.hpp"
11 
12 #include <fwCom/Signal.hpp>
13 #include <fwCom/Signal.hxx>
14 
15 #include <fwCore/base.hpp>
16 
17 fwDataRegisterMacro( ::fwData::PointList );
18 
19 namespace fwData
20 {
21 
22 const ::fwCom::Signals::SignalKeyType PointList::s_POINT_ADDED_SIG = "pointAdded";
23 const ::fwCom::Signals::SignalKeyType PointList::s_POINT_REMOVED_SIG = "pointRemoved";
24 
25 //------------------------------------------------------------------------------
26 
28 {
29  newSignal<PointAddedSignalType>(s_POINT_ADDED_SIG);
30  newSignal<PointRemovedSignalType>(s_POINT_REMOVED_SIG);
31 }
32 
33 //------------------------------------------------------------------------------
34 
36 {
37 }
38 
39 //------------------------------------------------------------------------------
40 
41 void PointList::shallowCopy(const Object::csptr& _source )
42 {
43  PointList::csptr other = PointList::dynamicConstCast(_source);
44  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
45  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
46  + " to " + this->getClassname()), !bool(other) );
47  this->fieldShallowCopy( _source );
48 
49  m_vPoints = other->m_vPoints;
50 }
51 
52 //------------------------------------------------------------------------------
53 
54 void PointList::cachedDeepCopy(const Object::csptr& _source, DeepCopyCacheType& _cache)
55 {
56  PointList::csptr other = PointList::dynamicConstCast(_source);
57  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
58  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
59  + " to " + this->getClassname()), !bool(other) );
60  this->fieldDeepCopy( _source, _cache );
61 
62  m_vPoints.clear();
63  for(const PointListContainer::value_type& point : other->m_vPoints )
64  {
65  Point::sptr newPoint = Point::New();
66  newPoint = ::fwData::Object::copy(point, _cache);
67  m_vPoints.push_back( newPoint );
68  }
69 }
70 
71 //------------------------------------------------------------------------------
72 
73 } // namespace fwData
PointListContainer m_vPoints
Points container.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Implements data exception class.
virtual FWDATA_API ~PointList()
Destructor.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_ADDED_SIG
Signal emitted when a Point is added.
virtual const std::string & getClassname() const override
return full object&#39;s classname with its namespace, i.e. fwCore::BaseObject
FWDATA_API void fieldDeepCopy(const ::fwData::Object::csptr &source)
A deep copy of fields (objects in m_children)
FWDATA_API PointList(::fwData::Object::Key _key)
Constructor.
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 void cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache) override
Defines deep copy.
This class defines a list of points.
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)
FWDATA_API void shallowCopy(const Object::csptr &_source) override
Defines shallow copy.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_REMOVED_SIG
Signal emitted when a Point is added.