/** * @file command.hpp * @author Julian Iseringhausen * @date Tue Apr 5 19:21:37 2011 * * @brief Base class for commands that can be added to several * command lists. Commands in the lists COMMANDLIST_INIT, * COMMAND_LIST_LOOP and COMMANDLIST_FINALIZE will be * executed automatically. However the user may create * other command lists and execute them manually. * * */ #ifndef COMMAND_HPP_ #define COMMAND_HPP_ #include #include #include "base/defs.hpp" #include "mg.hpp" #define CREATE_INITIALIZER(a) void Initialize##a() { \ VMG::MG::GetFactory().RegisterCommand(new VMG::CommandProxy); \ } namespace VMG { class Command { public: typedef std::vector argument_vector; ///< Holds arguments for execution virtual ~Command() {} /** * This function will be executed when command flow in a certain command * list reaches this command. * * @param arguments Holds arguments for execution as strings. When using multiple arguments, * ':' serves as the separator. * * @return Certain commands may want to change the following command flow of the command list * (e.g. stopping criteria). This can be achieved by returning either "StopNow", which * stops execution right after this command or by returning "StopLater", which will stop * execution of a loop after the remaining commands have also been executed. */ virtual Request Run(Command::argument_vector arguments) = 0; }; } #endif /* COMMAND_HPP_ */