OpenASIP  2.0
ResumeCommand.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file ResumeCommand.cc
26  *
27  * Implementation of ResumeCommand class
28  *
29  * @author Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include "ResumeCommand.hh"
34 #include "Application.hh"
35 #include "SimulatorFrontend.hh"
37 #include "Exception.hh"
38 #include "SimulatorToolbox.hh"
40 
41 /**
42  * Constructor.
43  *
44  * Sets the name of the command to the base class.
45  */
47  SimControlLanguageCommand("resume") {
48 }
49 
50 /**
51  * Destructor.
52  *
53  * Does nothing.
54  */
56 }
57 
58 /**
59  * Executes the "resume" command.
60  *
61  * Resume simulation of the program until the simulation is finished or
62  * a breakpoint is reached. The optional argument gives the number of times
63  * the continue command is repeated, that is, the number of times breakpoints
64  * should be ignored.
65  *
66  * @param arguments (optional) count of times to repeat in case breakpoints are
67  * reached.
68  * @return Always true.
69  * @exception NumberFormatException Is never thrown by this command.
70  *
71  */
72 bool
73 ResumeCommand::execute(const std::vector<DataObject>& arguments) {
74  // how many times breakpoints should be ignored?
75  int repeatCount = 0;
76  if (!checkArgumentCount(arguments.size() - 1, 0, 1)) {
77  return false;
78  } else {
79  if (arguments.size() > 1) {
80  if (!checkPositiveIntegerArgument(arguments[1])) {
81  return false;
82  } else {
83  repeatCount = arguments[1].integerValue();
84  }
85  }
86  }
87 
88  if (!checkSimulationStopped()) {
89  return false;
90  }
91 
92  int repeats = 0;
93  do {
95  ++repeats;
96  } while(simulatorFrontend().isSimulationStopped() &&
97  repeats < repeatCount);
98 
100 
101  return true;
102 }
103 
104 /**
105  * Returns the help text for this command.
106  *
107  * Help text is searched from SimulatorTextGenerator.
108  *
109  * @return The help text.
110  * @todo Use SimulatorTextGenerator to get the help text.
111  */
112 std::string
116 }
117 
CustomCommand::checkArgumentCount
bool checkArgumentCount(int argumentCount, int minimum, int maximum)
Definition: CustomCommand.cc:82
SimControlLanguageCommand::checkSimulationStopped
bool checkSimulationStopped()
Definition: SimControlLanguageCommand.cc:135
SimulatorInterpreterContext.hh
Exception.hh
ResumeCommand::~ResumeCommand
virtual ~ResumeCommand()
Definition: ResumeCommand.cc:55
CustomCommand::checkPositiveIntegerArgument
bool checkPositiveIntegerArgument(const DataObject &argument)
Definition: CustomCommand.cc:134
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
SimulatorFrontend::run
virtual void run()
Definition: SimulatorFrontend.cc:997
ResumeCommand::helpText
virtual std::string helpText() const
Definition: ResumeCommand.cc:113
ResumeCommand.hh
SimControlLanguageCommand::printStopInformation
virtual void printStopInformation()
Definition: SimControlLanguageCommand.cc:243
SimulatorToolbox.hh
Application.hh
SimulatorToolbox::textGenerator
static SimulatorTextGenerator & textGenerator()
Definition: SimulatorToolbox.cc:75
SimulatorTextGenerator.hh
Texts::TXT_INTERP_HELP_RESUME
@ TXT_INTERP_HELP_RESUME
Help text for command "resume" of the CLI.
Definition: SimulatorTextGenerator.hh:79
SimulatorFrontend.hh
ResumeCommand::ResumeCommand
ResumeCommand()
Definition: ResumeCommand.cc:46
SimControlLanguageCommand
Definition: SimControlLanguageCommand.hh:63
SimControlLanguageCommand::simulatorFrontend
SimulatorFrontend & simulatorFrontend()
Definition: SimControlLanguageCommand.cc:214
ResumeCommand::execute
virtual bool execute(const std::vector< DataObject > &arguments)
Definition: ResumeCommand.cc:73