GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/catalog_mgr_ro.h
Date: 2024-04-21 02:33:16
Exec Total Coverage
Lines: 12 12 100.0%
Branches: 8 15 53.3%

Line Branch Exec Source
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 class SimpleCatalogManager : public AbstractCatalogManager<Catalog> {
33 public:
34 31 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 31 : AbstractCatalogManager<Catalog>(statistics)
42 31 , base_hash_(base_hash)
43 31 , stratum0_(stratum0)
44
1/2
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
31 , dir_temp_(dir_temp)
45 31 , download_manager_(download_manager)
46
1/2
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
62 , manage_catalog_files_(manage_catalog_files) { }
47
48 protected:
49 virtual LoadReturn GetNewRootCatalogContext(CatalogContext *result);
50 virtual LoadReturn LoadCatalogByHash(CatalogContext *ctlg_context);
51 virtual Catalog* CreateCatalog(const PathString &mountpoint,
52 const shash::Any &catalog_hash,
53 Catalog *parent_catalog);
54
55 40 const shash::Any& base_hash() const { return base_hash_; }
56 20 void set_base_hash(const shash::Any &hash) { base_hash_ = hash; }
57 29 const std::string& dir_temp() const { return dir_temp_; }
58
59 /**
60 * Makes the given path relative to the catalog structure
61 * Paths coming out here can be used for lookups in catalogs
62 * @param relativePath the path to be mangled
63 * @return the mangled path
64 */
65 321 inline std::string MakeRelativePath(const std::string &relative_path) const {
66
6/11
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 284 times.
✓ Branch 5 taken 37 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 284 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 37 times.
✓ Branch 11 taken 284 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
321 return (relative_path == "") ? "" : "/" + relative_path;
67 }
68
69 private:
70 shash::Any base_hash_;
71 std::string stratum0_;
72 std::string dir_temp_;
73 download::DownloadManager *download_manager_;
74 const bool manage_catalog_files_;
75 }; // class SimpleCatalogManager
76
77 } // namespace catalog
78
79 #endif // CVMFS_CATALOG_MGR_RO_H_
80