#ifndef ACTION__H #define ACTION__H #include <functional> #include <string> #include <vector> #include "Config.hpp" class Action { public : enum Type { Push, Pop, Write, MoveWord, MoveChar, AddLines, Check }; enum Object { Buffer, Stack }; private : Type type; std::function<void(Config & config, Action & action)> apply; std::function<void(Config & config, Action & action)> undo; std::function<bool(Config & config, Action & action)> appliable; std::vector<std::string> data; public : Action(Type type, std::function<void(Config & config, Action & action)> apply, std::function<void(Config & config, Action & action)> undo, std::function<bool(Config & config, Action & action)> appliable); public : static Object str2object(const std::string & s); static Action addLinesIfNeeded(int nbLines); static Action moveWordIndex(int movement); static Action moveCharacterIndex(int movement); static Action addHypothesis(const std::string & colName, std::size_t lineIndex, const std::string & hypothesis); static Action addHypothesisRelative(const std::string & colName, Object object, int relativeIndex, const std::string & hypothesis); }; #endif