source: src/base/command_list.cpp@ 06e153

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

Fixed some warnings.

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

  • Property mode set to 100644
File size: 2.3 KB
RevLine 
[48b662]1/**
2 * @file command_list.cpp
3 * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
4 * @date Tue Apr 5 20:15:06 2011
[dfed1c]5 *
[48b662]6 */
7
8#ifdef HAVE_CONFIG_H
9#include <config.h>
10#endif
11
[dfed1c]12#ifdef DEBUG_BARRIER
13#ifdef HAVE_MPI
14#include <mpi.h>
[ac6d04]15#ifdef HAVE_MARMOT
16#include <enhancempicalls.h>
17#include <sourceinfompicalls.h>
18#endif
[dfed1c]19#endif
20#endif
21
[76e019]22#include <cstdio>
23
[48b662]24#include "base/command.hpp"
[dfed1c]25#include "base/command_factory.hpp"
[48b662]26#include "base/command_list.hpp"
[894a5f]27#include "base/timer.hpp"
[48b662]28#include "base/defs.hpp"
29#include "mg.hpp"
30
31using namespace VMG;
32
33Request CommandList::ExecuteList()
34{
35 Request request;
36 Request final_request = (commands.size() == 0 ? StopCycleNow : Continue);
37
38 for (CommandList::iterator iter=commands.begin(); iter!=commands.end(); ++iter) {
39
40#ifdef DEBUG
41 const int num_args = (iter->second.size() > 1 ? iter->second.size() : (iter->second[0] == "" ? 0 : 1));
[dfed1c]42 MG::GetCommands().CheckNumberOfArguments(iter->first, num_args);
[48b662]43#endif
44
[dfed1c]45#ifdef DEBUG_BARRIER
46#ifdef HAVE_MPI
47 MPI_Barrier(MPI_COMM_WORLD);
48#endif
[cd0fed]49 MG::GetComm()->PrintStringOnce("Command \"%s\" start", iter->first.c_str());
[dfed1c]50#endif
51
[894a5f]52 Timer::Start(iter->first);
53 request = MG::GetCommands().Get(iter->first)->Run(iter->second);
54 Timer::Stop(iter->first);
[dfed1c]55
56#ifdef DEBUG_BARRIER
57#ifdef HAVE_MPI
58 MPI_Barrier(MPI_COMM_WORLD);
59#endif
[cd0fed]60 MG::GetComm()->PrintStringOnce("Command \"%s\" done", iter->first.c_str());
[dfed1c]61#endif
[48b662]62
63 if (request == StopCycleLater)
64 final_request = StopCycleNow;
65 else if (request == StopCycleNow) {
66 final_request = StopCycleNow;
67 break;
68 }
69 }
70
71 return final_request;
72}
73
74void CommandList::AddCommand(std::string command, std::string arguments)
75{
76 std::vector<std::string> argument_list;
77 size_t pos;
78
79 do {
80 pos = arguments.find(':');
81 argument_list.push_back(arguments.substr(0, pos));
82 arguments.erase(0, pos+1);
83 }while (pos != std::string::npos);
84
85 commands.push_back(std::pair<std::string, std::vector<std::string> >(command, argument_list));
86}
87
88void CommandList::DeleteCommand(const CommandList::iterator& iter)
89{
90 commands.erase(iter);
91}
92
93void CommandList::Print()
94{
95 for (CommandList::iterator iter=commands.begin(); iter!=commands.end(); ++iter)
96 printf("%s\n", (*iter).first.c_str());
97}
98
99void CommandList::Clear()
100{
101 commands.clear();
102}
Note: See TracBrowser for help on using the repository browser.