#pragma once

class Action
{
public:
    enum class Direction { Undo, Redo } m_direction = Direction::Undo;
    bool was_saved = false;
    Direction reverse_direction() const { return (Direction)(1 - (int)m_direction); }
    virtual void run() = 0;
    virtual void undo() = 0;
    virtual Action* get_redo() = 0;
    virtual size_t memory() = 0;
    virtual ~Action() = default;
    Action() = default;
};

class ActionManager
{
public:
    static ActionManager I;
    std::stack<std::unique_ptr<Action>> m_actions;
    std::stack<std::unique_ptr<Action>> m_redos;
    size_t m_memory = 0;
    static void add(Action* action);
    static void undo();
    static void redo();
    static void clear();
    static bool empty()
    {
        return I.m_actions.empty();
    }
};
