OpenASIP  2.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
CostDBEntry Class Reference

#include <CostDBEntry.hh>

Collaboration diagram for CostDBEntry:
Collaboration graph

Public Member Functions

 CostDBEntry (CostDBEntryKey *key)
 
 CostDBEntry (const CostDBEntry &entry1, const CostDBEntry &entry2, const EntryKeyField &weighter)
 
virtual ~CostDBEntry ()
 
CostDBEntrycopy () const
 
EntryKeyField keyFieldOfType (const EntryKeyFieldProperty &type) const
 
EntryKeyField keyFieldOfType (std::string type) const
 
const EntryKeyPropertytype () const
 
void replaceField (EntryKeyField *newField)
 
int fieldCount () const
 
const EntryKeyFieldfield (int index) const
 
bool isEqualKey (const CostDBEntry &entry) const
 
void addStatistics (CostDBEntryStats *newStats)
 
int statisticsCount () const
 
const CostDBEntryStatsstatistics (int index) const
 

Private Types

typedef std::vector< CostDBEntryStats * > StatsTable
 Type definition for a table of statistics. More...
 

Private Member Functions

 CostDBEntry (const CostDBEntry &)
 Copying not allowed. More...
 
CostDBEntryoperator= (const CostDBEntry &)
 Assignment not allowed. More...
 

Private Attributes

CostDBEntryKeyentryKey_
 Key of the entry. More...
 
StatsTable entryStats_
 Statistics of the entry. More...
 

Detailed Description

Represents an entry containing a key and statistics.

Key means the properties of an entry that are used as a search key.

Definition at line 52 of file CostDBEntry.hh.

Member Typedef Documentation

◆ StatsTable

typedef std::vector<CostDBEntryStats*> CostDBEntry::StatsTable
private

Type definition for a table of statistics.

Definition at line 77 of file CostDBEntry.hh.

Constructor & Destructor Documentation

◆ CostDBEntry() [1/3]

CostDBEntry::CostDBEntry ( CostDBEntryKey key)

Constructor.

Parameters
keyAn entry key.

Definition at line 44 of file CostDBEntry.cc.

44  :
45  entryKey_(key) {
46 }

Referenced by copy().

◆ CostDBEntry() [2/3]

CostDBEntry::CostDBEntry ( const CostDBEntry entry1,
const CostDBEntry entry2,
const EntryKeyField weighter 
)

Constructor.

Combines two entries into one using weighter as a weighting factor on interpolating the statistics. Also replacing weighter field in entry key.

Parameters
entry1First entry.
entry2Second entry.
weighterA field.

Definition at line 59 of file CostDBEntry.cc.

62  {
63 
64  EntryKeyField field1 = entry1.keyFieldOfType(*weighter.type());
65  EntryKeyField field2 = entry2.keyFieldOfType(*weighter.type());
66  double coefficient = weighter.coefficient(field1, field2);
67 
68  entryKey_ = entry1.entryKey_->copy();
69  entryKey_->replaceField(new EntryKeyField(weighter));
70  for (StatsTable::const_iterator i = entry1.entryStats_.begin();
71  i != entry1.entryStats_.end(); i++) {
72  for (StatsTable::const_iterator j = entry2.entryStats_.begin();
73  j != entry2.entryStats_.end(); j++) {
74  // newStats cannot be base class type if stats are for FU or RF
75  if (dynamic_cast<CostDBEntryStatsRF*>(*i) &&
76  dynamic_cast<CostDBEntryStatsRF*>(*j)) {
77  CostDBEntryStatsRF* newStats = new CostDBEntryStatsRF(
78  *dynamic_cast<CostDBEntryStatsRF*>(*i),
79  *dynamic_cast<CostDBEntryStatsRF*>(*j), coefficient);
80  addStatistics(newStats);
81  } else if (dynamic_cast<CostDBEntryStatsFU*>(*i) &&
82  dynamic_cast<CostDBEntryStatsFU*>(*j)) {
83  CostDBEntryStatsFU* newStats = new CostDBEntryStatsFU(
84  *dynamic_cast<CostDBEntryStatsFU*>(*i),
85  *dynamic_cast<CostDBEntryStatsFU*>(*j), coefficient);
86  addStatistics(newStats);
87  } else { // if the entry is Bus or Socket
88  CostDBEntryStats* newStats =
89  new CostDBEntryStats(*(*i), *(*j), coefficient);
90  addStatistics(newStats);
91  }
92  }
93  }
94 }

References addStatistics(), EntryKeyField::coefficient(), CostDBEntryKey::copy(), entryKey_, entryStats_, keyFieldOfType(), CostDBEntryKey::replaceField(), and EntryKeyField::type().

