#pragma once #ifndef REAL_BUILD # include "externals.hh" #endif // Interface for undo actions class A_UndoAction { public: virtual ~A_UndoAction( ) = 0; virtual void undo( ) const noexcept = 0; virtual void redo( ) const noexcept = 0; }; using P_UndoAction = T_OwnPtr< A_UndoAction >; // Undo manager class T_UndoManager { private: static constexpr uint32_t MaxUndo = 1024; ebcl::T_StaticArray< P_UndoAction , MaxUndo > actions_; uint32_t start_{ 0 }; uint32_t count_{ 0 }; uint32_t pos_{ 0 }; public: T_UndoManager( ) noexcept = default; DEF_MOVE( T_UndoManager ); NO_COPY( T_UndoManager ); // Undo last action void undo( ) noexcept; // Redo last undone action void redo( ) noexcept; // Add an action using a pointer void addAction( P_UndoAction action ) noexcept; // Construct and add an action template< typename T , typename... Args > void add( Args&&... args ) noexcept; }; template< typename T , typename... Args > inline void T_UndoManager::add( Args&&... args ) noexcept { addAction( NewOwned< T >( std::forward< Args >( args ) ... ) ); }