OpenASIP 2.2
Loading...
Searching...
No Matches
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
36namespace 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 */
61bool
63 return hasID_;
64}
65
66
67/**
68 * Sets the ID for the entry.
69 *
70 * @param id The ID to set.
71 */
72void
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 */
85HDBEntry::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 */
98bool
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 */
126void
133
134
135/**
136 * Returns the HDB file that contains the entry.
137 *
138 * @return The HDB file.
139 */
140std::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 */
151void
152HDBEntry::setHDBFile(const std::string& file) {
153 hdbFile_ = file;
154}
155}
#define __func__
int RowID
Type definition of row ID in relational databases.
Definition DBTypes.hh:37
find Finds info of the inner loops in the false
RowID id_
ID of the entry in HDB.
Definition HDBEntry.hh:71
void setCostFunction(CostFunctionPlugin *costFunction)
Definition HDBEntry.cc:127
void setID(RowID id)
Definition HDBEntry.cc:73
CostFunctionPlugin * costFunction_
Cost function of the entry.
Definition HDBEntry.hh:73
bool hasCostFunction() const
Definition HDBEntry.cc:99
std::string hdbFile_
The HDB file that contains the entry.
Definition HDBEntry.hh:75
CostFunctionPlugin & costFunction() const
Definition HDBEntry.cc:111
virtual ~HDBEntry()
Definition HDBEntry.cc:49
std::string hdbFile() const
Definition HDBEntry.cc:141
bool hasID_
Tells whether the entry has an ID set.
Definition HDBEntry.hh:69
bool hasID() const
Definition HDBEntry.cc:62
void setHDBFile(const std::string &file)
Definition HDBEntry.cc:152
RowID id() const
Definition HDBEntry.cc:85