fw4spl
SrcLib/core/fwData/src/fwData/List.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/List.hpp"
10 
11 fwDataRegisterMacro( ::fwData::List );
12 
13 namespace fwData
14 {
15 
16 //------------------------------------------------------------------------------
17 
19 {
21 }
22 
23 //------------------------------------------------------------------------------
24 
26 {
28 }
29 
30 //------------------------------------------------------------------------------
31 
32 void List::shallowCopy(const Object::csptr &_source )
33 {
34  List::csptr other = List::dynamicConstCast(_source);
35  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
36  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
37  + " to " + this->getClassname()), !bool(other) );
38  this->fieldShallowCopy( _source );
39  m_container = other->m_container;
40 }
41 
42 //------------------------------------------------------------------------------
43 
44 void List::cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache)
45 {
46  List::csptr other = List::dynamicConstCast(_source);
47  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
48  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
49  + " to " + this->getClassname()), !bool(other) );
50  this->fieldDeepCopy( _source, cache );
51 
52  m_container.clear();
53  for(const ContainerType::value_type &obj : other->m_container)
54  {
55  m_container.push_back( ::fwData::Object::copy(obj, cache) );
56  }
57 }
58 
59 //------------------------------------------------------------------------------
60 
61 }
FWDATA_API void cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache) override
Defines deep copy.
#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.
FWDATA_API List(::fwData::Object::Key key)
Constructor.
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)
This class defines a list of objects.
virtual const std::string & getClassname() const override
return full object&#39;s classname with its namespace, i.e. fwCore::BaseObject
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.
Contains the representation of the data objects used in the framework.
virtual FWDATA_API ~List()
Destructor.
FWDATA_API void fieldShallowCopy(const ::fwData::Object::csptr &source)
A shallow copy of fields (objects in m_children)