OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
CostDBEntryKey Class Reference

#include <CostDBEntryKey.hh>

Collaboration diagram for CostDBEntryKey:
Collaboration graph

Public Member Functions

 CostDBEntryKey (const EntryKeyProperty *entryType)
 
virtual ~CostDBEntryKey ()
 
CostDBEntryKeycopy () const
 
const EntryKeyPropertytype () const
 
EntryKeyField keyFieldOfType (const EntryKeyFieldProperty &fieldType) const
 
EntryKeyField keyFieldOfType (std::string fieldType) const
 
bool isEqual (const CostDBEntryKey &entryKey) const
 
void addField (EntryKeyField *field)
 
void replaceField (EntryKeyField *newField)
 
int fieldCount () const
 
const EntryKeyFieldfield (int index) const
 

Private Types

typedef std::vector< EntryKeyField * > FieldTable
 Table of entry fields.
 

Private Member Functions

 CostDBEntryKey (const CostDBEntryKey &)
 Copying not allowed.
 
CostDBEntryKeyoperator= (const CostDBEntryKey &)
 Assignment not allowed.
 

Private Attributes

const EntryKeyPropertytype_
 Type of the entry key.
 
FieldTable fields_
 Fields of the entry key.
 

Detailed Description

Represents the key of the CostDBEntry.

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

Definition at line 52 of file CostDBEntryKey.hh.

Member Typedef Documentation

◆ FieldTable

typedef std::vector<EntryKeyField*> CostDBEntryKey::FieldTable
private

Table of entry fields.

Definition at line 70 of file CostDBEntryKey.hh.

Constructor & Destructor Documentation

◆ CostDBEntryKey() [1/2]

CostDBEntryKey::CostDBEntryKey ( const EntryKeyProperty entryType)

Constructor.

Parameters
entryTypeType of the entry key.

Definition at line 43 of file CostDBEntryKey.cc.

43 :
44 type_(entryType) {
45}
const EntryKeyProperty * type_
Type of the entry key.

◆ ~CostDBEntryKey()

CostDBEntryKey::~CostDBEntryKey ( )
virtual

Destructor.

Deallocates memory reserved for the fields of the entry key.

Definition at line 52 of file CostDBEntryKey.cc.

52 {
53 for (FieldTable::iterator i = fields_.begin(); i != fields_.end(); i++) {
54 assert(*i != NULL);
55 delete *i;
56 *i = NULL;
57 }
58}
#define assert(condition)
FieldTable fields_
Fields of the entry key.

References assert, and fields_.

◆ CostDBEntryKey() [2/2]

CostDBEntryKey::CostDBEntryKey ( const CostDBEntryKey )
private

Copying not allowed.

Member Function Documentation

◆ addField()

void CostDBEntryKey::addField ( EntryKeyField field)

Adds certain field to the entry key.

Parameters
fieldA field to be added.
Exceptions
ObjectAlreadyExistsEqual field already exists.

Definition at line 88 of file CostDBEntryKey.cc.

88 {
89 for (FieldTable::iterator i = fields_.begin(); i != fields_.end(); i++) {
90 if ((*i)->type() == field->type()) {
92 __FILE__, __LINE__, "CostDBEntryKey::addField");
93 }
94 }
95 fields_.push_back(field);
96}
const EntryKeyField & field(int index) const
const EntryKeyFieldProperty * type() const

References field(), fields_, and EntryKeyField::type().

Referenced by CostDatabase::buildBuses(), CostDatabase::buildFunctionUnits(), CostDatabase::buildRegisterFiles(), CostDatabase::buildSockets(), copy(), InterpolatingRFEstimator::createSearch(), and InterpolatingFUEstimator::createSearch().

Here is the call graph for this function:

◆ copy()

CostDBEntryKey * CostDBEntryKey::copy ( ) const

Copies the entry key.

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

Returns
A copy of the entry key.

Definition at line 69 of file CostDBEntryKey.cc.

69 {
70
72
73 for (FieldTable::const_iterator i = fields_.begin();
74 i != fields_.end(); i++) {
75
76 copy->addField(new EntryKeyField(*(*i)));
77 }
78 return copy;
79}
CostDBEntryKey * copy() const
void addField(EntryKeyField *field)

References addField(), copy(), fields_, and type_.

Referenced by CostDBEntry::copy(), copy(), FilterSearch::Cache::copy(), CostDBEntry::CostDBEntry(), and FilterSearch::search().

Here is the call graph for this function:

◆ field()

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

Returns the field found on the given index.

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

Parameters
indexIndex.
Returns
The field found on the given index.
Exceptions
OutOfRangeIndex was out of range.

