fw4spl
fwData/Mesh/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/String.hpp>
8 #include <fwAtoms/Map.hpp>
9 #include <fwAtomsPatch/StructuralCreatorDB.hpp>
10 
11 #include "fwStructuralPatch/fwData/Mesh/V1ToV2.hpp"
12 
13 namespace fwStructuralPatch
14 {
15 
16 namespace fwData
17 {
18 
19 namespace Mesh
20 {
21 
22 V1ToV2::V1ToV2() : ::fwAtomsPatch::IStructuralPatch()
23 {
24  m_originClassname = "::fwData::Mesh";
25  m_targetClassname = "::fwData::Mesh";
26  m_originVersion = "1";
27  m_targetVersion = "2";
28 }
29 
30 // ----------------------------------------------------------------------------
31 
33 {
34 }
35 
36 // ----------------------------------------------------------------------------
37 
39 {
40 }
41 
42 // ----------------------------------------------------------------------------
43 
44 void V1ToV2::apply( const ::fwAtoms::Object::sptr& previous,
45  const ::fwAtoms::Object::sptr& current,
46  ::fwAtomsPatch::IPatch::NewVersionsType& newVersions)
47 {
48  IStructuralPatch::apply(previous, current, newVersions);
49 
50  // Update object version
51  this->updateVersion(current);
52 
53  // Create helper
54  ::fwAtomsPatch::helper::Object helper(current);
55  helper.addAttribute("array_map", ::fwAtoms::Map::New() );
56 }
57 
58 } // namespace Mesh
59 
60 } // namespace fwData
61 
62 } // namespace fwStructuralPatch
63 
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.
FWATOMSPATCH_API IStructuralPatch()
Constructor.
std::string m_originClassname
Origin classname of the object.
Definition: IPatch.hpp:64
virtual FWSTRUCTURALPATCH_API void apply(const ::fwAtoms::Object::sptr &previous, const ::fwAtoms::Object::sptr &current,::fwAtomsPatch::IPatch::NewVersionsType &newVersions) override
Applies patch.
Contains creators and structural patches.
Definition: Landmarks1.hpp:13
std::string m_originVersion
Origin version of the object.
Definition: IPatch.hpp:67
FWSTRUCTURALPATCH_API ~V1ToV2()
Destructor.
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()
Constructor.
Structural patch to convert a fwData::Mesh from version &#39;1&#39; to version &#39;2&#39;.