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

#include <CostDatabaseRegistry.hh>

Collaboration diagram for CostDatabaseRegistry:
Collaboration graph

Public Member Functions

virtual ~CostDatabaseRegistry ()
 
CostDatabasecostDatabase (const HDB::HDBManager &hdb)
 
void addCostDatabase (CostDatabase *costDatabase, const HDB::HDBManager &hdb)
 
bool hasCostDatabase (const HDB::HDBManager &hdb)
 
int costDatabaseCount ()
 
CostDatabasecostDatabase (unsigned int index)
 
std::string hdbPath (unsigned int index)
 

Static Public Member Functions

static CostDatabaseRegistryinstance ()
 

Private Member Functions

 CostDatabaseRegistry ()
 CostDatabase registry must be created with instance() method.
 

Private Attributes

std::map< const HDB::HDBManager *, CostDatabase * > registry_
 All created CostDatabasess are stored in this map.
 

Static Private Attributes

static CostDatabaseRegistryinstance_ = NULL
 Unique instance of the class.
 

Detailed Description

Registry for multiple CostDatabases.

Definition at line 46 of file CostDatabaseRegistry.hh.

Constructor & Destructor Documentation

◆ ~CostDatabaseRegistry()

CostDatabaseRegistry::~CostDatabaseRegistry ( )
virtual

Destructor.

Definition at line 49 of file CostDatabaseRegistry.cc.

49 {
51 instance_ = NULL;
52}
static void deleteAllValues(ContainerType &aMap)
static CostDatabaseRegistry * instance_
Unique instance of the class.
std::map< const HDB::HDBManager *, CostDatabase * > registry_
All created CostDatabasess are stored in this map.

References AssocTools::deleteAllValues(), instance_, and registry_.

Here is the call graph for this function:

◆ CostDatabaseRegistry()

CostDatabaseRegistry::CostDatabaseRegistry ( )
private

CostDatabase registry must be created with instance() method.

Constructor.

Definition at line 43 of file CostDatabaseRegistry.cc.

43 {
44}

Referenced by instance().

Member Function Documentation

◆ addCostDatabase()

void CostDatabaseRegistry::addCostDatabase ( CostDatabase costDatabase,
const HDB::HDBManager hdb 
)

Adds CostDatabase and HDB used in the CostDatabase in to the registry.

Parameters
costDatabaseThe cost database to be added in to the registry.
hdbThe HDB that is used to create the CostDatabase.

Definition at line 95 of file CostDatabaseRegistry.cc.

96 {
97
99 delete costDatabase;
100 costDatabase = NULL;
101 return;
102 }
103 registry_[&hdb] = costDatabase;
104}
static bool containsKey(const ContainerType &aContainer, const KeyType &aKey)
CostDatabase & costDatabase(const HDB::HDBManager &hdb)

References AssocTools::containsKey(), costDatabase(), and registry_.

Referenced by CostDatabase::instance().

Here is the call graph for this function:

◆ costDatabase() [1/2]

CostDatabase & CostDatabaseRegistry::costDatabase ( const HDB::HDBManager hdb)

Returns CostDatabase that is build against the HDB at given path.

In case the CostDatabase is not found in registry, tries to generate it.

Parameters
hdbFileNameFile name of the HDB to build the CostDatabase against.
Returns
The CostDatabase build against the HDB file.
Exceptions
ExceptionIn case there was a problem while creating the CostDatabase.

Definition at line 79 of file CostDatabaseRegistry.cc.

79 {
81 return *registry_[&hdb];
82 }
84 registry_[&hdb] = costDatabase;
85 return *costDatabase;
86}
static CostDatabase & instance(const HDB::HDBManager &hdb)

References AssocTools::containsKey(), costDatabase(), CostDatabase::instance(), and registry_.

Referenced by addCostDatabase(), costDatabase(), InterpolatingFUEstimator::initializeEstimator(), InterpolatingRFEstimator::initializeEstimator(), and CostDatabase::instance().

Here is the call graph for this function:

◆ costDatabase() [2/2]

