/* * MakroAction.hpp * * Created on: Dec 17, 2009 * Author: crueger */ #ifndef MAKROACTION_HPP_ #define MAKROACTION_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include "Actions/Action.hpp" #include "Actions/ActionSequence.hpp" class ActionSequenceTest; namespace MoleCuilder { class ActionRegistry; /** * Action to allow producing bigger Actions from sequences of small actions. * * Destruction of the Actions and the sequence is handled by this class. */ class MakroAction : public Action { //!> grant unit test access to sequence friend class ::ActionSequenceTest; public: MakroAction(const MakroAction &_instance); MakroAction(const ActionTrait &_trait,ActionSequence& _actions); bool canUndo(); bool shouldUndo(); virtual Action* clone(enum QueryOptions flag = Interactive) const; void prepare(enum QueryOptions flag = Interactive); virtual void outputAsCLI(std::ostream &ost) const; virtual void outputAsPython(std::ostream &ost, const std::string &prefix) const; virtual void setOptionValue(const std::string &_token, const std::string &_value); // must be called after all primitive actions are present virtual void prepare(ActionRegistry &AR); // must be called before alle primitive actions are removed virtual void unprepare(ActionRegistry &AR); protected: virtual ~MakroAction(); /** * MakroAction requires an own dialog for global options such as number of loop * iterations, ... besides the dialog from each action in the sequence. * * However, fillDialog() calls ActionSequence::fillAllDialog(). Hence, the dialog * for specific global options must be requested in an distinct function. */ virtual Dialog * fillOwnDialog(Dialog*); /** Pass-thru for removeAction to allow all derived MakroActions to manipulate action sequence. * * \param name name of action to remove * \return true - action removed, false - action not found * \sa ActionSequence::removeAction() */ bool removeAction(const std::string &name); virtual ActionState::ptr performCall(); virtual ActionState::ptr performUndo(ActionState::ptr); virtual ActionState::ptr performRedo(ActionState::ptr); void setLoop(unsigned int _loop); private: /** fillDialog is used to spawn sequence queries, hence must not be modified by * derived MakroActions. */ Dialog *fillDialog(Dialog *dialog); //!> this points to the instance of a specific MakroAction, we need to ref for callAll() ActionSequence &actions; }; } #endif /* MAKROACTION_HPP_ */