Snapshots in Action manager

This commit is contained in:
brunoherbelin
2021-04-15 22:50:28 +02:00
parent 11df7c28b4
commit 2d4a6d1fe6
5 changed files with 242 additions and 134 deletions

View File

@@ -1,11 +1,13 @@
#ifndef ACTIONMANAGER_H
#define ACTIONMANAGER_H
#include <list>
#include <atomic>
#include <tinyxml2.h>
class Action
{
// Private Constructor
@@ -23,25 +25,36 @@ public:
}
void store(const std::string &label);
void clear();
void undo();
void redo();
void stepTo(uint target);
inline uint current() const { return step_; }
inline uint max() const { return max_step_; }
inline uint current() const { return history_step_; }
inline uint max() const { return history_max_step_; }
std::string label(uint s) const;
void snapshot(const std::string &label);
inline std::list<uint64_t> snapshots() const { return snapshots_; }
std::string label(uint64_t s) const;
void restore(uint64_t snapshotid);
void remove (uint64_t snapshotid);
void setLabel (uint64_t snapshotid, const std::string &label);
private:
void restore(uint target);
tinyxml2::XMLDocument xmlDoc_;
uint step_;
uint max_step_;
tinyxml2::XMLDocument history_doc_;
uint history_step_;
uint history_max_step_;
std::atomic<bool> locked_;
tinyxml2::XMLDocument snapshots_doc_;
std::list<uint64_t> snapshots_;
};