source: ThirdParty/vmg/src/base/command_list.cpp@ 33a694

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes
Last change on this file since 33a694 was 7faa5c, checked in by Frederik Heber <heber@…>, 8 years ago

Merge commit 'de061d9d851257a04e924d4472df4523d33bb08b' as 'ThirdParty/vmg'

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 * vmg - a versatile multigrid solver
3 * Copyright (C) 2012 Institute for Numerical Simulation, University of Bonn
4 *
5 * vmg is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * vmg is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/**
20 * @file command_list.cpp
21 * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
22 * @date Tue Apr 5 20:15:06 2011
23 *
24 */
25
26#ifdef HAVE_CONFIG_H
27#include <libvmg_config.h>
28#endif
29
30#ifdef DEBUG_BARRIER
31#ifdef HAVE_MPI
32#include <mpi.h>
33#ifdef HAVE_MARMOT
34#include <enhancempicalls.h>
35#include <sourceinfompicalls.h>
36#endif
37#endif
38#endif
39
40#include <cstdio>
41
42#include "base/command.hpp"
43#include "base/command_factory.hpp"
44#include "base/command_list.hpp"
45#include "base/timer.hpp"
46#include "base/defs.hpp"
47#include "mg.hpp"
48
49using namespace VMG;
50
51Request CommandList::ExecuteList()
52{
53 Request request;
54 Request final_request = (commands.size() == 0 ? StopCycleNow : Continue);
55
56 for (CommandList::iterator iter=commands.begin(); iter!=commands.end(); ++iter) {
57
58#ifdef DEBUG
59 const int num_args = (iter->second.size() > 1 ? iter->second.size() : (iter->second[0] == "" ? 0 : 1));
60 MG::GetCommands().CheckNumberOfArguments(iter->first, num_args);
61#endif
62
63#ifdef DEBUG_BARRIER
64 Comm& comm = *MG::GetComm();
65 comm.Barrier();
66 comm.PrintOnce(Debug, "Command \"%s\" start", iter->first.c_str());
67#endif
68
69 Timer::Start(iter->first);
70 request = MG::GetCommands().Get(iter->first)->Run(iter->second);
71 Timer::Stop(iter->first);
72
73#ifdef DEBUG_BARRIER
74 comm.Barrier();
75 comm.PrintOnce(Debug, "Command \"%s\" done", iter->first.c_str());
76#endif
77
78 if (request == StopCycleLater)
79 final_request = StopCycleNow;
80 else if (request == StopCycleNow) {
81 final_request = StopCycleNow;
82 break;
83 }
84 }
85
86 return final_request;
87}
88
89void CommandList::AddCommand(std::string command, std::string arguments)
90{
91 std::vector<std::string> argument_list;
92 size_t pos;
93
94 do {
95 pos = arguments.find(':');
96 argument_list.push_back(arguments.substr(0, pos));
97 arguments.erase(0, pos+1);
98 }while (pos != std::string::npos);
99
100 commands.push_back(std::pair<std::string, std::vector<std::string> >(command, argument_list));
101}
102
103void CommandList::DeleteCommand(const CommandList::iterator& iter)
104{
105 commands.erase(iter);
106}
107
108void CommandList::DeleteCommand(const std::string& _command)
109{
110 CommandList::iterator iter = commands.begin();
111 for (;iter != commands.end(); ++iter)
112 if (iter->first == _command)
113 break;
114 assert( iter != commands.end() );
115 DeleteCommand(iter);
116}
117
118void CommandList::Print()
119{
120 for (CommandList::iterator iter=commands.begin(); iter!=commands.end(); ++iter)
121 printf("%s\n", (*iter).first.c_str());
122}
123
124void CommandList::Clear()
125{
126 commands.clear();
127}
Note: See TracBrowser for help on using the repository browser.