Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
CommandHistory.h
Go to the documentation of this file.
1/**
2 * @file CommandHistory.h
3 * @brief Undo/redo history manager for graph commands
4 * @author Olympe Engine
5 * @details C++14 compliant - no C++17/20 features
6 */
7
8#pragma once
9
10#include "GraphCommand.h"
11#include <vector>
12#include <string>
13
14namespace Olympe
15{
16 /**
17 * @class CommandHistory
18 * @brief Manages undo/redo stacks for graph operations
19 *
20 * Implements a standard undo/redo pattern with two stacks:
21 * - Undo stack: Commands that can be undone
22 * - Redo stack: Commands that were undone and can be redone
23 */
25 {
26 public:
28 ~CommandHistory() = default;
29
30 /**
31 * @brief Execute a new command and add it to history
32 * @param command The command to execute
33 * @return true if command executed successfully
34 */
36
37 /**
38 * @brief Undo the last command
39 * @return true if undo succeeded, false if nothing to undo
40 */
41 bool Undo();
42
43 /**
44 * @brief Redo the last undone command
45 * @return true if redo succeeded, false if nothing to redo
46 */
47 bool Redo();
48
49 /**
50 * @brief Check if undo is available
51 * @return true if there's a command to undo
52 */
53 bool CanUndo() const;
54
55 /**
56 * @brief Check if redo is available
57 * @return true if there's a command to redo
58 */
59 bool CanRedo() const;
60
61 /**
62 * @brief Get description of next undo command
63 * @return Description string or empty if nothing to undo
64 */
65 std::string GetUndoDescription() const;
66
67 /**
68 * @brief Get description of next redo command
69 * @return Description string or empty if nothing to redo
70 */
71 std::string GetRedoDescription() const;
72
73 /**
74 * @brief Clear all undo/redo history
75 */
76 void Clear();
77
78 /**
79 * @brief Get current undo stack size
80 */
81 size_t GetUndoStackSize() const { return m_undoStack.size(); }
82
83 /**
84 * @brief Get current redo stack size
85 */
86 size_t GetRedoStackSize() const { return m_redoStack.size(); }
87
88 private:
89 std::vector<GraphCommandPtr> m_undoStack;
90 std::vector<GraphCommandPtr> m_redoStack;
91 };
92
93} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Base command class for undo/redo in graph operations.
Manages undo/redo stacks for graph operations.
size_t GetUndoStackSize() const
Get current undo stack size.
bool CanRedo() const
Check if redo is available.
std::string GetRedoDescription() const
Get description of next redo command.
bool Undo()
Undo the last command.
std::vector< GraphCommandPtr > m_redoStack
bool ExecuteCommand(GraphCommandPtr command)
Execute a new command and add it to history.
void Clear()
Clear all undo/redo history.
bool Redo()
Redo the last undone command.
std::vector< GraphCommandPtr > m_undoStack
bool CanUndo() const
Check if undo is available.
size_t GetRedoStackSize() const
Get current redo stack size.
std::string GetUndoDescription() const
Get description of next undo command.
< Provides AssetID and INVALID_ASSET_ID
std::unique_ptr< GraphCommand > GraphCommandPtr