fw4spl
IStructuralPatch.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 <fwAtomsPatch/types.hpp>
8 
9 #include "fwAtomsPatch/IStructuralPatch.hpp"
10 #include "fwAtomsPatch/helper/functions.hpp"
11 
12 namespace fwAtomsPatch
13 {
14 
16 {
17 }
18 
19 // ----------------------------------------------------------------------------
20 
22 {
23 }
24 
25 // ----------------------------------------------------------------------------
26 
28 {
33 }
34 
35 // ----------------------------------------------------------------------------
36 
37 void IStructuralPatch::updateVersion(::fwAtoms::Object::sptr current)
38 {
39  ::fwAtomsPatch::helper::setClassname(current, m_targetClassname);
40  ::fwAtomsPatch::helper::setVersion(current, m_targetVersion);
41 }
42 
43 // ----------------------------------------------------------------------------
44 
45 void IStructuralPatch::apply(const ::fwAtoms::Object::sptr& previous,
46  const ::fwAtoms::Object::sptr& current,
47  ::fwAtomsPatch::IPatch::NewVersionsType& newVersions)
48 {
49  OSLM_ASSERT("The type of the previous object (" << ::fwAtomsPatch::helper::getClassname(
50  previous)
51  << ") does not match the required type (" << m_originClassname << ").",
53  OSLM_ASSERT("The version of the previous object (" << ::fwAtomsPatch::helper::getVersion(
54  previous)
55  << ") does not match the required version (" << m_originVersion << ").",
57 }
58 
59 // ----------------------------------------------------------------------------
60 
61 const std::string& IStructuralPatch::getTargetClassname() const
62 {
63  return m_targetClassname;
64 }
65 
66 // ----------------------------------------------------------------------------
67 
68 const std::string& IStructuralPatch::getTargetVersion() const
69 {
70  return m_targetVersion;
71 }
72 
73 
74 
75 } //fwAtomsPatch
virtual FWATOMSPATCH_API const std::string & getOriginClassname() const
Returns the origin classname of the object.
Definition: IPatch.cpp:32
virtual FWATOMSPATCH_API ~IStructuralPatch()
Destructor.
#define OSLM_ASSERT(message, cond)
work like &#39;assert&#39; from &#39;cassert&#39;, with in addition a message logged by spylog (with FATAL loglevel) ...
Definition: spyLog.hpp:310
FWATOMSPATCH_API std::string getClassname(const ::fwAtoms::Object::sptr &obj)
Get classname of an object.
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 FWATOMSPATCH_API const std::string & getTargetClassname() const
Returns the target classname of the object.
std::string m_originVersion
Origin version of the object.
Definition: IPatch.hpp:67
virtual FWATOMSPATCH_API const std::string & getTargetVersion() const
Returns the target version of the object.
virtual FWATOMSPATCH_API void apply(const std::shared_ptr< ::fwAtoms::Object > &previous, const std::shared_ptr< ::fwAtoms::Object > &current,::fwAtomsPatch::IPatch::NewVersionsType &newVersions) override
Applies the patch to the specified object.
std::string m_targetVersion
Target version.
Base class of all structural patches.
FWATOMSPATCH_API std::string getVersion(const ::fwAtoms::Object::sptr &obj)
Get version of an object.
virtual FWATOMSPATCH_API const std::string & getOriginVersion() const
Returns the origin version of the object.
Definition: IPatch.cpp:39
Base class of all patches.
Definition: IPatch.hpp:27