fw4spl
VersionsManager.hpp
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 #ifndef __FWATOMSPATCH_VERSIONSMANAGER_HPP__
8 #define __FWATOMSPATCH_VERSIONSMANAGER_HPP__
9 
10 #include <map>
11 #include <vector>
12 #include <string>
13 
14 #include <boost/filesystem/path.hpp>
15 
16 #include <fwCore/mt/types.hpp>
17 
18 #include "fwAtomsPatch/VersionsGraph.hpp"
19 #include "fwAtomsPatch/config.hpp"
20 
21 namespace fwAtomsPatch
22 {
23 
30 class FWATOMSPATCH_CLASS_API VersionsManager
31 {
32 
33 public:
34 
38  typedef std::vector< ::boost::filesystem::path > ListPathType;
39  typedef std::map< std::string, VersionsGraph::sptr > VersionsGraphMapType;
42  FWATOMSPATCH_API VersionsManager();
43  FWATOMSPATCH_API ~VersionsManager();
44 
50  FWATOMSPATCH_API VersionsGraph::sptr getGraph(const std::string& context);
51 
59  FWATOMSPATCH_API static void generateNewFile(const ::boost::filesystem::path& filePath, const std::string& context,
60  const std::string& versionName);
61 
67  FWATOMSPATCH_API void buildVersionTable(const std::string& dirPath);
68 
74  FWATOMSPATCH_API void buildLinkTable(const std::string& dirPath);
75 
77  static SPTR(VersionsManager) getDefault() {
78  return s_default;
79  }
80 
81 private:
82 
83 
88  FWATOMSPATCH_API static ::fwAtomsPatch::VersionDescriptor getVersion(
89  const ::boost::filesystem::path& filePath);
90 
95  FWATOMSPATCH_API static ::fwAtomsPatch::LinkDescriptor getLink(
96  const ::boost::filesystem::path& filePath);
97 
102  FWATOMSPATCH_API void generateVersionsGraph();
103 
105  ::fwCore::mt::ReadWriteMutex m_versionMutex;
106 
108  ::fwCore::mt::ReadWriteMutex m_linkMutex;
109 
111  ::fwCore::mt::ReadWriteMutex m_graphMutex;
112 
114  ListPathType m_versionTable;
115 
117  ListPathType m_linkTable;
118 
120  VersionsGraphMapType m_versionsGraphMap;
121 
123  FWATOMSPATCH_API static SPTR(VersionsManager) s_default;
124 };
125 
126 } // fwAtomsPatch
127 
128 #endif /* __FWATOMSPATCH_VERSIONSMANAGER_HPP__ */
#define SPTR(_cls_)
::boost::shared_mutex ReadWriteMutex
Defines a single writer, multiple readers mutex.
Contains base functionalities used to transform objects from a version to another.
Definition: Abstract.hpp:16
Maintains a table of object versions and a table of links between objects.