OpenASIP 2.2
Loading...
Searching...
No Matches
StopPoint.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 StopPoint.cc
26 *
27 * Definition of StopPoint class.
28 *
29 * @author Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#include "StopPoint.hh"
34#include "ConditionScript.hh"
35#include "SimulatorConstants.hh"
36#include "BaseType.hh"
37#include "Application.hh"
38#include "Conversion.hh"
39
40/**
41 * Constructor.
42 */
44 enabled_(false), disabledAfterTriggered_(false),
45 deletedAfterTriggered_(false), conditional_(false), condition_(NULL),
46 ignoreCount_(0) {
47}
48
49/**
50 * Destructor.
51 */
53 delete condition_;
54 condition_ = NULL;
55}
56
57/**
58 * Sets the enabled status of the breakpoint.
59 *
60 * @param flag The status.
61 */
62void
64 enabled_ = flag;
65}
66
67/**
68 * Tells wheter the stop point is enabled or not.
69 *
70 * @return 'True' if the breakpoint is enabled, 'false' if it is disabled.
71 */
72bool
74 return enabled_;
75}
76
77
78/**
79 * Sets the stop point to be disabled after it is triggered the next
80 * time.
81 *
82 * @param flag The new value for this property.
83 */
84void
88
89/**
90 * Tells if the stop point is disabled after it is triggered (fired) the
91 * next time.
92 *
93 * @return 'True' if the stop oint is disabled after it is triggered,
94 * 'false' otherwise.
95 */
96bool
100
101/**
102 * Makes the stop point to be deleted after it is triggered the next time.
103 *
104 * @param flag The new value for this property.
105 */
106void
110
111/**
112 * Tells whether the stop point is deleted after it is triggered (fired)
113 * the next time.
114 *
115 * @return 'True' if the stop point is deleted after it is triggered,
116 * 'false' if it is not.
117 */
118bool
122
123/**
124 * Sets the condition of the StopPoint.
125 *
126 * The condition is used to determine if the stop point should be fired.
127 *
128 * @param condition The condition to be used as stop point's condition.
129 */
130void
132 conditional_ = true;
134}
135
136/**
137 * Remove the condition of the StopPoint.
138 *
139 * The condition is used to determine if the stop point should be fired.
140 */
141void
143 conditional_ = false;
144 delete condition_;
145 condition_ = NULL;
146}
147
148/**
149 * Returns the condition of the stop point.
150 *
151 * If breakpoint is unconditional, an empty ConditionScript is returned.
152 *
153 * @return The condition of the stop point firing.
154 */
155const ConditionScript&
157
158 static ConditionScript emptyCondition(NULL, "");
159
160 if (conditional_) {
161 return *condition_;
162 } else {
163 return emptyCondition;
164 }
165}
166
167/**
168 * Tells whether the stop point is conditional or not.
169 *
170 * @return 'True' if the stop point is conditional, 'false' if it is not.
171 */
172bool
174 return conditional_;
175}
176
177/**
178 * Sets the number of times the condition for firing the stop point is
179 * to be disabled before enabling it.
180 */
181void
182StopPoint::setIgnoreCount(unsigned int count) {
183 ignoreCount_ = count;
184}
185
186/**
187 * Tells the current ignore count, i.e. the number of times the stop point
188 * condition is ignored before being fired.
189 *
190 * @return The ignore count.
191 */
192unsigned int
194 return ignoreCount_;
195}
196
197/**
198 * Decreases the ignore count.
199 */
200void
202 if (ignoreCount() > 0) {
204 }
205}
206
207/**
208 * Tells wheter the condition of the stop point evalutes to true.
209 *
210 * If the stop point is not conditional, returns always true.
211 *
212 * @return 'True' if condition is OK, 'false' otherwise.
213 */
214bool
216
217 if (conditional_) {
218 assert(condition_ != NULL);
219 try {
220 return condition_->conditionOk();
221 } catch (const Exception& e) {
223 << "Condition script threw exception: " << e.errorMessage()
224 << std::endl;
225 return false;
226 }
227 } else {
228 return true;
229 }
230}
231
232/**
233 * Prints the description string of the stop point.
234 *
235 * Each subclass overrides this method to construct a descripting string of
236 * itself.
237 */
238std::string
240 std::string description = "";
241 if (!enabled_)
242 description += "is disabled";
243
245 if (description != "")
246 description += ", ";
247 description = "will be disabled after triggered";
248 }
249
251 if (description != "")
252 description += ", ";
253 description += "will be deleted after triggered";
254 }
255
256 if (ignoreCount_) {
257 if (description != "")
258 description += ", ";
259 description += "will be ignored " +
261 }
262
263 if (conditional_) {
264 if (description != "")
265 description += ", ";
266 description += "has condition '" + condition_->script().at(0) + "'";
267 }
268
269 if (description != "")
270 description += " ";
271
272 return description;
273}
274
#define assert(condition)
find Finds info of the inner loops in the false
static std::ostream & logStream()
virtual bool conditionOk()
virtual ConditionScript * copy() const
static std::string toString(const T &source)
std::string errorMessage() const
Definition Exception.cc:123
virtual std::vector< std::string > script() const
Definition Script.cc:106
virtual bool isConditional() const
Definition StopPoint.cc:173
bool enabled_
Tells whether the breakpoint is enabled or disabled.
Definition StopPoint.hh:84
virtual bool isDisabledAfterTriggered() const
Definition StopPoint.cc:97
virtual void removeCondition()
Definition StopPoint.cc:142
virtual std::string description() const =0
Definition StopPoint.cc:239
bool conditional_
Tells whether the breakpoint is conditional or not.
Definition StopPoint.hh:91
virtual bool isEnabled() const
Definition StopPoint.cc:73
virtual const ConditionScript & condition() const
Definition StopPoint.cc:156
virtual void setDeletedAfterTriggered(bool flag)
Definition StopPoint.cc:107
virtual bool isConditionOK()
Definition StopPoint.cc:215
virtual ~StopPoint()
Definition StopPoint.cc:52
virtual void setEnabled(bool flag)
Definition StopPoint.cc:63
bool disabledAfterTriggered_
Tells if the breakpoint is disabled after it is triggered the next time.
Definition StopPoint.hh:87
bool deletedAfterTriggered_
Tells if the breakpoint is deleted after it is triggered the next time.
Definition StopPoint.hh:89
virtual void decreaseIgnoreCount()
Definition StopPoint.cc:201
virtual void setCondition(const ConditionScript &condition)
Definition StopPoint.cc:131
ConditionScript * condition_
The condition which is used to determine whether the breakpoint should be fired or not.
Definition StopPoint.hh:94
virtual bool isDeletedAfterTriggered() const
Definition StopPoint.cc:119
unsigned int ignoreCount_
The number of times the condition is to be ignored before enabling the breakpoint.
Definition StopPoint.hh:97
virtual unsigned int ignoreCount() const
Definition StopPoint.cc:193
virtual void setDisabledAfterTriggered(bool flag)
Definition StopPoint.cc:85
virtual void setIgnoreCount(unsigned int count)
Definition StopPoint.cc:182