OpenASIP  2.0
HDBEntry.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 HDBEntry.cc
26  *
27  * Implementation of HDBEntry class.
28  *
29  * @author Lasse Laasonen 2006 (lasse.laasonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #include "HDBEntry.hh"
34 #include "CostFunctionPlugin.hh"
35 
36 namespace HDB {
37 
38 /**
39  * The constructor.
40  */
42  hasID_(false), id_(0), costFunction_(NULL), hdbFile_("") {
43 }
44 
45 
46 /**
47  * The destructor.
48  */
50  if (hasCostFunction()) {
51  delete costFunction_;
52  }
53 }
54 
55 
56 /**
57  * Tells whether the entry has an ID.
58  *
59  * @return True if the entry has an ID, otherwise false.
60  */
61 bool
62 HDBEntry::hasID() const {
63  return hasID_;
64 }
65 
66 
67 /**
68  * Sets the ID for the entry.
69  *
70  * @param id The ID to set.
71  */
72 void
74  hasID_ = true;
75  id_ = id;
76 }
77 
78 
79 /**
80  * Returns the ID of the entry.
81  *
82  * @return ID of the entry.
83  */
84 RowID
85 HDBEntry::id() const {
86  if (!hasID()) {
87  throw NotAvailable(__FILE__, __LINE__, __func__);
88  } else {
89  return id_;
90  }
91 }
92 
93 /**
94  * Tells whether the entry contains a cost function.
95  *
96  * @return True if the entry contains a cost function.
97  */
98 bool
100  return costFunction_ != NULL;
101 }
102 
103 
104 /**
105  * Returns the cost function of the entry.
106  *
107  * @return Cost function of the entry.
108  * @exception NotAvailable If the entry doesn't have a cost function.
109  */
112  if (!hasCostFunction()) {
113  throw NotAvailable(__FILE__, __LINE__, __func__);
114  }
115 
116  return *costFunction_;
117 }
118 
119 /**
120  * Sets cost function for the entry.
121  *
122  * Deletes the old cost function if one exists.
123  *
124  * @param costFunction The new cost function.
125  */
126 void
128  if (hasCostFunction()) {
129  delete costFunction_;
130  }
132 }
133 
134 
135 /**
136  * Returns the HDB file that contains the entry.
137  *
138  * @return The HDB file.
139  */
140 std::string
142  return hdbFile_;
143 }
144 
145 
146 /**
147  * Sets the HDB file that contains the entry.
148  *
149  * @param file The HDB file.
150  */
151 void
152 HDBEntry::setHDBFile(const std::string& file) {
153  hdbFile_ = file;
154 }
155 }
HDB::HDBEntry::hasID
bool hasID() const
Definition: HDBEntry.cc:62
HDB::HDBEntry::hdbFile_
std::string hdbFile_
The HDB file that contains the entry.
Definition: HDBEntry.hh:75
HDB::HDBEntry::costFunction
CostFunctionPlugin & costFunction() const
Definition: HDBEntry.cc:111
HDB
Definition: CostDatabase.hh:49
HDB::HDBEntry::~HDBEntry
virtual ~HDBEntry()
Definition: HDBEntry.cc:49
HDB::HDBEntry::id
RowID id() const
Definition: HDBEntry.cc:85
HDB::HDBEntry::HDBEntry
HDBEntry()
Definition: HDBEntry.cc:41
RowID
int RowID
Type definition of row ID in relational databases.
Definition: DBTypes.hh:37
HDB::HDBEntry::hdbFile
std::string hdbFile() const
Definition: HDBEntry.cc:141
NotAvailable
Definition: Exception.hh:728
HDB::HDBEntry::hasCostFunction
bool hasCostFunction() const
Definition: HDBEntry.cc:99
HDB::HDBEntry::setID
void setID(RowID id)
Definition: HDBEntry.cc:73
HDB::HDBEntry::setCostFunction
void setCostFunction(CostFunctionPlugin *costFunction)
Definition: HDBEntry.cc:127
HDB::HDBEntry::costFunction_
CostFunctionPlugin * costFunction_
Cost function of the entry.
Definition: HDBEntry.hh:73
__func__
#define __func__
Definition: Application.hh:67
false
find Finds info of the inner loops in the false
Definition: InnerLoopFinder.cc:81
HDB::HDBEntry::hasID_
bool hasID_
Tells whether the entry has an ID set.
Definition: HDBEntry.hh:69
CostFunctionPlugin.hh
HDBEntry.hh
HDB::HDBEntry::id_
RowID id_
ID of the entry in HDB.
Definition: HDBEntry.hh:71
HDB::CostFunctionPlugin
Definition: CostFunctionPlugin.hh:43
HDB::HDBEntry::setHDBFile
void setHDBFile(const std::string &file)
Definition: HDBEntry.cc:152