fw4spl
src/fwData/Tag.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/Tag.hpp"
8 
9 #include "fwData/Exception.hpp"
10 #include "fwData/registry/macros.hpp"
11 
12 #include <fwCore/base.hpp>
13 
14 fwDataRegisterMacro( ::fwData::Tag );
15 
16 namespace fwData
17 {
18 //------------------------------------------------------------------------------
19 
21  m_size(0.5)
22 {
23 }
24 
25 //------------------------------------------------------------------------------
26 
28 {
29  if(m_pointList)
30  {
31  m_pointList->getPoints().clear();
32  }
33 }
34 
35 //------------------------------------------------------------------------------
36 
37 void Tag::shallowCopy(const Object::csptr& source )
38 {
39  Tag::csptr other = Tag::dynamicConstCast(source);
40  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
41  "Unable to copy" + (source ? source->getClassname() : std::string("<NULL>"))
42  + " to " + this->getClassname()), !bool(other) );
43  this->fieldShallowCopy( source );
44  m_sType = other->m_sType;
45  m_size = other->m_size;
46  m_pointList = other->m_pointList;
47 }
48 
49 //------------------------------------------------------------------------------
50 
51 void Tag::cachedDeepCopy(const Object::csptr& source, DeepCopyCacheType& cache)
52 {
53  Tag::csptr other = Tag::dynamicConstCast(source);
54  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
55  "Unable to copy" + (source ? source->getClassname() : std::string("<NULL>"))
56  + " to " + this->getClassname()), !bool(other) );
57  this->fieldDeepCopy( source, cache );
58  m_sType = other->m_sType;
59  m_size = other->m_size;
60  m_pointList = ::fwData::Object::copy(other->m_pointList, cache);
61 }
62 
63 } // namespace fwData
This class represent a tag. A tag contains a list of points.
FWDATA_API void cachedDeepCopy(const Object::csptr &source, DeepCopyCacheType &cache) override
Defines deep copy.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Implements data exception class.
::fwData::PointList::sptr m_pointList
list of points
virtual const std::string & getClassname() const override
return full object&#39;s classname with its namespace, i.e. fwCore::BaseObject
std::string m_sType
type of tag
FWDATA_API void fieldDeepCopy(const ::fwData::Object::csptr &source)
A deep copy of fields (objects in m_children)
virtual FWDATA_API ~Tag()
Destructor.
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 Tag(::fwData::Object::Key key)
Constructor.
FWDATA_API void shallowCopy(const Object::csptr &source) override
Defines shallow copy.
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)
double m_size
size of tag