fw4spl
SemanticPatchDB.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2016.
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_SEMANTICPATCHDB_HPP__
8 #define __FWATOMSPATCH_SEMANTICPATCHDB_HPP__
9 
10 #include <string>
11 #include <vector>
12 #include <map>
13 #include <utility>
14 
15 #include <fwCore/base.hpp>
16 #include <fwCore/mt/types.hpp>
17 
18 #include "fwAtomsPatch/config.hpp"
19 
20 
21 namespace fwAtomsPatch
22 {
23 
24 class ISemanticPatch;
25 
30 class FWATOMSPATCH_CLASS_API SemanticPatchDB
31 {
32 public:
33 
34  typedef SPTR (SemanticPatchDB) sptr;
36  typedef std::pair< std::string, std::string > VersionIDType;
38  typedef std::vector< SPTR(::fwAtomsPatch::ISemanticPatch) > PatchVectorType;
40  typedef std::map< VersionIDType, PatchVectorType > PatchesType;
41 
43  FWATOMSPATCH_API void registerPatch(SPTR(::fwAtomsPatch::ISemanticPatch) patch);
44 
55  FWATOMSPATCH_API SPTR(::fwAtomsPatch::ISemanticPatch) getPatch(
56  const std::string& context,
57  const std::string& originVersion,
58  const std::string& targetVersion,
59  const std::string& objOriginClassname,
60  const std::string& objOriginVersion) const;
61 
63  FWATOMSPATCH_API size_t size() const;
64 
66  FWATOMSPATCH_API static SemanticPatchDB::sptr getDefault();
67 
69  FWATOMSPATCH_API SemanticPatchDB();
70 
72  FWATOMSPATCH_API virtual ~SemanticPatchDB();
73 
74 private:
75 
77  FWATOMSPATCH_API SemanticPatchDB( const SemanticPatchDB &cpy );
78 
80  mutable ::fwCore::mt::ReadWriteMutex m_mutex;
81 
83  PatchesType m_patches;
84 
86  static SemanticPatchDB::sptr s_default;
87 
88 };
89 
90 } // fwAtomsPatch
91 
92 #endif /* __FWATOMSPATCH_SEMANTICPATCHDB_HPP__ */
93 
#define SPTR(_cls_)
STL namespace.
Contextual patch database. All contextual patches are stored in this database.
Contains base functionalities used to transform objects from a version to another.
Definition: Abstract.hpp:16
This namespace fwCore provides common foundations for FW4SPL.
Definition: BaseObject.hpp:16
std::vector< std::shared_ptr< ::fwAtomsPatch::ISemanticPatch > > PatchVectorType
Typedef used to store a list of contextual patches applicable on an object.
std::pair< std::string, std::string > VersionIDType
Typedef used to store the pair type/version of a data structure.
Base class of contextual patches.
std::map< VersionIDType, PatchVectorType > PatchesType
Typedef used to store all the contextual patches.