| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * @file command.hpp
|
|---|
| 3 | * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
|
|---|
| 4 | * @date Tue Apr 5 19:21:37 2011
|
|---|
| 5 | *
|
|---|
| 6 | * @brief Base class for commands that can be added to several
|
|---|
| 7 | * command lists. Commands in the lists COMMANDLIST_INIT,
|
|---|
| 8 | * COMMAND_LIST_LOOP and COMMANDLIST_FINALIZE will be
|
|---|
| 9 | * executed automatically. However the user may create
|
|---|
| 10 | * other command lists and execute them manually.
|
|---|
| 11 | *
|
|---|
| 12 | *
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | #ifndef COMMAND_HPP_
|
|---|
| 16 | #define COMMAND_HPP_
|
|---|
| 17 |
|
|---|
| 18 | #include <string>
|
|---|
| 19 | #include <vector>
|
|---|
| 20 |
|
|---|
| 21 | #include "base/defs.hpp"
|
|---|
| 22 | #include "mg.hpp"
|
|---|
| 23 |
|
|---|
| 24 | #define CREATE_INITIALIZER(a) void Initialize##a() { \
|
|---|
| 25 | VMG::MG::GetFactory().RegisterCommand(new VMG::CommandProxy<a>); \
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | namespace VMG
|
|---|
| 29 | {
|
|---|
| 30 |
|
|---|
| 31 | class Command
|
|---|
| 32 | {
|
|---|
| 33 | public:
|
|---|
| 34 | typedef std::vector<std::string> argument_vector; ///< Holds arguments for execution
|
|---|
| 35 |
|
|---|
| 36 | virtual ~Command() {}
|
|---|
| 37 |
|
|---|
| 38 | /**
|
|---|
| 39 | * This function will be executed when command flow in a certain command
|
|---|
| 40 | * list reaches this command.
|
|---|
| 41 | *
|
|---|
| 42 | * @param arguments Holds arguments for execution as strings. When using multiple arguments,
|
|---|
| 43 | * ':' serves as the separator.
|
|---|
| 44 | *
|
|---|
| 45 | * @return Certain commands may want to change the following command flow of the command list
|
|---|
| 46 | * (e.g. stopping criteria). This can be achieved by returning either "StopNow", which
|
|---|
| 47 | * stops execution right after this command or by returning "StopLater", which will stop
|
|---|
| 48 | * execution of a loop after the remaining commands have also been executed.
|
|---|
| 49 | */
|
|---|
| 50 | virtual Request Run(Command::argument_vector arguments) = 0;
|
|---|
| 51 | };
|
|---|
| 52 |
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | #endif /* COMMAND_HPP_ */
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.