Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
GraphCommand.h
Go to the documentation of this file.
1/**
2 * @file GraphCommand.h
3 * @brief Base command class for undo/redo in graph operations
4 * @author Olympe Engine
5 * @details C++14 compliant - no C++17/20 features
6 */
7
8#pragma once
9
10#include <string>
11#include <memory>
12
13namespace Olympe
14{
15 /**
16 * @class GraphCommand
17 * @brief Abstract base class for all graph modification commands
18 *
19 * Implements the Command Pattern for undo/redo functionality.
20 * Each command represents a single, undoable action on the graph.
21 */
23 {
24 public:
25 virtual ~GraphCommand() = default;
26
27 /**
28 * @brief Execute the command (forward operation)
29 * @return true if execution succeeded
30 */
31 virtual bool Execute() = 0;
32
33 /**
34 * @brief Undo the command (reverse operation)
35 * @return true if undo succeeded
36 */
37 virtual bool Undo() = 0;
38
39 /**
40 * @brief Get a human-readable description of the command
41 * @return Command description for UI display (e.g., "Create Action Node")
42 */
43 virtual std::string GetDescription() const = 0;
44
45 /**
46 * @brief Check if this command can be merged with another
47 * Used for combining consecutive similar commands (e.g., multiple position changes)
48 * @param other The other command to potentially merge with
49 * @return true if commands can be merged
50 */
51 virtual bool CanMergeWith(const GraphCommand& other) const
52 {
53 return false; // Default: no merging
54 }
55
56 /**
57 * @brief Merge this command with another
58 * Called only if CanMergeWith returned true
59 * @param other The command to merge with
60 * @return true if merge succeeded
61 */
62 virtual bool MergeWith(const GraphCommand& other)
63 {
64 return false; // Default: no merging
65 }
66 };
67
68 using GraphCommandPtr = std::unique_ptr<GraphCommand>;
69
70} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Abstract base class for all graph modification commands.
virtual bool Undo()=0
Undo the command (reverse operation)
virtual bool CanMergeWith(const GraphCommand &other) const
Check if this command can be merged with another Used for combining consecutive similar commands (e....
virtual bool Execute()=0
Execute the command (forward operation)
virtual ~GraphCommand()=default
virtual bool MergeWith(const GraphCommand &other)
Merge this command with another Called only if CanMergeWith returned true.
virtual std::string GetDescription() const =0
Get a human-readable description of the command.
< Provides AssetID and INVALID_ASSET_ID
std::unique_ptr< GraphCommand > GraphCommandPtr