OpenASIP  2.0
InstructionExecution.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 InstructionExecution.cc
26  *
27  * Definition of InstructionExecution class.
28  *
29  * @author Pekka Jääskeläinen 2004 (pjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include "Application.hh"
34 #include "InstructionExecution.hh"
35 #include "ExecutionTrace.hh"
36 #include "DataObject.hh"
37 
38 /**
39  * Constructor.
40  *
41  * Object is initialized to point to the first record in the record set,
42  * if any.
43  *
44  * @param result The query result to traverse.
45  */
47  result_(result), addressColumnIndex_(-1), cycleColumnIndex_(-1) {
48  cycleColumnIndex_ = result_->column("cycle");
49  addressColumnIndex_ = result_->column("address");
50 
53  assert(result != NULL);
54 
55  if (hasNext()) {
56  next();
57  }
58 }
59 
60 /**
61  * Destructor.
62  */
64  delete result_;
65  result_ = NULL;
66 }
67 
68 /**
69  * Returns the cycle count value of the current record.
70  *
71  * @return The cycle count.
72  * @exception NotAvailable If the current record is empty.
73  */
77  const std::string errorMsg =
78  "Tried to fetch data from an empty result set.";
79  throw NotAvailable(__FILE__, __LINE__, __func__, errorMsg);
80  }
82 }
83 
84 /**
85  * Returns the instruction address value of the current record.
86  *
87  * @return The instruction address value.
88  * @exception NotAvailable If the current record is empty.
89  */
93  const std::string errorMsg =
94  "Tried to fetch data from an empty result set.";
95  throw NotAvailable(__FILE__, __LINE__, __func__, errorMsg);
96  }
98 }
99 
100 /**
101  * Advances the navigator to the next record in the query result set.
102  *
103  * @exception NotAvailable if there is no more results in the set.
104  */
105 void
107  if (!result_->hasNext()) {
108  throw NotAvailable(__FILE__, __LINE__, __func__, "No more results.");
109  }
110  result_->next();
111 }
112 
113 /**
114  * Returns true if there are more results available.
115  *
116  * @return True if more results available.
117  */
118 bool
120  return result_->hasNext();
121 }
InstructionExecution::~InstructionExecution
virtual ~InstructionExecution()
Definition: InstructionExecution.cc:63
InstructionExecution::cycleColumnIndex_
int cycleColumnIndex_
Definition: InstructionExecution.hh:59
InstructionAddress
UInt32 InstructionAddress
Definition: BaseType.hh:175
InstructionExecution::addressColumnIndex_
int addressColumnIndex_
Definition: InstructionExecution.hh:58
InstructionExecution.hh
RelationalDBQueryResult::data
virtual const DataObject & data(std::size_t column) const =0
Definition: RelationalDBQueryResult.cc:96
InstructionExecution::result_
RelationalDBQueryResult * result_
Definition: InstructionExecution.hh:57
RelationalDBQueryResult::hasNext
virtual bool hasNext()=0
Definition: RelationalDBQueryResult.cc:126
NotAvailable
Definition: Exception.hh:728
assert
#define assert(condition)
Definition: Application.hh:86
InstructionExecution::hasNext
bool hasNext() const
Definition: InstructionExecution.cc:119
DataObject::integerValue
virtual int integerValue() const
Definition: DataObject.cc:204
RelationalDBQueryResult::next
virtual bool next()=0
Definition: RelationalDBQueryResult.cc:138
Application.hh
RelationalDBQueryResult
Definition: RelationalDBQueryResult.hh:46
__func__
#define __func__
Definition: Application.hh:67
InstructionExecution::InstructionExecution
InstructionExecution(RelationalDBQueryResult *result)
Definition: InstructionExecution.cc:46
DataObject.hh
RelationalDBQueryResult::column
virtual int column(const std::string &name) const
Definition: RelationalDBQueryResult.cc:64
ClockCycleCount
CycleCount ClockCycleCount
Alias for ClockCycleCount.
Definition: SimulatorConstants.hh:57
InstructionExecution::cycle
ClockCycleCount cycle() const
Definition: InstructionExecution.cc:75
InstructionExecution::address
InstructionAddress address() const
Definition: InstructionExecution.cc:91
InstructionExecution::next
void next()
Definition: InstructionExecution.cc:106
NullDataObject::instance
static NullDataObject & instance()
Definition: DataObject.cc:542
ExecutionTrace.hh