CostDatabase & CostDatabaseRegistry::costDatabase ( unsigned int  index)

Returns the CostDatabase from given index.

Returns
The CostDatabase from the given index.
Exceptions
OutOfRangeIs thrown if index is bigger than the CostDatabase count.

Definition at line 143 of file CostDatabaseRegistry.cc.

143 {
144 if (index > (registry_.size() - 1)) {
145 throw OutOfRange(__FILE__, __LINE__,
146 "CostDatabaseRegistry::costDatavase(unsigned int)");
147 }
148 std::map<const HDB::HDBManager*, CostDatabase*>::const_iterator iter =
149 registry_.begin();
150 for (unsigned int counter = 0; iter != registry_.end(); iter++) {
151 if (counter == index) {
152 break;
153 } else {
154 counter++;
155 }
156 }
157 return *(*iter).second;
158}

References registry_.

◆ costDatabaseCount()

int CostDatabaseRegistry::costDatabaseCount ( )

Returns the total number of stored CostDatabases.

Returns
Count of stored CostDatabases.

Definition at line 130 of file CostDatabaseRegistry.cc.

130 {
131
132 return registry_.size();
133}

References registry_.

◆ hasCostDatabase()

bool CostDatabaseRegistry::hasCostDatabase ( const HDB::HDBManager hdb)

Returns true if the registry contains a CostDatabase build against the given HDB.

Parameters
hdbThe HDB that is used in creating the CostDatabase.
Returns
True if the registry contains a CostDatabase build against the given HDB.

Definition at line 115 of file CostDatabaseRegistry.cc.

115 {
116
118 return true;
119 } else {
120 return false;
121 }
122}

References AssocTools::containsKey(), and registry_.

Referenced by CostDatabase::instance().

Here is the call graph for this function:

◆ hdbPath()

std::string CostDatabaseRegistry::hdbPath ( unsigned int  index)

Returns the full path of the HDB with given index.

Returns
The HDB file path.
Exceptions
OutOfRangeIs thrown if index is out of range.

Definition at line 167 of file CostDatabaseRegistry.cc.

167 {
168 if (index > (registry_.size() - 1)) {
169 throw OutOfRange(__FILE__, __LINE__,
170 "CostDatabaseRegistry::hdbPath(unsigned int)");
171 }
172 std::map<const HDB::HDBManager*, CostDatabase*>::const_iterator iter =
173 registry_.begin();
174
175 for (unsigned c = 0; iter != registry_.end(); iter++) {
176 if (c == index) return (*iter).first->fileName();
177 c++;
178 }
179 assert(false);
180}
#define assert(condition)

References assert, and registry_.

◆ instance()

CostDatabaseRegistry & CostDatabaseRegistry::instance ( )
static

Creates and returns an instance of cost database registry.

Returns
An instance of cost database registry.

Definition at line 60 of file CostDatabaseRegistry.cc.

60 {
61
62 if (instance_ == NULL) {
64 }
65 return *instance_;
66}
CostDatabaseRegistry()
CostDatabase registry must be created with instance() method.

References CostDatabaseRegistry(), and instance_.

Referenced by CostDatabase::instance(), InterpolatingFUEstimator::InterpolatingFUEstimator(), and InterpolatingRFEstimator::InterpolatingRFEstimator().

Here is the call graph for this function:

Member Data Documentation

◆ instance_

CostDatabaseRegistry * CostDatabaseRegistry::instance_ = NULL
staticprivate

Unique instance of the class.

Definition at line 65 of file CostDatabaseRegistry.hh.

Referenced by instance(), and ~CostDatabaseRegistry().

◆ registry_

std::map<const HDB::HDBManager*, CostDatabase*> CostDatabaseRegistry::registry_
private

All created CostDatabasess are stored in this map.

Definition at line 63 of file CostDatabaseRegistry.hh.

Referenced by addCostDatabase(), costDatabase(), costDatabase(), costDatabaseCount(), hasCostDatabase(), hdbPath(), and ~CostDatabaseRegistry().


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