CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
reflog_sql.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_REFLOG_SQL_H_
6 #define CVMFS_REFLOG_SQL_H_
7 
8 #include <string>
9 
10 #include "crypto/hash.h"
11 #include "sql.h"
12 
13 class ReflogDatabase : public sqlite::Database<ReflogDatabase> {
14  public:
15  static const float kLatestSchema;
16  static const float kLatestSupportedSchema;
17  // backwards-compatible schema changes
18  static const unsigned kLatestSchemaRevision;
19 
20  static const std::string kFqrnKey;
21 
22  bool CreateEmptyDatabase();
23 
26  bool CompactDatabase() const { return true; } // no implementation specific
27  // database compaction.
28 
29  bool InsertInitialValues(const std::string &repo_name);
30 
31  protected:
32  // TODO(rmeusel): C++11 - constructor inheritance
34  ReflogDatabase(const std::string &filename,
35  const OpenMode open_mode) :
36  sqlite::Database<ReflogDatabase>(filename, open_mode) {}
37 };
38 
39 
40 //------------------------------------------------------------------------------
41 
42 
43 class SqlReflog : public sqlite::Sql {
44  public:
50  };
51 
53 };
54 
55 
56 class SqlInsertReference : public SqlReflog {
57  public:
58  explicit SqlInsertReference(const ReflogDatabase *database);
59  bool BindReference(const shash::Any &reference_hash,
60  const ReferenceType type);
61 };
62 
63 
64 class SqlCountReferences : public SqlReflog {
65  public:
66  explicit SqlCountReferences(const ReflogDatabase *database);
67  uint64_t RetrieveCount();
68 };
69 
70 
71 class SqlListReferences : public SqlReflog {
72  public:
73  explicit SqlListReferences(const ReflogDatabase *database);
74  bool BindType(const ReferenceType type);
75  bool BindOlderThan(const uint64_t timestamp);
76  shash::Any RetrieveHash() const;
77 };
78 
79 
80 class SqlRemoveReference : public SqlReflog {
81  public:
82  explicit SqlRemoveReference(const ReflogDatabase *database);
83  bool BindReference(const shash::Any &reference_hash,
84  const ReferenceType type);
85 };
86 
87 
89  public:
90  explicit SqlContainsReference(const ReflogDatabase *database);
91  bool BindReference(const shash::Any &reference_hash,
92  const ReferenceType type);
93  bool RetrieveAnswer();
94 };
95 
96 
97 class SqlGetTimestamp : public SqlReflog {
98  public:
99  explicit SqlGetTimestamp(const ReflogDatabase *database);
100  bool BindReference(const shash::Any &reference_hash,
101  const ReferenceType type);
102  uint64_t RetrieveTimestamp();
103 };
104 
105 #endif // CVMFS_REFLOG_SQL_H_
bool CheckSchemaCompatibility()
Definition: reflog_sql.cc:34
bool BindOlderThan(const uint64_t timestamp)
Definition: reflog_sql.cc:134
uint64_t RetrieveTimestamp()
Definition: reflog_sql.cc:204
const std::string & filename() const
Definition: sql.h:148
static const std::string kFqrnKey
Definition: reflog_sql.h:20
shash::Any RetrieveHash() const
Definition: reflog_sql.cc:142
SqlListReferences(const ReflogDatabase *database)
Definition: reflog_sql.cc:123
SqlGetTimestamp(const ReflogDatabase *database)
Definition: reflog_sql.cc:191
bool BindType(const ReferenceType type)
Definition: reflog_sql.cc:130
bool BindReference(const shash::Any &reference_hash, const ReferenceType type)
Definition: reflog_sql.cc:99
Database(const std::string &filename, const OpenMode open_mode)
bool BindReference(const shash::Any &reference_hash, const ReferenceType type)
Definition: reflog_sql.cc:174
uint64_t RetrieveCount()
Definition: reflog_sql.cc:115
bool CompactDatabase() const
Definition: reflog_sql.h:26
bool LiveSchemaUpgradeIfNecessary()
Definition: reflog_sql.cc:40
static const float kLatestSupportedSchema
Definition: reflog_sql.h:16
static const float kLatestSchema
Definition: reflog_sql.h:15
SqlContainsReference(const ReflogDatabase *database)
Definition: reflog_sql.cc:168
bool BindReference(const shash::Any &reference_hash, const ReferenceType type)
Definition: reflog_sql.cc:157
SqlCountReferences(const ReflogDatabase *database)
Definition: reflog_sql.cc:111
SqlRemoveReference(const ReflogDatabase *database)
Definition: reflog_sql.cc:152
char Suffix
Definition: hash.h:114
bool InsertInitialValues(const std::string &repo_name)
Definition: reflog_sql.cc:46
static const unsigned kLatestSchemaRevision
Definition: reflog_sql.h:18
bool CreateEmptyDatabase()
Definition: reflog_sql.cc:26
bool BindReference(const shash::Any &reference_hash, const ReferenceType type)
Definition: reflog_sql.cc:197
SqlInsertReference(const ReflogDatabase *database)
Definition: reflog_sql.cc:93
ReflogDatabase(const std::string &filename, const OpenMode open_mode)
Definition: reflog_sql.h:34
static shash::Suffix ToSuffix(const ReferenceType type)
Definition: reflog_sql.cc:74