fw4spl
DefaultPatcher.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
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 #ifndef __FWATOMSPATCH_PATCHER_DEFAULTPATCHER_HPP__
8 #define __FWATOMSPATCH_PATCHER_DEFAULTPATCHER_HPP__
9 
10 #include "fwAtomsPatch/config.hpp"
11 #include "fwAtomsPatch/helper/Object.hpp"
12 #include "fwAtomsPatch/patcher/IPatcher.hpp"
13 #include "fwAtomsPatch/VersionDescriptor.hpp"
14 
15 #include <fwAtoms/Blob.hpp>
16 #include <fwAtoms/Boolean.hpp>
17 #include <fwAtoms/Map.hpp>
18 #include <fwAtoms/Numeric.hpp>
19 #include <fwAtoms/Object.hpp>
20 #include <fwAtoms/Sequence.hpp>
21 #include <fwAtoms/String.hpp>
22 
23 #include <fwCore/base.hpp>
24 
25 #include <string>
26 
27 namespace fwAtomsPatch
28 {
29 
30 namespace patcher
31 {
32 
36 class FWATOMSPATCH_CLASS_API DefaultPatcher : public IPatcher
37 {
38 
39 public:
40 
42  ::fwAtomsPatch::patcher::factory::New< DefaultPatcher >);
43 
46 
48  FWATOMSPATCH_API virtual ~DefaultPatcher();
49 
51  FWATOMSPATCH_API virtual ::fwAtoms::Object::sptr transformObject(::fwAtoms::Object::sptr object,
52  const std::string& context,
53  const std::string& currentVersion,
54  const std::string& targetVersion) override;
55 
56 protected:
57 
59  FWATOMSPATCH_API virtual ::fwAtoms::Object::sptr processStructuralObject(::fwAtoms::Object::sptr current);
60 
62  FWATOMSPATCH_API virtual ::fwAtoms::Object::sptr processContextualObject(::fwAtoms::Object::sptr current);
63 
65  FWATOMSPATCH_API virtual ::fwAtoms::Base::sptr processBase(::fwAtoms::Base::sptr base);
66 
68  FWATOMSPATCH_API virtual ::fwAtoms::Map::sptr processMapping(::fwAtoms::Map::sptr map);
69 
71  FWATOMSPATCH_API virtual ::fwAtoms::Sequence::sptr processSequence(::fwAtoms::Sequence::sptr seq);
72 
74  FWATOMSPATCH_API virtual ::fwAtoms::Object::sptr applyStructuralPatch(::fwAtoms::Object::sptr previous,
75  ::fwAtoms::Object::sptr current);
76 
78  FWATOMSPATCH_API virtual ::fwAtoms::Object::sptr applyContextualPatch(::fwAtoms::Object::sptr previous,
79  ::fwAtoms::Object::sptr current);
81  FWATOMSPATCH_API bool isKnown(const ::fwAtoms::Base::sptr& base);
82 
84  enum PassType { Structural, Contextual };
85 
89  typedef std::map<std::string, ::fwAtoms::Object::sptr > CacheType;
90  typedef std::map< ::fwAtoms::Object::sptr, ::fwAtoms::Object::sptr > NewVersionsType;
93  PassType m_pass;
95 
97  CacheType m_cache;
98 
100  NewVersionsType m_newVersions;
101 
103  ::fwAtoms::Object::sptr m_object;
104 
106  std::string m_context;
107 
109  ::fwAtomsPatch::VersionsGraph::NodeIDType m_currentVersion;
110 
112  ::fwAtomsPatch::VersionsGraph::NodeIDType m_targetVersion;
113 
115  ::fwAtomsPatch::VersionsGraph::sptr m_versionsGraph;
116 
117 };
118 
119 } // namespace patcher
120 
121 } // namespace fwAtomsPatch
122 
123 #endif /* __FWATOMSPATCH_PATCHER_DEFAULTPATCHER_HPP__ */
::fwAtomsPatch::VersionsGraph::sptr m_versionsGraph
Versions graph.
NewVersionsType m_newVersions
Map used to store the correspondence between an old object and a new one.
Contains base functionalities used to transform objects from a version to another.
Definition: Abstract.hpp:16
::fwAtomsPatch::VersionsGraph::NodeIDType m_currentVersion
Current object version.
std::string m_context
Context where the object is patched.
::fwAtomsPatch::VersionsGraph::NodeIDType m_targetVersion
Target version for current object.
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
Base class of all patchers.
Definition: IPatcher.hpp:40
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
CacheType m_cache
Cache used to store objects which have already been patched (in order to avoid patching the same obje...
::fwAtoms::Object::sptr m_object
Current object being patched.