fw4spl
patch/fwMDSemanticPatch/src/fwMDSemanticPatch/V2/V03AGO/fwData/Image.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 <fwTools/UUID.hpp>
8 
9 #include <fwAtoms/Object.hpp>
10 #include <fwAtoms/Object.hxx>
11 #include <fwAtoms/Numeric.hpp>
12 #include <fwAtoms/Numeric.hxx>
13 
14 #include <fwAtomsPatch/helper/functions.hpp>
15 
16 #include "fwMDSemanticPatch/V2/V03AGO/fwData/Image.hpp"
17 
18 namespace fwMDSemanticPatch
19 {
20 namespace V2
21 {
22 namespace V03AGO
23 {
24 namespace fwData
25 {
26 
27 Image::Image() : ::fwAtomsPatch::ISemanticPatch()
28 {
29  m_originClassname = "::fwData::Image";
30  m_originVersion = "1";
31  this->addContext("MedicalData", "V2", "V03AGO");
32 }
33 
34 // ----------------------------------------------------------------------------
35 
37 {
38 }
39 
40 // ----------------------------------------------------------------------------
41 
43 {
44 }
45 
46 // ----------------------------------------------------------------------------
47 
49  const ::fwAtoms::Object::sptr& previous,
50  const ::fwAtoms::Object::sptr& current,
51  ::fwAtomsPatch::IPatch::NewVersionsType& newVersions)
52 {
53  ISemanticPatch::apply(previous, current, newVersions);
54  ::fwAtomsPatch::helper::cleanFields( current );
55  ::fwAtomsPatch::helper::Object helper( current );
56 
57  ::fwAtoms::Object::sptr array = ::fwAtoms::Object::dynamicCast(previous->getAttribute("array"));
58  ::fwAtoms::Numeric::sptr nbComponent = ::fwAtoms::Numeric::dynamicCast(array->getAttribute("nb_of_components"));
59 
60  helper.replaceAttribute("nb_components", nbComponent->clone());
61 }
62 
63 // ----------------------------------------------------------------------------
64 
65 } // namespace fwData
66 } // namespace V03AGO
67 } // namespace V2
68 } // namespace fwMDSemanticPatch
69 
Contains the semantic patches within the context "MedicalData".
Contains base functionalities used to transform objects from a version to another.
Definition: Abstract.hpp:16
std::string m_originClassname
Origin classname of the object.
Definition: IPatch.hpp:64
virtual FWATOMSPATCH_API void addContext(const std::string &context, const std::string &originVersion, const std::string &targetVersion)
Add a context where the patch can be applied.
FWATOMSPATCH_API void replaceAttribute(const std::string &name,::fwAtoms::Base::sptr newValue, conditions::Abstract::sptr condition=conditions::Abstract::New())
Replaces an attribute.
std::string m_originVersion
Origin version of the object.
Definition: IPatch.hpp:67
Patch an image from version &#39;V2&#39; to &#39;V03AGO&#39; within &#39;MedicalData&#39; context.
virtual FWMDSEMANTICPATCH_API void apply(const ::fwAtoms::Object::sptr &previous, const ::fwAtoms::Object::sptr &current,::fwAtomsPatch::IPatch::NewVersionsType &newVersions) override
Applies patch.
FWATOMSPATCH_API ISemanticPatch()
Constructor.
Contains the representation of the data objects used in the framework.