Horizon
Loading...
Searching...
No Matches
history_manager.hpp
1#pragma once
2#include <string>
3#include <memory>
4#include <deque>
5#include "changeable.hpp"
6
7namespace horizon {
8class HistoryManager : public Changeable {
9public:
11 public:
12 HistoryItem(const std::string &c) : comment(c)
13 {
14 }
15 const std::string comment;
16 virtual ~HistoryItem() = default;
17 };
18
19 const HistoryItem &undo();
20 const HistoryItem &redo();
21 const HistoryItem &get_current();
22
23 bool can_undo() const;
24 bool can_redo() const;
25
26 const std::string &get_undo_comment() const;
27 const std::string &get_redo_comment() const;
28
29 void set_history_max(unsigned int m);
30 void set_never_forgets(bool x);
31
32 void push(std::unique_ptr<const HistoryItem> it);
33 void clear();
34
35private:
36 std::shared_ptr<const HistoryItem> history_current;
37 std::deque<std::shared_ptr<const HistoryItem>> undo_stack;
38 std::deque<std::shared_ptr<const HistoryItem>> redo_stack;
39
40 unsigned int history_max = 50;
41 bool never_forgets = true;
42 void trim();
43};
44} // namespace horizon
Definition changeable.hpp:5
Definition history_manager.hpp:10
Definition history_manager.hpp:8