fw4spl
core/fwMedData/src/fwMedData/SeriesDB.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 "fwMedData/Series.hpp"
8 #include "fwMedData/SeriesDB.hpp"
9 
10 #include <fwCom/Signal.hpp>
11 #include <fwCom/Signal.hxx>
12 
13 #include <fwData/Exception.hpp>
14 #include <fwData/registry/macros.hpp>
15 
16 
17 fwDataRegisterMacro( ::fwMedData::SeriesDB );
18 
19 namespace fwMedData
20 {
21 
22 const ::fwCom::Signals::SignalKeyType SeriesDB::s_ADDED_SERIES_SIG = "addedSeries";
23 const ::fwCom::Signals::SignalKeyType SeriesDB::s_REMOVED_SERIES_SIG = "removedSeries";
24 
25 //------------------------------------------------------------------------------
26 
28 {
29  newSignal< AddedSeriesSignalType >(s_ADDED_SERIES_SIG);
30  newSignal< RemovedSeriesSignalType >(s_REMOVED_SERIES_SIG);
31 }
32 
33 //------------------------------------------------------------------------------
34 
36 {
37 }
38 
39 //------------------------------------------------------------------------------
40 
41 void SeriesDB::shallowCopy(const ::fwData::Object::csptr &_source)
42 {
43  SeriesDB::csptr other = SeriesDB::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 
48  this->fieldShallowCopy( other );
49 
50  m_container = other->m_container;
51 }
52 
53 //------------------------------------------------------------------------------
54 
55 void SeriesDB::cachedDeepCopy(const ::fwData::Object::csptr &_source, DeepCopyCacheType &cache)
56 {
57  SeriesDB::csptr other = SeriesDB::dynamicConstCast(_source);
58  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
59  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
60  + " to " + this->getClassname()), !bool(other) );
61 
62  this->fieldDeepCopy( other, cache );
63  m_container.clear();
64  m_container.reserve(other->m_container.size());
65  for(const ValueType &series : other->m_container)
66  {
67  m_container.push_back(::fwData::Object::copy(series, cache));
68  }
69 }
70 
71 //------------------------------------------------------------------------------
72 
73 } // namespace fwMedData
74 
Namespace containing medical data.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Implements data exception class.
FWMEDDATA_API SeriesDB(::fwData::Object::Key key)
Constructor.
virtual const std::string & getClassname() const override
return full object&#39;s classname with its namespace, i.e. fwCore::BaseObject
static FWMEDDATA_APIconst::fwCom::Signals::SignalKeyType s_ADDED_SERIES_SIG
Type of signal when series are added.
FWDATA_API void fieldDeepCopy(const ::fwData::Object::csptr &source)
A deep copy of fields (objects in m_children)
static FWMEDDATA_APIconst::fwCom::Signals::SignalKeyType s_REMOVED_SERIES_SIG
Type of signal when series are added.
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.
FWMEDDATA_API void shallowCopy(const ::fwData::Object::csptr &_source) override
Defines shallow copy.
virtual FWMEDDATA_API ~SeriesDB()
Destructor.
ContainerType m_container
Series container.
FWDATA_API void fieldShallowCopy(const ::fwData::Object::csptr &source)
A shallow copy of fields (objects in m_children)
FWMEDDATA_API void cachedDeepCopy(const ::fwData::Object::csptr &_source, DeepCopyCacheType &cache) override
Defines deep copy.