Here is the call graph for this function:

◆ ~CostDBEntry()

CostDBEntry::~CostDBEntry ( )
virtual

Destructor.

Definition at line 99 of file CostDBEntry.cc.

99  {
100  assert(entryKey_ != NULL);
101  delete entryKey_;
102  entryKey_ = NULL;
103 
104  for (StatsTable::iterator i = entryStats_.begin();
105  i != entryStats_.end(); i++) {
106  assert(*i != NULL);
107  delete *i;
108  }
109 }

References assert, entryKey_, and entryStats_.

◆ CostDBEntry() [3/3]

CostDBEntry::CostDBEntry ( const CostDBEntry )
private

Copying not allowed.

Member Function Documentation

◆ addStatistics()

void CostDBEntry::addStatistics ( CostDBEntryStats newStats)

Add new statistics into this entry.

Parameters
newStatsStatistics to be added.

Definition at line 213 of file CostDBEntry.cc.

213  {
214  entryStats_.push_back(newStats);
215 }

References entryStats_.

Referenced by CostDatabase::buildBuses(), CostDatabase::buildFunctionUnits(), CostDatabase::buildRegisterFiles(), CostDatabase::buildSockets(), copy(), and CostDBEntry().

◆ copy()

CostDBEntry * CostDBEntry::copy ( ) const

Copies the entry.

Client is responsible of deallocating the memory reserved for the returned object.

Returns
A copy of the entry.

Definition at line 120 of file CostDBEntry.cc.

120  {
121  CostDBEntry* newEntry = new CostDBEntry(entryKey_->copy());
122 
123  for (StatsTable::const_iterator i = entryStats_.begin();
124  i != entryStats_.end(); i++) {
125  newEntry->addStatistics((*i)->copy());
126  }
127 
128  return newEntry;
129 }

References addStatistics(), CostDBEntryKey::copy(), CostDBEntry(), entryKey_, and entryStats_.

Here is the call graph for this function:

◆ field()

const EntryKeyField & CostDBEntry::field ( int  index) const

Returns the field found on the given index.

The index must be between 0 and the number of entry key - 1.

Parameters
indexIndex.
Returns
The field found on the given index.

Definition at line 182 of file CostDBEntry.cc.

182  {
183  return entryKey_->field(index);
184 }

References entryKey_, and CostDBEntryKey::field().

Referenced by Matcher::onlyThisFieldDiffers().

Here is the call graph for this function:

◆ fieldCount()

int CostDBEntry::fieldCount ( ) const

Returns the number of fields in an entry.

Returns
The number of fields in an entry.

Definition at line 169 of file CostDBEntry.cc.

169  {
170  return entryKey_->fieldCount();
171 }

References entryKey_, and CostDBEntryKey::fieldCount().

Referenced by Matcher::onlyThisFieldDiffers().

Here is the call graph for this function:

◆ isEqualKey()

bool CostDBEntry::isEqualKey ( const CostDBEntry entry) const

Checks whether two entries have equal key.

Parameters
entryDatabase entry to compare with.
Returns
True if two entries have equal key, false otherwise.

Definition at line 203 of file CostDBEntry.cc.

203  {
204  return entryKey_->isEqual(*entry.entryKey_);
205 }

References entryKey_, and CostDBEntryKey::isEqual().

Here is the call graph for this function:

◆ keyFieldOfType() [1/2]

EntryKeyField CostDBEntry::keyFieldOfType ( const EntryKeyFieldProperty type) const

Returns demanded field of the entry.

Parameters
typeType of the field.
Returns
Demanded entry field.

Definition at line 148 of file CostDBEntry.cc.

148  {
149  return entryKey_->keyFieldOfType(type);
150 }

References entryKey_, CostDBEntryKey::keyFieldOfType(), and type().

Referenced by CostDBEntry(), and Matcher::onlyThisFieldDiffers().

Here is the call graph for this function:

◆ keyFieldOfType() [2/2]

EntryKeyField CostDBEntry::keyFieldOfType ( std::string  type) const

Returns demanded field of the entry.

Parameters
typeType of the field.
Returns
Demanded entry field.

Definition at line 159 of file CostDBEntry.cc.

159  {
160  return entryKey_->keyFieldOfType(type);
161 }

References entryKey_, CostDBEntryKey::keyFieldOfType(), and type().

Here is the call graph for this function:

◆ operator=()

CostDBEntry& CostDBEntry::operator= ( const CostDBEntry )
private

Assignment not allowed.

◆ replaceField()

void CostDBEntry::replaceField ( EntryKeyField newField)

Replaces certain field of the entry.

Parameters
newFieldA field.

Definition at line 192 of file CostDBEntry.cc.

