-
Notifications
You must be signed in to change notification settings - Fork 33
/
SnapshotManager.hpp
90 lines (73 loc) · 2.79 KB
/
SnapshotManager.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/* SPDX-FileCopyrightText: 2021 SUSE LLC */
/*
The SnapshotManager class is the central API class for general snapshot
mangement, i.e. for everything which is not bound to a specific transaction
such as listing all snapshots or getting the default snapshot.
Use the Transaction class for creating new snapshots.
*/
#ifndef T_U_SNAPSHOTMANAGER_H
#define T_U_SNAPSHOTMANAGER_H
#include <deque>
#include <map>
#include <memory>
#include <string>
namespace TransactionalUpdate {
class Snapshot;
/**
* @brief The SnapshotManager class is an abstract class and may return different implementations, though
* currently only snapper is implemented as a backend.
* To retrieve an implementation suitable for the running system call
* @example: std::unique_ptr<TransactionalUpdate::SnapshotManager> snapshotMgr = TransactionalUpdate::SnapshotFactory::get();
*/
class SnapshotManager
{
public:
/* Internal methods */
SnapshotManager() = default;
virtual ~SnapshotManager() = default;
virtual std::unique_ptr<Snapshot> create(std::string base, std::string description) = 0;
virtual std::unique_ptr<Snapshot> open(std::string id) = 0;
/**
* @brief getList List of snapshots
* @param columns The columns to show, separated by colons; permitted values are the values accepted by
* the `snapper list --columns` command; if an empty string is given 'number,date,description' are
* used as a default.
* @return The list of snapshots with the processed columns.
*/
virtual std::deque<std::map<std::string, std::string>> getList(std::string columns) = 0;
/**
* @brief getCurrent
* @return Returns the ID of the currently running snapshot.
*/
virtual std::string getCurrent() = 0;
/**
* @brief getDefault
* @return Returns the ID of the currently set default snapshot.
*/
virtual std::string getDefault() = 0;
/**
* @brief deleteSnap Deletes the given snapshot; note that the method may fail if the snapshot
* cannot be deleted because it is currently in use or set as the default snapshot, so
* getCurrent() and getDefault() should be used beforehand.
* @param id ID of the snapshot to be deleted.
*/
virtual void deleteSnap(std::string id) = 0;
/**
* @brief Set the given snapshot ID as the default snapshot ID
* @param id ID of the snapshot to be rolled back to.
*/
virtual void rollbackTo(std::string id) = 0;
};
class SnapshotFactory {
public:
/**
* @brief get See example for SnapshotManager
* @return Returns a SnapshotManager instance suitable for the system
*/
static std::unique_ptr<SnapshotManager> get();
};
struct SnapshotTable {
};
} // namespace TransactionalUpdate
#endif // T_U_SNAPSHOTMANAGER_H