source: src/base/command.hpp@ 06e153

Last change on this file since 06e153 was dfed1c, checked in by Julian Iseringhausen <isering@…>, 14 years ago

Major vmg update.

git-svn-id: https://svn.version.fz-juelich.de/scafacos/trunk@1136 5161e1c8-67bf-11de-9fd5-51895aff932f

  • Property mode set to 100644
File size: 2.1 KB
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#ifndef COMMAND_HPP_
15#define COMMAND_HPP_
16
17#include <string>
18#include <vector>
19
20#include "base/defs.hpp"
21#include "base/proxy.hpp"
22#include "comm/comm.hpp"
23#include "mg.hpp"
24
25#ifdef HAVE_MPE
26#include <mpe_log.h>
27#define MPE_EVENT_BEGIN() static int eventID_begin;\
28 static int eventID_end;\
29 if (eventID_begin == 0 && eventID_end == 0) {\
30 MPE_Log_get_state_eventIDs(&eventID_begin, &eventID_end);\
31 if (MG::GetComm()->GlobalRank() == 0)\
32 MPE_Describe_state(eventID_begin, eventID_end, Name(), "pink"); \
33 }\
34 MPE_Log_event(eventID_begin, 0, NULL);
35#define MPE_EVENT_END() MPE_Log_event(eventID_end, 0, NULL);
36#else
37#define MPE_EVENT_BEGIN()
38#define MPE_EVENT_END()
39#endif /* HAVE_MPE */
40
41#define CREATE_INITIALIZER(a) void Initialize##a() { \
42 VMG::MG::GetCommands().Register(new VMG::CommandProxy<a>); \
43 }
44
45namespace VMG
46{
47
48class Command
49{
50public:
51 typedef std::vector<std::string> argument_vector; ///< Holds arguments for execution
52
53 virtual ~Command() {}
54
55 /**
56 * This function will be executed when command flow in a certain command
57 * list reaches this command.
58 *
59 * @param arguments Holds arguments for execution as strings. When using multiple arguments,
60 * ':' serves as the separator.
61 *
62 * @return Certain commands may want to change the following command flow of the command list
63 * (e.g. stopping criteria). This can be achieved by returning either "StopNow", which
64 * stops execution right after this command or by returning "StopLater", which will stop
65 * execution of a loop after the remaining commands have also been executed.
66 */
67 virtual Request Run(Command::argument_vector arguments) = 0;
68};
69
70}
71
72#endif /* COMMAND_HPP_ */
Note: See TracBrowser for help on using the repository browser.