Definition at line 181 of file CostDBEntryKey.cc.

181 {
182 if (index >= fieldCount() || index < 0) {
183 throw OutOfRange(__FILE__, __LINE__, "CostDBEntryKey::field");
184 }
185 return *fields_[index];
186}
int fieldCount() const

References fieldCount(), and fields_.

Referenced by addField(), and CostDBEntry::field().

Here is the call graph for this function:

◆ fieldCount()

int CostDBEntryKey::fieldCount ( ) const

Referenced by field(), and CostDBEntry::fieldCount().

◆ isEqual()

bool CostDBEntryKey::isEqual ( const CostDBEntryKey entryKey) const

Compares if two entry keys are equal.

Parameters
entryKeyAn entry key.
Returns
True if two entry keys are equal, otherwise false.

Definition at line 152 of file CostDBEntryKey.cc.

152 {
153
154 if (type() == entryKey.type()) {
155 bool isMatch = true;
156 for (FieldTable::const_iterator f = fields_.begin();
157 f != fields_.end(); f++) {
158
159 if (!(*f)->isEqual(entryKey.keyFieldOfType(*(*f)->type()))) {
160 isMatch = false;
161 break;
162 }
163 }
164 if (isMatch) {
165 return true;
166 }
167 }
168 return false;
169}
EntryKeyField keyFieldOfType(const EntryKeyFieldProperty &fieldType) const
const EntryKeyProperty * type() const

References fields_, keyFieldOfType(), and type().

Referenced by CostDBEntry::isEqualKey().

Here is the call graph for this function:

◆ keyFieldOfType() [1/2]

EntryKeyField CostDBEntryKey::keyFieldOfType ( const EntryKeyFieldProperty fieldType) const

Returns demanded field of the entry key.

Parameters
fieldTypeType of the field.
Exceptions
KeyNotFoundRequested field type was not found.

Definition at line 123 of file CostDBEntryKey.cc.

123 {
124 for (FieldTable::const_iterator i = fields_.begin();
125 i != fields_.end(); i++) {
126 if ((*i)->type() == &fieldType) {
127 return *(*i);
128 }
129 }
130 throw KeyNotFound(__FILE__, __LINE__, "CostDBEntry::keyFieldOfType");
131 return *fields_[0];// stupid return statement to make compiler quiet
132}

References fields_.

Referenced by Interpolation::filter(), isEqual(), CostDBEntry::keyFieldOfType(), keyFieldOfType(), CostDBEntry::keyFieldOfType(), and ExactMatch::quickFilter().

◆ keyFieldOfType() [2/2]

EntryKeyField CostDBEntryKey::keyFieldOfType ( std::string  fieldType) const

Returns demanded field of the entry key.

Returns
type Type of the field.

Definition at line 140 of file CostDBEntryKey.cc.

140 {
141
142 return keyFieldOfType(*type_->fieldProperty(fieldType));
143}
EntryKeyFieldProperty * fieldProperty(std::string field) const

References EntryKeyProperty::fieldProperty(), keyFieldOfType(), and type_.

Here is the call graph for this function:

◆ operator=()

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

Assignment not allowed.

◆ replaceField()

void CostDBEntryKey::replaceField ( EntryKeyField newField)

Replaces certain field of the entry key.

Parameters
newFieldA field.
Exceptions
KeyNotFoundEqual field was not found.

Definition at line 105 of file CostDBEntryKey.cc.

105 {
106 for (FieldTable::iterator i = fields_.begin(); i != fields_.end(); i++) {
107 if ((*i)->type() == newField->type()) {
108 delete *i;
109 *i = newField;
110 return;
111 }
112 }
113 throw KeyNotFound(__FILE__, __LINE__, "CostDBEntry::replaceField");
114}

References fields_, and EntryKeyField::type().

Referenced by CostDBEntry::CostDBEntry(), and CostDBEntry::replaceField().

Here is the call graph for this function:

◆ type()

const EntryKeyProperty * CostDBEntryKey::type ( ) const

Member Data Documentation

◆ fields_

FieldTable CostDBEntryKey::fields_
private

Fields of the entry key.

Definition at line 75 of file CostDBEntryKey.hh.

Referenced by addField(), copy(), field(), isEqual(), keyFieldOfType(), replaceField(), and ~CostDBEntryKey().

◆ type_

const EntryKeyProperty* CostDBEntryKey::type_
private

Type of the entry key.

Definition at line 73 of file CostDBEntryKey.hh.

Referenced by copy(), and keyFieldOfType().


The documentation for this class was generated from the following files: