1 |
|
|
/** |
2 |
|
|
* This file is part of the CernVM File System. |
3 |
|
|
* |
4 |
|
|
* The SimpleCatalogManager is a simplistic concrete implementation of the |
5 |
|
|
* AbstractCatalogManager and allows for easy-to-use access to the catalog |
6 |
|
|
* structure of a given repository. This class is tailored for simplicity, not |
7 |
|
|
* for performance. Have a look into ClientCatalogManager if you are working |
8 |
|
|
* on the CVMFS client. |
9 |
|
|
*/ |
10 |
|
|
|
11 |
|
|
#ifndef CVMFS_CATALOG_MGR_RO_H_ |
12 |
|
|
#define CVMFS_CATALOG_MGR_RO_H_ |
13 |
|
|
|
14 |
|
|
#include <string> |
15 |
|
|
|
16 |
|
|
#include "catalog_mgr.h" |
17 |
|
|
|
18 |
|
|
namespace download { |
19 |
|
|
class DownloadManager; |
20 |
|
|
} |
21 |
|
|
|
22 |
|
|
namespace manifest { |
23 |
|
|
class Manifest; |
24 |
|
|
} |
25 |
|
|
|
26 |
|
|
namespace perf { |
27 |
|
|
class Statistics; |
28 |
|
|
} |
29 |
|
|
|
30 |
|
|
namespace catalog { |
31 |
|
|
|
32 |
✗✗✗✓
|
18 |
class SimpleCatalogManager : public AbstractCatalogManager<Catalog> { |
33 |
|
|
public: |
34 |
|
16 |
SimpleCatalogManager( |
35 |
|
|
const shash::Any &base_hash, |
36 |
|
|
const std::string &stratum0, |
37 |
|
|
const std::string &dir_temp, |
38 |
|
|
download::DownloadManager *download_manager, |
39 |
|
|
perf::Statistics *statistics, |
40 |
|
|
const bool manage_catalog_files = false) |
41 |
|
|
: AbstractCatalogManager<Catalog>(statistics) |
42 |
|
|
, base_hash_(base_hash) |
43 |
|
|
, stratum0_(stratum0) |
44 |
|
|
, dir_temp_(dir_temp) |
45 |
|
|
, download_manager_(download_manager) |
46 |
|
16 |
, manage_catalog_files_(manage_catalog_files) { } |
47 |
|
|
|
48 |
|
|
protected: |
49 |
|
|
virtual LoadError LoadCatalog(const PathString &mountpoint, |
50 |
|
|
const shash::Any &hash, |
51 |
|
|
std::string *catalog_path, |
52 |
|
|
shash::Any *catalog_hash); |
53 |
|
|
virtual Catalog* CreateCatalog(const PathString &mountpoint, |
54 |
|
|
const shash::Any &catalog_hash, |
55 |
|
|
Catalog *parent_catalog); |
56 |
|
|
|
57 |
|
16 |
const shash::Any& base_hash() const { return base_hash_; } |
58 |
✗✓ |
8 |
void set_base_hash(const shash::Any &hash) { base_hash_ = hash; } |
59 |
|
7 |
const std::string& dir_temp() const { return dir_temp_; } |
60 |
|
|
|
61 |
|
|
/** |
62 |
|
|
* Makes the given path relative to the catalog structure |
63 |
|
|
* Pathes coming out here can be used for lookups in catalogs |
64 |
|
|
* @param relativePath the path to be mangled |
65 |
|
|
* @return the mangled path |
66 |
|
|
*/ |
67 |
|
84 |
inline std::string MakeRelativePath(const std::string &relative_path) const { |
68 |
✓✓✗✗ ✓✓ |
84 |
return (relative_path == "") ? "" : "/" + relative_path; |
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
private: |
72 |
|
|
shash::Any base_hash_; |
73 |
|
|
std::string stratum0_; |
74 |
|
|
std::string dir_temp_; |
75 |
|
|
download::DownloadManager *download_manager_; |
76 |
|
|
const bool manage_catalog_files_; |
77 |
|
|
}; // class SimpleCatalogManager |
78 |
|
|
|
79 |
|
|
} // namespace catalog |
80 |
|
|
|
81 |
|
|
#endif // CVMFS_CATALOG_MGR_RO_H_ |