// PresAction.hpp

#ifndef presaction_hpp
#define presaction_hpp

#include <vector>

class PresAction;
//class PresActionContext;

class PrescribbleNote;

/**
 * PresAction 
 * - a potentially undoable/redoable action in a PrescribbleNote
 */
class PresAction {
public:
    
    struct Context;

    virtual ~PresAction(){}

    virtual bool undo( Context *a_pContext = 0 ) = 0;
    virtual bool redo( Context *a_pContext = 0 ) = 0;
    virtual bool isDone() = 0;
};


class PresActionBase : public PresAction {
protected:
    PrescribbleNote *m_pNote;
    bool m_done;
public:
    PresActionBase( PrescribbleNote *a_pNote )
        : m_pNote( a_pNote ), m_done(false)
        {}
    virtual bool undo( Context *a_pContext = 0 ){return false;}
    virtual bool redo( Context *a_pContext = 0 ){return false;}
    virtual bool isDone(){return m_done;}
};


/**
 * Paramter Object pattern for the actions.
 */
struct PresAction::Context {
};

class PresComplexAction : public PresActionBase
{
    typedef std::vector<PresAction*> ActionList;
protected:
    ActionList m_subactions;
public:

    PresComplexAction() : PresActionBase(0){}
    virtual ~PresComplexAction();

    virtual bool undo( Context *a_pContext = 0 );
    virtual bool redo( Context *a_pContext = 0 );
    void add( PresAction& );

    bool empty(){ return m_subactions.empty(); }
};


#endif
