OpenASIP  2.0
CostDBEntryStatsFU.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 CostDBEntryStatsFU.cc
26  *
27  * Implementation of CostDBEntryStatsFU class.
28  *
29  * @author Tommi Rantanen 2003 (tommi.rantanen-no.spam-tut.fi)
30  * @author Jari Mäntyneva 2005 (jari.mantyneva-no.spam-tut.fi)
31  * @note rating: red
32  */
33 
34 #include <map>
35 
36 #include "CostDBEntryStatsFU.hh"
37 
38 using std::string;
39 using std::map;
40 
41 
42 /**
43  * Constructor.
44  *
45  * @param areaData area.
46  * @param delayData delay.
47  */
48 CostDBEntryStatsFU::CostDBEntryStatsFU(double areaData, double delayData) :
49  CostDBEntryStats(areaData, delayData) {
50 }
51 
52 /**
53  * Constructor.
54  *
55  * Combines two statistics into one using coefficient as a weighting
56  * factor on interpolating the statistics. For example, if weighting
57  * factor is 0.4, the first area 100 and the second 200, area of new
58  * statistics will be 140. delay and energy will be handled similarly.
59  *
60  * @param stats1 First statistics.
61  * @param stats2 Second statistics.
62  * @param coefficient Weighting factor.
63  */
65  const CostDBEntryStatsFU& stats1,
66  const CostDBEntryStatsFU& stats2,
67  double coefficient):
68  CostDBEntryStats(stats1, stats2, coefficient) {
69 }
70 
71 
72 /**
73  * Destructor.
74  */
76 }
77 
78 /**
79  * Create correct type of statistics.
80  *
81  * @return Correct type of statistics.
82  */
85  return new CostDBEntryStatsFU(area(), delay());
86 }
87 
88 /**
89  * Returns the energy of an entry in an active cycle.
90  *
91  * The function will fail since function units do not have unambiguous
92  * energy for the whole unit but separately for each operation.
93  *
94  * @return The energy of an entry in an active cycle.
95  * @exception WrongSubclass An illegal function was called for this
96  * instance.
97  * @exception KeyNotFound Never thrown by this function.
98  */
99 double
101  throw WrongSubclass(__FILE__, __LINE__,
102  "CostDBEntryStatsFU::energyActive");
103  return 0.0; // stupid return statement to make compiler quiet
104 }
105 
106 /**
107  * Returns the energy of an entry when given operation is executed.
108  *
109  * @param name name of the operation.
110  * @return The energy of an entry when given operation is executed.
111  * @exception WrongSubclass Never thrown by this function.
112  * @exception KeyNotFound No energy matching the string found.
113  */
114 double
115 CostDBEntryStatsFU::energyOperation(const std::string& name) const {
116  return findEnergy(name);
117 }
118 
119 /**
120  * Checks whether the energy exists for the given operation.
121  *
122  * @param name name of the operation.
123  * @return True if the energy exists for the given operation.
124  * @exception WrongSubclass Never thrown by this function.
125  */
126 bool
127 CostDBEntryStatsFU::hasEnergyOperation(const std::string& name) const {
128  return hasEnergy(name);
129 }
130 
131 /**
132  * Set the energy of an entry in an active cycle.
133  *
134  * The function will fail since function units do not have unambiguous
135  * energy for the whole unit but separately for each operation.
136  *
137  * @param energy The energy of an entry in an active cycle.
138  * @exception WrongSubclass An illegal function was called for this
139  * instance.
140  */
141 void
143  throw WrongSubclass(__FILE__, __LINE__,
144  "CostDBEntryStatsFU::setEnergyActive");
145 }
146 
147 /**
148  * Set the energy of an entry when given operation is executed.
149  *
150  * @param name name of the operation.
151  * @param energy The energy of an entry when given operation is executed.
152  * @exception WrongSubclass Never thrown by this function.
153  */
154 void
155 CostDBEntryStatsFU::setEnergyOperation(const std::string& name, double energy) {
156  addEnergy(name, energy);
157 }
CostDBEntryStatsFU::~CostDBEntryStatsFU
virtual ~CostDBEntryStatsFU()
Definition: CostDBEntryStatsFU.cc:75
CostDBEntryStatsFU::hasEnergyOperation
virtual bool hasEnergyOperation(const std::string &name) const
Definition: CostDBEntryStatsFU.cc:127
CostDBEntryStatsFU::energyActive
virtual double energyActive() const
Definition: CostDBEntryStatsFU.cc:100
CostDBEntryStats::hasEnergy
virtual bool hasEnergy(const std::string &key) const
Definition: CostDBEntryStats.cc:294
CostDBEntryStats::delay
virtual double delay() const
CostDBEntryStatsFU::setEnergyOperation
virtual void setEnergyOperation(const std::string &name, double energy)
Definition: CostDBEntryStatsFU.cc:155
CostDBEntryStatsFU
Definition: CostDBEntryStatsFU.hh:44
WrongSubclass
Definition: Exception.hh:336
CostDBEntryStats::area
virtual double area() const
CostDBEntryStats::addEnergy
virtual void addEnergy(const std::string &name, double energy)
Definition: CostDBEntryStats.cc:413
CostDBEntryStatsFU::CostDBEntryStatsFU
CostDBEntryStatsFU(double areaData, double delayData)
Definition: CostDBEntryStatsFU.cc:48
CostDBEntryStats::findEnergy
virtual double findEnergy(const std::string &key) const
Definition: CostDBEntryStats.cc:308
CostDBEntryStatsFU.hh
CostDBEntryStatsFU::setEnergyActive
virtual void setEnergyActive(double energy)
Definition: CostDBEntryStatsFU.cc:142
CostDBEntryStats
Definition: CostDBEntryStats.hh:46
CostDBEntryStatsFU::createStats
virtual CostDBEntryStats * createStats() const
Definition: CostDBEntryStatsFU.cc:84
CostDBEntryStatsFU::energyOperation
virtual double energyOperation(const std::string &name) const
Definition: CostDBEntryStatsFU.cc:115