fw4spl
fwData/Image/V1ToV2.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 <fwAtoms/Numeric.hpp>
8 #include <fwAtoms/Numeric.hxx>
9 #include <fwAtoms/String.hpp>
10 
11 #include "fwStructuralPatch/fwData/Image/V1ToV2.hpp"
12 
13 namespace fwStructuralPatch
14 {
15 
16 namespace fwData
17 {
18 
19 namespace Image
20 {
21 
22 V1ToV2::V1ToV2() : ::fwAtomsPatch::IStructuralPatch()
23 {
24  m_originClassname = "::fwData::Image";
25  m_targetClassname = "::fwData::Image";
26  m_originVersion = "1";
27  m_targetVersion = "2";
28 
29 }
30 
31 // ----------------------------------------------------------------------------
32 
34 {
35 }
36 
37 // ----------------------------------------------------------------------------
38 
40 {
41 }
42 
43 // ----------------------------------------------------------------------------
44 
46  const ::fwAtoms::Object::sptr& previous,
47  const ::fwAtoms::Object::sptr& current,
48  ::fwAtomsPatch::IPatch::NewVersionsType& newVersions)
49 {
50  IStructuralPatch::apply(previous, current, newVersions);
51 
52  // Update object version
53  this->updateVersion(current);
54 
55  // Create helper
56  ::fwAtomsPatch::helper::Object helper(current);
57 
58  helper.addAttribute("nb_components", ::fwAtoms::Numeric::New(1));
59  helper.addAttribute("window_center", ::fwAtoms::Numeric::New(50));
60  helper.addAttribute("window_width", ::fwAtoms::Numeric::New(500));
61 }
62 
63 } // namespace Image
64 
65 } // namespace fwData
66 
67 } // namespace fwStructuralPatch
68 
FWSTRUCTURALPATCH_API V1ToV2()
Constructor.
virtual FWSTRUCTURALPATCH_API void apply(const ::fwAtoms::Object::sptr &previous, const ::fwAtoms::Object::sptr &current,::fwAtomsPatch::IPatch::NewVersionsType &newVersions) override
Applies patch.
FWATOMSPATCH_API void updateVersion(std::shared_ptr< ::fwAtoms::Object > current)
Updates the version of the patched object.
Contains base functionalities used to transform objects from a version to another.
Definition: Abstract.hpp:16
std::string m_targetClassname
Target type.
Structural patch to convert a fwData::Image from version &#39;1&#39; to version &#39;2&#39;.
FWATOMSPATCH_API IStructuralPatch()
Constructor.
std::string m_originClassname
Origin classname of the object.
Definition: IPatch.hpp:64
Contains creators and structural patches.
Definition: Landmarks1.hpp:13
std::string m_originVersion
Origin version of the object.
Definition: IPatch.hpp:67
static Numeric::sptr New(T value)
Build a new numeric type.
Definition: Numeric.hxx:77
FWATOMSPATCH_API void addAttribute(const std::string &name,::fwAtoms::Base::sptr value, conditions::Abstract::sptr condition=conditions::Abstract::New())
Adds a new attribute in the current object.
std::string m_targetVersion
Target version.
Contains the representation of the data objects used in the framework.
FWSTRUCTURALPATCH_API ~V1ToV2()
Destructor.