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:
10 class HistoryItem {
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() const;
22 bool has_current() const;
23
24 bool can_undo() const;
25 bool can_redo() const;
26
27 const std::string &get_undo_comment() const;
28 const std::string &get_redo_comment() const;
29
30 void set_history_max(unsigned int m);
31 void set_never_forgets(bool x);
32
33 void push(std::unique_ptr<const HistoryItem> it);
34 void clear();
35
36private:
37 std::shared_ptr<const HistoryItem> history_current;
38 std::deque<std::shared_ptr<const HistoryItem>> undo_stack;
39 std::deque<std::shared_ptr<const HistoryItem>> redo_stack;
40
41 unsigned int history_max = 50;
42 bool never_forgets = true;
43 void trim();
44};
45} // namespace horizon
Definition changeable.hpp:5
Definition history_manager.hpp:10
Definition history_manager.hpp:8