CernVM-FS  2.13.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
catalog_virtual.h
Go to the documentation of this file.
1 
4 #ifndef CVMFS_CATALOG_VIRTUAL_H_
5 #define CVMFS_CATALOG_VIRTUAL_H_
6 
7 #include <string>
8 #include <vector>
9 
10 #include "crypto/hash.h"
11 #include "shortstring.h"
12 #include "swissknife_assistant.h"
13 
14 namespace catalog {
15 class WritableCatalogManager;
16 }
17 namespace download {
18 class DownloadManager;
19 }
20 namespace manifest {
21 class Manifest;
22 }
23 struct SyncParameters;
24 
25 
26 namespace catalog {
27 
29  public:
30  static const char *kVirtualPath; // = ".cvmfs"
31  static const int kActionNone; // = 0x00
32  static const int kActionGenerateSnapshots; // = 0x01
33  static const int kActionRemove; // 0x02;
34 
35  static bool ParseActions(const std::string &action_desc, int *actions);
36 
40  SyncParameters *p);
41  void Generate(int actions);
42 
43  private:
44  static const char *kSnapshotDirectory;
45 
46  struct TagId {
47  TagId() { }
48  TagId(const std::string &n, const shash::Any &h) : name(n), hash(h) { }
49  bool operator==(const TagId &other) const {
50  return (this->name == other.name) && (this->hash == other.hash);
51  }
52  bool operator<(const TagId &other) const {
53  if (this->name < other.name) {
54  return true;
55  } else if (this->name > other.name) {
56  return false;
57  }
58  return this->hash < other.hash;
59  }
60 
61  std::string name;
63  };
64 
65  void GenerateSnapshots();
66  void EnsurePresence();
67  void CreateCatalog();
68  void CreateBaseDirectory();
71  void GetSortedTagsFromHistory(std::vector<TagId> *tags);
72  void GetSortedTagsFromCatalog(std::vector<TagId> *tags);
73  void RemoveSnapshot(TagId tag);
74  void InsertSnapshot(TagId tag);
75  void Remove();
76  void RemoveRecursively(const std::string &directory);
77 
80 }; // class VirtualCatalog
81 
82 } // namespace catalog
83 
84 #endif // CVMFS_CATALOG_VIRTUAL_H_
VirtualCatalog(manifest::Manifest *m, download::DownloadManager *d, catalog::WritableCatalogManager *c, SyncParameters *p)
catalog::WritableCatalogManager * catalog_mgr_
const manifest::Manifest * manifest() const
Definition: repository.h:125
void InsertSnapshot(TagId tag)
bool operator<(const TagId &other) const
static bool ParseActions(const std::string &action_desc, int *actions)
TagId(const std::string &n, const shash::Any &h)
void RemoveSnapshot(TagId tag)
void GetSortedTagsFromCatalog(std::vector< TagId > *tags)
static const char * kSnapshotDirectory
static const int kActionRemove
static const int kActionNone
void RemoveRecursively(const std::string &directory)
void GetSortedTagsFromHistory(std::vector< TagId > *tags)
void Generate(int actions)
bool operator==(const TagId &other) const
static const char * kVirtualPath
static const int kActionGenerateSnapshots
swissknife::Assistant assistant_