1 // Aseprite 2 // Copyright (C) 2001-2018 David Capello 3 // 4 // This program is distributed under the terms of 5 // the End-User License Agreement for Aseprite. 6 7 #ifndef APP_CMD_H_INCLUDED 8 #define APP_CMD_H_INCLUDED 9 #pragma once 10 11 #include "base/disable_copying.h" 12 #include "undo/undo_command.h" 13 14 #include <string> 15 16 namespace app { 17 18 class Context; 19 20 class Cmd : public undo::UndoCommand { 21 public: 22 Cmd(); 23 virtual ~Cmd(); 24 25 void execute(Context* ctx); 26 27 // undo::UndoCommand impl 28 void undo() override; 29 void redo() override; 30 void dispose() override; 31 32 std::string label() const; 33 size_t memSize() const; 34 context()35 Context* context() const { return m_ctx; } 36 37 protected: 38 virtual void onExecute(); 39 virtual void onUndo(); 40 virtual void onRedo(); 41 virtual void onFireNotifications(); 42 virtual std::string onLabel() const; 43 virtual size_t onMemSize() const; 44 45 private: 46 Context* m_ctx; 47 #if _DEBUG 48 enum class State { NotExecuted, Executed, Undone, Redone }; 49 State m_state; 50 #endif 51 52 DISABLE_COPYING(Cmd); 53 }; 54 55 } // namespace app 56 57 #endif 58