192  {
193  entryKey_->replaceField(newField);
194 }

References entryKey_, and CostDBEntryKey::replaceField().

Here is the call graph for this function:

◆ statistics()

const CostDBEntryStats & CostDBEntry::statistics ( int  index) const

Returns the statistics according to given index.

Parameters
indexThe index of the statistics.
Returns
The statistics according to given index.
Exceptions
OutOfRangeIndex is out of bounds.

Definition at line 236 of file CostDBEntry.cc.

236  {
237  if (index < 0 || index >= statisticsCount()) {
238  throw OutOfRange(__FILE__, __LINE__, "CostDBEntry::statistics");
239  }
240  return *entryStats_[index];
241 }

References entryStats_, and statisticsCount().

Referenced by CostDatabase::insertEntry().

Here is the call graph for this function:

◆ statisticsCount()

int CostDBEntry::statisticsCount ( ) const

Returns the number of statistics in the entry.

Returns
Number of statistics in the entry.

Definition at line 224 of file CostDBEntry.cc.

224  {
225  return entryStats_.size();
226 }

References entryStats_.

Referenced by CostDatabase::insertEntry(), and statistics().

◆ type()

const EntryKeyProperty * CostDBEntry::type ( ) const

Returns type of the entry.

Returns
Type.

Definition at line 137 of file CostDBEntry.cc.

137  {
138  return entryKey_->type();
139 }

References entryKey_, and CostDBEntryKey::type().

Referenced by CostDatabase::insertEntry(), and keyFieldOfType().

Here is the call graph for this function:

Member Data Documentation

◆ entryKey_

CostDBEntryKey* CostDBEntry::entryKey_
private

Key of the entry.

Definition at line 80 of file CostDBEntry.hh.

Referenced by copy(), CostDBEntry(), field(), fieldCount(), isEqualKey(), keyFieldOfType(), replaceField(), type(), and ~CostDBEntry().

◆ entryStats_

StatsTable CostDBEntry::entryStats_
private

Statistics of the entry.

Definition at line 82 of file CostDBEntry.hh.

Referenced by addStatistics(), copy(), CostDBEntry(), statistics(), statisticsCount(), and ~CostDBEntry().


The documentation for this class was generated from the following files:
CostDBEntry::statisticsCount
int statisticsCount() const
Definition: CostDBEntry.cc:224
CostDBEntryKey::type
const EntryKeyProperty * type() const
OutOfRange
Definition: Exception.hh:320
CostDBEntryKey::fieldCount
int fieldCount() const
CostDBEntry::addStatistics
void addStatistics(CostDBEntryStats *newStats)
Definition: CostDBEntry.cc:213
EntryKeyField
Definition: EntryKeyField.hh:45
CostDBEntryStatsRF
Definition: CostDBEntryStatsRF.hh:45
CostDBEntry::entryStats_
StatsTable entryStats_
Statistics of the entry.
Definition: CostDBEntry.hh:82
assert
#define assert(condition)
Definition: Application.hh:86
CostDBEntry
Definition: CostDBEntry.hh:52
CostDBEntryStatsFU
Definition: CostDBEntryStatsFU.hh:44
CostDBEntryKey::replaceField
void replaceField(EntryKeyField *newField)
Definition: CostDBEntryKey.cc:105
EntryKeyField::coefficient
double coefficient(const EntryKeyField &field1, const EntryKeyField &field2) const
Definition: EntryKeyField.cc:130
EntryKeyField::type
const EntryKeyFieldProperty * type() const
CostDBEntryKey::isEqual
bool isEqual(const CostDBEntryKey &entryKey) const
Definition: CostDBEntryKey.cc:152
CostDBEntry::type
const EntryKeyProperty * type() const
Definition: CostDBEntry.cc:137
CostDBEntryKey::field
const EntryKeyField & field(int index) const
Definition: CostDBEntryKey.cc:181
CostDBEntry::entryKey_
CostDBEntryKey * entryKey_
Key of the entry.
Definition: CostDBEntry.hh:80
CostDBEntryKey::copy
CostDBEntryKey * copy() const
Definition: CostDBEntryKey.cc:69
CostDBEntryKey::keyFieldOfType
EntryKeyField keyFieldOfType(const EntryKeyFieldProperty &fieldType) const
Definition: CostDBEntryKey.cc:123
CostDBEntry::keyFieldOfType
EntryKeyField keyFieldOfType(const EntryKeyFieldProperty &type) const
Definition: CostDBEntry.cc:148
CostDBEntryStats
Definition: CostDBEntryStats.hh:46
CostDBEntry::CostDBEntry
CostDBEntry(CostDBEntryKey *key)
Definition: CostDBEntry.cc:44