OpenASIP  2.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
HDB::CachedHDBManager Class Reference

#include <CachedHDBManager.hh>

Inheritance diagram for HDB::CachedHDBManager:
Inheritance graph
Collaboration diagram for HDB::CachedHDBManager:
Collaboration graph

Public Member Functions

virtual ~CachedHDBManager ()
 
virtual void removeFUArchitecture (RowID archID) const
 
virtual void removeFUImplementation (RowID id) const
 
virtual void removeRFArchitecture (RowID archID) const
 
virtual void removeRFImplementation (RowID archID) const
 
virtual void modifyCostFunctionPlugin (RowID id, const CostFunctionPlugin &plugin)
 
virtual void removeCostFunctionPlugin (RowID pluginID) const
 
virtual void removeFUEntry (RowID id) const
 
virtual void removeRFEntry (RowID id) const
 
virtual void removeBusEntry (RowID id) const
 
virtual void removeSocketEntry (RowID id) const
 
virtual void removeCostEstimationData (RowID id) const
 
virtual void modifyCostEstimationData (RowID id, const CostEstimationData &data)
 
virtual FUArchitecturefuArchitectureByID (RowID id) const
 
virtual RFArchitecturerfArchitectureByID (RowID id) const
 
virtual DataObject costEstimationDataValue (const std::string &valueName, const std::string &pluginName) const
 
const FUArchitecturefuArchitectureByIDConst (RowID id) const
 
const RFArchitecturerfArchitectureByIDConst (RowID id) const
 
virtual void deleteCostEstimationDataIDsQueries () const
 
virtual std::set< RowIDcostEstimationDataIDs (const CostEstimationData &match, bool useCompiledQueries=false, RelationalDBQueryResult *compiledQuery=NULL) const
 
- Public Member Functions inherited from HDB::HDBManager
virtual ~HDBManager ()
 
std::string fileName () const
 
RowID addCostFunctionPlugin (const CostFunctionPlugin &plugin) const
 
RowID addFUArchitecture (const FUArchitecture &architecture) const
 
bool canRemoveFUArchitecture (RowID archID) const
 
RowID addFUEntry () const
 
RowID addFUImplementation (const FUEntry &entry) const
 
void setArchitectureForFU (RowID fuID, RowID archID) const
 
void unsetArchitectureForFU (RowID fuID) const
 
RowID addRFArchitecture (const RFArchitecture &architecture) const
 
bool canRemoveRFArchitecture (RowID archID) const
 
RowID addRFEntry () const
 
RowID addRFImplementation (const RFImplementation &implementation, RowID rfEntryID)
 
void setArchitectureForRF (RowID rfID, RowID archID) const
 
void unsetArchitectureForRF (RowID rfID) const
 
void setCostFunctionPluginForFU (RowID fuID, RowID pluginID) const
 
void unsetCostFunctionPluginForFU (RowID fuID) const
 
void setCostFunctionPluginForRF (RowID rfID, RowID pluginID) const
 
void unsetCostFunctionPluginForRF (RowID rfID) const
 
std::set< RowIDfuEntryIDs () const
 
std::set< RowIDrfEntryIDs () const
 
std::set< RowIDbusEntryIDs () const
 
std::set< RowIDsocketEntryIDs () const
 
std::set< RowIDOperationImplementationIDs () const
 
std::set< RowIDOperationImplementationResourceIDs () const
 
OperationImplementation OperationImplementationByID (RowID id) const
 
OperationImplementationResource OperationImplementationResourceByID (RowID id) const
 
void addOperationImplementationResource (const OperationImplementationResource &resource)
 
void addOperationImplementation (const OperationImplementation &operation)
 
void removeOperationImplementation (RowID id)
 
void removeOperationImplementationResource (RowID id)
 
std::set< RowIDfuArchitectureIDs () const
 
std::set< RowIDfuArchitectureIDsByOperationSet (const std::set< std::string > &operationNames) const
 
std::set< RowIDrfArchitectureIDs () const
 
RowID fuEntryIDOfImplementation (RowID implID) const
 
RowID rfEntryIDOfImplementation (RowID implID) const
 
FUEntryfuByEntryID (RowID id) const
 
RFEntryrfByEntryID (RowID id) const
 
std::set< RowIDfuEntriesByArchitecture (const TTAMachine::FunctionUnit &fu) const
 
std::set< RowIDrfEntriesByArchitecture (int readPorts, int writePorts, int bidirPorts, int maxReads, int maxWrites, int latency, bool guardSupport, int guardLatency=0, int width=0, int size=0, bool zeroRegister=false) const
 
DataObject costEstimationDataValue (RowID entryId) const
 
RowID addFUCostEstimationData (RowID fuID, const std::string &valueName, const std::string &value, RowID pluginID) const
 
RowID addRFCostEstimationData (RowID rfID, const std::string &valueName, const std::string &value, RowID pluginID) const
 
DataObject fuCostEstimationData (const std::string &valueName, RowID implementationId, const std::string &pluginName) const
 
DataObject rfCostEstimationData (const std::string &valueName, RowID implementationId, const std::string &pluginName) const
 
RowID addBusEntry () const
 
RowID addBusCostEstimationData (RowID busID, const std::string &valueName, const std::string &value, RowID pluginID) const
 
DataObject busCostEstimationData (const std::string &valueName, RowID busID, const std::string &pluginName) const
 
DataObjectListbusCostEstimationDataList (const std::string &valueName, RowID implementationId, const std::string &pluginName) const
 
RowID addSocketEntry () const
 
RowID addSocketCostEstimationData (RowID socketID, const std::string &valueName, const std::string &value, RowID pluginID) const
 
DataObject socketCostEstimationData (const std::string &valueName, RowID socketID, const std::string &pluginName) const
 
DataObjectListsocketCostEstimationDataList (const std::string &valueName, RowID implementationID, const std::string &pluginName) const
 
std::set< RowIDfuCostEstimationDataIDs (RowID fuImplID) const
 
std::set< RowIDrfCostEstimationDataIDs (RowID rfImplID) const
 
std::set< RowIDbusCostEstimationDataIDs (RowID busID) const
 
std::set< RowIDsocketCostEstimationDataIDs (RowID socketID) const
 
CostEstimationData costEstimationData (RowID id) const
 
std::set< RowIDcostFunctionPluginIDs () const
 
std::set< RowIDcostFunctionPluginDataIDs (RowID pluginID) const
 
CostFunctionPlugincostFunctionPluginByID (RowID pluginID) const
 
RowID addCostEstimationData (const CostEstimationData &data) const
 
std::list< std::string > blockSourceFile ()
 

Static Public Member Functions

static CachedHDBManagerinstance (const std::string &hdbFile)
 
static CachedHDBManagercreateNew (const std::string &fileName)
 
- Static Public Member Functions inherited from HDB::HDBManager
static void createNew (const std::string &file)
 
static std::string formatString (BlockImplementationFile::Format format)
 

Private Member Functions

 CachedHDBManager (const std::string &hdbFile)
 
virtual RFImplementationcreateImplementationOfRF (RowID id) const
 
virtual FUImplementationcreateImplementationOfFU (FUArchitecture &architecture, RowID id) const
 
void validateCache () const
 

Private Attributes

std::map< RowID, FUArchitecture * > fuArchCache_
 FU Architecture cache. More...
 
std::map< RowID, RFArchitecture * > rfArchCache_
 RF Architecture cache. More...
 
std::map< RowID, FUImplementation * > fuImplCache_
 FU Implementation cache. More...
 
std::map< RowID, RFImplementation * > rfImplCache_
 RF Implementation cache. More...
 
std::map< std::string, std::map< std::string, DataObject > > costEstimationPluginValueCache_
 Cost estimation plugin value cache (pluginName/valueName) More...
 
std::map< short int, RelationalDBQueryResult * > costEstimationDataIDsQueries_
 map of cached (compiled) queries for costEstimatioDataIDs function More...
 
std::time_t lastModificationTime_
 used to detect modifications to the HDB file (which invalidates cache) More...
 
uintmax_t lastSizeInBytes_
 used to detect modifications to the HDB file (which invalidates cache) More...
 

Additional Inherited Members

- Public Types inherited from HDB::HDBManager
typedef std::list< DataObjectDataObjectList
 
- Protected Member Functions inherited from HDB::HDBManager
void createCostEstimatioDataIdsQuery (const CostEstimationData &match, std::string *query, RelationalDBQueryResult *compiledQuery=NULL, short int *queryHash=NULL, bool createBindableQuery=false) const
 
RelationalDBConnectiongetDBConnection () const
 
 HDBManager (const std::string &hdbFile)
 

Detailed Description

Cached interface to HDBs.

HDBManager class queries HDB file every time the manager is queried for an object in the database. Queries to the database are time consuming, especially when constructing FU and RF implementation objects based on data scattered across multiple HDB tables. CachedHDBManager caches the queried objects in memory, resulting in significant speedups if the same objects are queried repeatedly without any modifications to the related data in the HDB.

IMPORTANT NOTE:

If a new function which modifies or removes cached objects is added to the HDBManager, it must be derived here to remove corresponding objects from the cache! Please check that all functions you are using that modify cached data are reimplemented to remove cached objects.

Definition at line 63 of file CachedHDBManager.hh.

Constructor & Destructor Documentation

◆ ~CachedHDBManager()

CachedHDBManager::~CachedHDBManager ( )
virtual

The Destructor.

Deletes all cached items.

Definition at line 69 of file CachedHDBManager.cc.

References costEstimationPluginValueCache_, MapTools::deleteAllValues(), fuArchCache_, fuImplCache_, rfArchCache_, and rfImplCache_.

Here is the call graph for this function:

◆ CachedHDBManager()

CachedHDBManager::CachedHDBManager ( const std::string &  hdbFile)
private

The Constructor.

Parameters
hdbFileHDBFile to open.
Exceptions
IOExceptionif an error occured opening the HDB file.

Definition at line 58 of file CachedHDBManager.cc.

References FileSystem::lastModificationTime(), lastModificationTime_, lastSizeInBytes_, and FileSystem::sizeInBytes().

Referenced by instance().

Here is the call graph for this function:

Member Function Documentation

◆ costEstimationDataIDs()

std::set< RowID > CachedHDBManager::costEstimationDataIDs ( const CostEstimationData match,
bool  useCompiledQueries = false,
RelationalDBQueryResult compiledQuery = NULL 
) const
virtual

Wrapper for HDBManager costEstimationDataIDs.

Compiles and caches queries for HDBManager costEstimationDataIDs function.

Reimplemented from HDB::HDBManager.

Definition at line 517 of file CachedHDBManager.cc.

520  {
521 
522  if (!useCompiledQueries) {
523  return HDBManager::costEstimationDataIDs(match);
524  }
525 
526  // query hash (bit vector might be better suited for this)
527  short int queryHash = 0;
528  // calculate query hash only to identify the query
529  HDBManager::createCostEstimatioDataIdsQuery(match, NULL, NULL, &queryHash);
530 
531  // check if query already exists
532  std::map<short int,RelationalDBQueryResult*>::iterator it =
533  costEstimationDataIDsQueries_.find(queryHash);
534 
535  if (costEstimationDataIDsQueries_.end() != it) {
536  // if query already existed use it
537  return HDBManager::costEstimationDataIDs(match, true, it->second);
538  } else {
539  // else create a new compiledQuery and use it
540  assert(queryHash != 0);
541  std::string query = "";
542  // create bindable query
543  HDBManager::createCostEstimatioDataIdsQuery(match, &query, NULL, NULL, true);
544  compiledQuery = HDBManager::getDBConnection()->query(query, false);
545  costEstimationDataIDsQueries_[queryHash] = compiledQuery;
546  return HDBManager::costEstimationDataIDs(match, true, compiledQuery);
547  }
548 }

References assert, HDB::HDBManager::costEstimationDataIDs(), costEstimationDataIDsQueries_, HDB::HDBManager::createCostEstimatioDataIdsQuery(), HDB::HDBManager::getDBConnection(), and RelationalDBConnection::query().

Here is the call graph for this function:

◆ costEstimationDataValue()

DataObject CachedHDBManager::costEstimationDataValue ( const std::string &  valueName,
const std::string &  pluginName 
) const
virtual

Returns cost estimation data which is not connected to any machine implementation id.

This version assumes that there's only one entry with given parameters. Caches values by plugin name.

Parameters
valueNameName of the value to fetch.
pluginNameName of the cost estimation plugin that owns the data.
Returns
The data.
Exceptions
KeyNotFoundIf the HDB does not contain cost estimation data with the given arguments.

Reimplemented from HDB::HDBManager.

Definition at line 271 of file CachedHDBManager.cc.

272  {
273  validateCache();
274 
275  std::map<std::string, std::map<std::string, DataObject> >::iterator iter =
276  costEstimationPluginValueCache_.find(pluginName);
277 
278  if (iter != costEstimationPluginValueCache_.end()) {
279  std::map<std::string, DataObject>::iterator it =
280  (*iter).second.find(valueName);
281  if (it != (*iter).second.end()) {
282  return (*it).second;
283  } else {
284  DataObject dataObject = HDBManager::costEstimationDataValue(valueName, pluginName);
285  (*iter).second[valueName] = dataObject;
286  return dataObject;
287  }
288  } else {
289  std::map<std::string, DataObject> temp;
290  DataObject dataObject = HDBManager::costEstimationDataValue(valueName, pluginName);
291  temp[valueName] = dataObject;
292  costEstimationPluginValueCache_[pluginName] = temp;
293  return dataObject;
294  }
295 }

References HDB::HDBManager::costEstimationDataValue(), costEstimationPluginValueCache_, and validateCache().

Here is the call graph for this function:

◆ createImplementationOfFU()

FUImplementation * CachedHDBManager::createImplementationOfFU ( FUArchitecture architecture,
RowID  id 
) const
privatevirtual

Returns implementation of a FU with the given index.

Returns NULL if the FU doesn't have implementation.

First the FU implementation cache is searched for the ID, if the implementation is found in the cache, a copy of the cached item is returned. If the implementation was not found in the cache, a DB query is made using the base class implementation and the item is then added to the cache.

Parameters
idID of the FU implementation.
Returns
FU implementation.

Reimplemented from HDB::HDBManager.

Definition at line 461 of file CachedHDBManager.cc.

462  {
463 
464  validateCache();
465 
466  std::map<RowID, FUImplementation*>::iterator iter = fuImplCache_.find(id);
467  if (iter != fuImplCache_.end()) {
468  return new FUImplementation(*(*iter).second);
469  }
470 
471  FUImplementation* impl =
472  HDBManager::createImplementationOfFU(architecture, id);
473 
474  if (impl != NULL) {
475  fuImplCache_[id] = impl;
476  return new FUImplementation(*impl);
477  } else {
478  return NULL;
479  }
480 }

References HDB::HDBManager::createImplementationOfFU(), fuImplCache_, and validateCache().

Here is the call graph for this function:

◆ createImplementationOfRF()

RFImplementation * CachedHDBManager::createImplementationOfRF ( RowID  id) const
privatevirtual

Returns implementation of a RF with the given index.

Returns NULL if the RF doesn't have implementation.

First the RF implementation cache is searched for the ID, if the implementation is found in the cache, a copy of the cached item is returned. If the implementation was not found in the cache, a DB query is made using the base class implementation and the item is then added to the cache.

Parameters
idID of the RF implementation.
Returns
RF implementation.

Reimplemented from HDB::HDBManager.

Definition at line 427 of file CachedHDBManager.cc.

427  {
428 
429  validateCache();
430 
431  std::map<RowID, RFImplementation*>::iterator iter = rfImplCache_.find(id);
432  if (iter != rfImplCache_.end()) {
433  return new RFImplementation(*(*iter).second);
434  }
435 
437 
438  if (impl != NULL) {
439  rfImplCache_[id] = impl;
440  return new RFImplementation(*impl);
441  } else {
442  return NULL;
443  }
444 }

References HDB::HDBManager::createImplementationOfRF(), rfImplCache_, and validateCache().

Here is the call graph for this function:

◆ createNew()

CachedHDBManager & CachedHDBManager::createNew ( const std::string &  file)
static

Creates a new HDB and returns CachedHDBManager instance for accessing it.

Parameters
fileFull path of the new HDB file.
Returns
CachedHDBManager instance accessing the newly created HDB.
Exceptions
UnreachableStreamIf the HDB creation was not succesful.

Definition at line 105 of file CachedHDBManager.cc.

105  {
106  HDBManager::createNew(file);
107  return instance(file);
108 }

References HDB::HDBManager::createNew(), and instance().

Referenced by HDBEditorMainFrame::createHDB().

Here is the call graph for this function:

◆ deleteCostEstimationDataIDsQueries()

void CachedHDBManager::deleteCostEstimationDataIDsQueries ( ) const
virtual

Deletes cached costEstimationDataIDs queries.

Implements HDB::HDBManager.

Definition at line 555 of file CachedHDBManager.cc.

555  {
556  std::map<short int,RelationalDBQueryResult*>::iterator it =
558 
559  while (it != costEstimationDataIDsQueries_.end()) {
560  delete it->second;
561  it->second = NULL;
562  ++it;
563  }
565 }

References costEstimationDataIDsQueries_.

◆ fuArchitectureByID()

FUArchitecture * CachedHDBManager::fuArchitectureByID ( RowID  id) const
virtual

Returns FU architecture with the given ID.

First the fu architecture cache is searched for the ID, if the architecture is found in the cache, a copy of the cached item is returned. If the architecture was not found in the cache, a DB query is made using the base class implementation and the item is then added to the cache.

Parameters
idID of the fu architecture.
Returns
FUArchitecture object with the give ID.
Exceptions
KeyNotFoundif an architecture with the given id was not found.

Reimplemented from HDB::HDBManager.

Definition at line 218 of file CachedHDBManager.cc.

218  {
219  validateCache();
220 
221  std::map<RowID, FUArchitecture*>::iterator iter = fuArchCache_.find(id);
222  if (iter != fuArchCache_.end()) {
223  return new FUArchitecture(*(*iter).second);
224  }
225 
227  fuArchCache_[id] = arch;
228  return new FUArchitecture(*arch);
229 }

References fuArchCache_, HDB::HDBManager::fuArchitectureByID(), and validateCache().

Referenced by ComponentImplementationSelector::fuArchsByOpSetWithMinLatency().

Here is the call graph for this function:

◆ fuArchitectureByIDConst()

const FUArchitecture & CachedHDBManager::fuArchitectureByIDConst ( RowID  id) const

Definition at line 484 of file CachedHDBManager.cc.

484  {
485 
486  validateCache();
487 
488  std::map<RowID, FUArchitecture*>::iterator iter = fuArchCache_.find(id);
489  if (iter == fuArchCache_.end()) {
491  fuArchCache_[id] = arch;
492  }
493  return *fuArchCache_[id];
494 }

References fuArchCache_, HDB::HDBManager::fuArchitectureByID(), and validateCache().

Here is the call graph for this function:

◆ instance()

CachedHDBManager & CachedHDBManager::instance ( const std::string &  hdbFile)
static

Returns a CachedHDBManager instance for the given file.

Only one instance is created per file.

Parameters
hdbFileName of the HDB file to open.
Returns
An instance of HDBManager.
Exceptions
IOExceptionIf connection to the DB cannot be established.

Definition at line 89 of file CachedHDBManager.cc.

89  {
90  HDBRegistry* registry = &HDBRegistry::instance();
91  if (!registry->hasHDB(hdbFile)) {
92  registry->addHDB(new CachedHDBManager(hdbFile));
93  }
94  return registry->hdb(hdbFile);
95 }

References HDB::HDBRegistry::addHDB(), CachedHDBManager(), HDB::HDBRegistry::hasHDB(), HDB::HDBRegistry::hdb(), and HDB::HDBRegistry::instance().

Referenced by Automagic::checkForSelectableFU(), ProGeTools::checkForSelectableFU(), Automagic::checkForSelectableIU(), ProGeTools::checkForSelectableIU(), ProGeTools::checkForSelectableRF(), Automagic::checkForSelectableRF(), Automagic::createFUGeneratableOperationInfos(), ProGeTools::createFUGeneratableOperationInfos(), FUGen::createImplementationFiles(), createNew(), HDB::HDBRegistry::hdb(), HDB::HDBRegistry::loadFromSearchPaths(), ImplementationTester::openHdb(), and FUGen::parseOperations().

Here is the call graph for this function:

◆ modifyCostEstimationData()

void CachedHDBManager::modifyCostEstimationData ( RowID  id,
const CostEstimationData data 
)
virtual

Cached (invalidates cache) function of HDBManager::modifyCostEstimationData.

Parameters
id
data
Exceptions
InvalidData
KeyNotFound

Reimplemented from HDB::HDBManager.

Definition at line 405 of file CachedHDBManager.cc.

406  {
409 }

References costEstimationPluginValueCache_, and HDB::HDBManager::modifyCostEstimationData().

Here is the call graph for this function:

◆ modifyCostFunctionPlugin()

void CachedHDBManager::modifyCostFunctionPlugin ( RowID  id,
const CostFunctionPlugin plugin 
)
virtual

Cached (invalidates cache) function of HDBManager::modifyCostFunctionPlugin.

Parameters
id
plugin
Exceptions
InvalidData
KeyNotFound

Reimplemented from HDB::HDBManager.

Definition at line 307 of file CachedHDBManager.cc.

308  {
309  // can't say by rowid what plugin is modified
311 
313 }

References costEstimationPluginValueCache_, and HDB::HDBManager::modifyCostFunctionPlugin().

Here is the call graph for this function:

◆ removeBusEntry()

void CachedHDBManager::removeBusEntry ( RowID  id) const
virtual

Cached (invalidates cache) function of HDBManager::removeBusEntry.

Parameters
id

Reimplemented from HDB::HDBManager.

Definition at line 363 of file CachedHDBManager.cc.

363  {
364 
367 }

References costEstimationPluginValueCache_, and HDB::HDBManager::removeBusEntry().

Here is the call graph for this function:

◆ removeCostEstimationData()

void CachedHDBManager::removeCostEstimationData ( RowID  id) const
virtual

Cached (invalidates cache) function of HDBManager::removeCostEstimationData.

Parameters
id

Reimplemented from HDB::HDBManager.

Definition at line 389 of file CachedHDBManager.cc.

389  {
390 
393 }

References costEstimationPluginValueCache_, and HDB::HDBManager::removeCostEstimationData().

Here is the call graph for this function:

◆ removeCostFunctionPlugin()

void CachedHDBManager::removeCostFunctionPlugin ( RowID  pluginID) const
virtual

Cached (invalidates cache) function of HDBManager::removeCostFunctionPlugin.

Parameters
pluginID

Reimplemented from HDB::HDBManager.

Definition at line 322 of file CachedHDBManager.cc.

322  {
323 
324  // can't say by rowid what plugin is removed
326 
328 }

References costEstimationPluginValueCache_, and HDB::HDBManager::removeCostFunctionPlugin().

Here is the call graph for this function:

◆ removeFUArchitecture()

void CachedHDBManager::removeFUArchitecture ( RowID  archID) const
virtual

Removes FU architecture from the HDB.

Removes architecture from the cache and calls base class function to actually remove the FU architecture.

Parameters
archIDID of the FU architecture to remove.

Reimplemented from HDB::HDBManager.

Definition at line 119 of file CachedHDBManager.cc.

119  {
120  // Remove architecture from the cache.
121  std::map<RowID, FUArchitecture*>::iterator iter =
122  fuArchCache_.find(archID);
123 
124  if (iter != fuArchCache_.end()) {
125  delete (*iter).second;
126  fuArchCache_.erase(iter);
127  }
128 
130 }

References fuArchCache_, and HDB::HDBManager::removeFUArchitecture().

Here is the call graph for this function:

◆ removeFUEntry()

void CachedHDBManager::removeFUEntry ( RowID  id) const
virtual

Cached (invalidates cache) function of HDBManager::removeFUEntry.

Parameters
id

Reimplemented from HDB::HDBManager.

Definition at line 337 of file CachedHDBManager.cc.

337  {
338 
341 }

References costEstimationPluginValueCache_, and HDB::HDBManager::removeFUEntry().

Here is the call graph for this function:

◆ removeFUImplementation()

void CachedHDBManager::removeFUImplementation ( RowID  id) const
virtual

Removes FU implementation from the HDB.

Removes implementation from the cache and calls base class function to actually remove the FU implementation.

Parameters
idID of the FU implementation to remove.

Reimplemented from HDB::HDBManager.

Definition at line 141 of file CachedHDBManager.cc.

141  {
142 
143  RowID entryID = fuEntryIDOfImplementation(id);
144 
145  // Remove implementation from the cache.
146  std::map<RowID, FUImplementation*>::iterator iter =
147  fuImplCache_.find(entryID);
148 
149  if (iter != fuImplCache_.end()) {
150  delete (*iter).second;
151  fuImplCache_.erase(iter);
152  }
153 
155 }

References HDB::HDBManager::fuEntryIDOfImplementation(), fuImplCache_, and HDB::HDBManager::removeFUImplementation().

Here is the call graph for this function:

◆ removeRFArchitecture()

void CachedHDBManager::removeRFArchitecture ( RowID  archID) const
virtual

Removes RF architecture from the HDB.

Removes architecture from the cache and calls base class function to actually remove the RF architecture.

Parameters
archIDID of the RF architecture to remove.

Reimplemented from HDB::HDBManager.

Definition at line 167 of file CachedHDBManager.cc.

167  {
168  // Remove architecture from the cache.
169  std::map<RowID, RFArchitecture*>::iterator iter =
170  rfArchCache_.find(archID);
171 
172  if (iter != rfArchCache_.end()) {
173  delete (*iter).second;
174  rfArchCache_.erase(iter);
175  }
176 
178 }

References HDB::HDBManager::removeRFArchitecture(), and rfArchCache_.

Here is the call graph for this function:

◆ removeRFEntry()

void CachedHDBManager::removeRFEntry ( RowID  id) const
virtual

Cached (invalidates cache) function of HDBManager::removeRFEntry.

Parameters
id

Reimplemented from HDB::HDBManager.

Definition at line 350 of file CachedHDBManager.cc.

350  {
351 
354 }

References costEstimationPluginValueCache_, and HDB::HDBManager::removeRFEntry().

Here is the call graph for this function:

◆ removeRFImplementation()

void CachedHDBManager::removeRFImplementation ( RowID  id) const
virtual

Removes RF implementation from the HDB.

Removes implementation from the cache and calls base class function to actually remove the RF implementation.

Parameters
idID of the RF implementation to remove.

Reimplemented from HDB::HDBManager.

Definition at line 189 of file CachedHDBManager.cc.

189  {
190 
191  RowID entryID = rfEntryIDOfImplementation(id);
192 
193  // Remove implementation from the cache.
194  std::map<RowID, RFImplementation*>::iterator iter =
195  rfImplCache_.find(entryID);
196 
197  if (iter != rfImplCache_.end()) {
198  delete (*iter).second;
199  rfImplCache_.erase(iter);
200  }
201 
203 }

References HDB::HDBManager::removeRFImplementation(), HDB::HDBManager::rfEntryIDOfImplementation(), and rfImplCache_.

Here is the call graph for this function:

◆ removeSocketEntry()

void CachedHDBManager::removeSocketEntry ( RowID  id) const
virtual

Cached (invalidates cache) function of HDBManager::removeSocketEntry.

Parameters
id

Reimplemented from HDB::HDBManager.

Definition at line 376 of file CachedHDBManager.cc.

376  {
377 
380 }

References costEstimationPluginValueCache_, and HDB::HDBManager::removeSocketEntry().

Here is the call graph for this function:

◆ rfArchitectureByID()

RFArchitecture * CachedHDBManager::rfArchitectureByID ( RowID  id) const
virtual

Returns RF architecture with the given ID.

First the RF architecture cache is searched for the ID, if the architecture is found in the cache, a copy of the cached item is returned. If the architecture was not found in the cache, a DB query is made using the base class implementation and the item is then added to the cache.

Parameters
idID of the fu architecture.
Returns
RFArchitecture object with the give ID.
Exceptions
KeyNotFoundif an architecture with the given id was not found.

Reimplemented from HDB::HDBManager.

Definition at line 244 of file CachedHDBManager.cc.

244  {
245  validateCache();
246 
247  std::map<RowID, RFArchitecture*>::iterator iter = rfArchCache_.find(id);
248  if (iter != rfArchCache_.end()) {
249  return new RFArchitecture(*(*iter).second);
250  }
251 
253  rfArchCache_[id] = arch;
254  return new RFArchitecture(*arch);
255 }

References rfArchCache_, HDB::HDBManager::rfArchitectureByID(), and validateCache().

Here is the call graph for this function:

◆ rfArchitectureByIDConst()

const RFArchitecture & CachedHDBManager::rfArchitectureByIDConst ( RowID  id) const

Definition at line 498 of file CachedHDBManager.cc.

498  {
499 
500  validateCache();
501 
502  std::map<RowID, RFArchitecture*>::iterator iter = rfArchCache_.find(id);
503  if (iter == rfArchCache_.end()) {
505  rfArchCache_[id] = arch;
506  }
507  return *rfArchCache_[id];
508 }

References rfArchCache_, HDB::HDBManager::rfArchitectureByID(), and validateCache().

Here is the call graph for this function:

◆ validateCache()

void CachedHDBManager::validateCache ( ) const
private

Checks if HDB file is modified. In case it is, invalid cache is cleared.

Definition at line 572 of file CachedHDBManager.cc.

572  {
573  std::string hdbFile = HDBManager::fileName();
574  std::time_t modTime = FileSystem::lastModificationTime(hdbFile);
575  uintmax_t byteSize = FileSystem::sizeInBytes(hdbFile);
576 
577  if (modTime == std::time_t(-1) ||
578  byteSize == static_cast<uintmax_t>(-1)) {
579  // problems accessing the file
580  return;
581  } else if (lastModificationTime_ == modTime &&
582  lastSizeInBytes_ == byteSize) {
583  // no changes
584  return;
585  }
586 
587  // delete all cached items
593 
594  // set current size and modification time
595  lastModificationTime_ = modTime;
596  lastSizeInBytes_ = byteSize;
597 }

References costEstimationPluginValueCache_, MapTools::deleteAllValues(), HDB::HDBManager::fileName(), fuArchCache_, fuImplCache_, FileSystem::lastModificationTime(), lastModificationTime_, lastSizeInBytes_, rfArchCache_, rfImplCache_, and FileSystem::sizeInBytes().

Referenced by costEstimationDataValue(), createImplementationOfFU(), createImplementationOfRF(), fuArchitectureByID(), fuArchitectureByIDConst(), rfArchitectureByID(), and rfArchitectureByIDConst().

Here is the call graph for this function:

Member Data Documentation

◆ costEstimationDataIDsQueries_

std::map<short int, RelationalDBQueryResult*> HDB::CachedHDBManager::costEstimationDataIDsQueries_
mutableprivate

map of cached (compiled) queries for costEstimatioDataIDs function

Definition at line 143 of file CachedHDBManager.hh.

Referenced by costEstimationDataIDs(), and deleteCostEstimationDataIDsQueries().

◆ costEstimationPluginValueCache_

std::map<std::string, std::map<std::string, DataObject> > HDB::CachedHDBManager::costEstimationPluginValueCache_
mutableprivate

◆ fuArchCache_

std::map<RowID, FUArchitecture*> HDB::CachedHDBManager::fuArchCache_
mutableprivate

FU Architecture cache.

Definition at line 130 of file CachedHDBManager.hh.

Referenced by fuArchitectureByID(), fuArchitectureByIDConst(), removeFUArchitecture(), validateCache(), and ~CachedHDBManager().

◆ fuImplCache_

std::map<RowID, FUImplementation*> HDB::CachedHDBManager::fuImplCache_
mutableprivate

FU Implementation cache.

Definition at line 134 of file CachedHDBManager.hh.

Referenced by createImplementationOfFU(), removeFUImplementation(), validateCache(), and ~CachedHDBManager().

◆ lastModificationTime_

std::time_t HDB::CachedHDBManager::lastModificationTime_
mutableprivate

used to detect modifications to the HDB file (which invalidates cache)

Definition at line 146 of file CachedHDBManager.hh.

Referenced by CachedHDBManager(), and validateCache().

◆ lastSizeInBytes_

uintmax_t HDB::CachedHDBManager::lastSizeInBytes_
mutableprivate

used to detect modifications to the HDB file (which invalidates cache)

Definition at line 148 of file CachedHDBManager.hh.

Referenced by CachedHDBManager(), and validateCache().

◆ rfArchCache_

std::map<RowID, RFArchitecture*> HDB::CachedHDBManager::rfArchCache_
mutableprivate

RF Architecture cache.

Definition at line 132 of file CachedHDBManager.hh.

Referenced by removeRFArchitecture(), rfArchitectureByID(), rfArchitectureByIDConst(), validateCache(), and ~CachedHDBManager().

◆ rfImplCache_

std::map<RowID, RFImplementation*> HDB::CachedHDBManager::rfImplCache_
mutableprivate

RF Implementation cache.

Definition at line 136 of file CachedHDBManager.hh.

Referenced by createImplementationOfRF(), removeRFImplementation(), validateCache(), and ~CachedHDBManager().


The documentation for this class was generated from the following files:
HDB::CachedHDBManager::costEstimationPluginValueCache_
std::map< std::string, std::map< std::string, DataObject > > costEstimationPluginValueCache_
Cost estimation plugin value cache (pluginName/valueName)
Definition: CachedHDBManager.hh:139
HDB::FUArchitecture
Definition: FUArchitecture.hh:55
HDB::HDBManager::createCostEstimatioDataIdsQuery
void createCostEstimatioDataIdsQuery(const CostEstimationData &match, std::string *query, RelationalDBQueryResult *compiledQuery=NULL, short int *queryHash=NULL, bool createBindableQuery=false) const
Definition: HDBManager.cc:6835
HDB::HDBManager::fuArchitectureByID
virtual FUArchitecture * fuArchitectureByID(RowID id) const
Definition: HDBManager.cc:2940
HDB::CachedHDBManager::lastSizeInBytes_
uintmax_t lastSizeInBytes_
used to detect modifications to the HDB file (which invalidates cache)
Definition: CachedHDBManager.hh:148
HDB::HDBManager::removeFUEntry
virtual void removeFUEntry(RowID id) const
Definition: HDBManager.cc:1039
DataObject
Definition: DataObject.hh:50
HDB::CachedHDBManager::fuArchCache_
std::map< RowID, FUArchitecture * > fuArchCache_
FU Architecture cache.
Definition: CachedHDBManager.hh:130
HDB::HDBManager::removeBusEntry
virtual void removeBusEntry(RowID id) const
Definition: HDBManager.cc:3418
HDB::HDBManager::removeRFEntry
virtual void removeRFEntry(RowID id) const
Definition: HDBManager.cc:1583
HDB::HDBManager::removeFUImplementation
virtual void removeFUImplementation(RowID implementationID) const
Definition: HDBManager.cc:1325
MapTools::deleteAllValues
static void deleteAllValues(MapType &aMap)
RowID
int RowID
Type definition of row ID in relational databases.
Definition: DBTypes.hh:37
HDB::HDBRegistry::hdb
CachedHDBManager & hdb(const std::string fileName)
Definition: HDBRegistry.cc:80
HDB::CachedHDBManager::costEstimationDataIDsQueries_
std::map< short int, RelationalDBQueryResult * > costEstimationDataIDsQueries_
map of cached (compiled) queries for costEstimatioDataIDs function
Definition: CachedHDBManager.hh:143
HDB::HDBRegistry::hasHDB
bool hasHDB(const std::string &hdbFile)
Definition: HDBRegistry.cc:119
HDB::HDBManager::removeSocketEntry
virtual void removeSocketEntry(RowID id) const
Definition: HDBManager.cc:3631
HDB::HDBManager::rfEntryIDOfImplementation
RowID rfEntryIDOfImplementation(RowID implID) const
Definition: HDBManager.cc:2796
HDB::CachedHDBManager::fuImplCache_
std::map< RowID, FUImplementation * > fuImplCache_
FU Implementation cache.
Definition: CachedHDBManager.hh:134
assert
#define assert(condition)
Definition: Application.hh:86
HDB::HDBManager::modifyCostEstimationData
virtual void modifyCostEstimationData(RowID id, const CostEstimationData &data)
Definition: HDBManager.cc:6999
HDB::RFImplementation
Definition: RFImplementation.hh:50
HDB::HDBRegistry
Definition: HDBRegistry.hh:46
HDB::CachedHDBManager::rfArchCache_
std::map< RowID, RFArchitecture * > rfArchCache_
RF Architecture cache.
Definition: CachedHDBManager.hh:132
FileSystem::lastModificationTime
static std::time_t lastModificationTime(const std::string &filePath)
Definition: FileSystem.cc:352
HDB::HDBManager::costEstimationDataValue
virtual DataObject costEstimationDataValue(const std::string &valueName, const std::string &pluginName) const
Definition: HDBManager.cc:3831
HDB::HDBManager::createNew
static void createNew(const std::string &file)
Definition: HDBManager.cc:548
HDB::HDBManager::rfArchitectureByID
virtual RFArchitecture * rfArchitectureByID(RowID id) const
Definition: HDBManager.cc:2963
HDB::HDBManager::HDBManager
HDBManager(const std::string &hdbFile)
Definition: HDBManager.cc:394
HDB::HDBManager::fuEntryIDOfImplementation
RowID fuEntryIDOfImplementation(RowID implID) const
Definition: HDBManager.cc:2765
RelationalDBConnection::query
virtual RelationalDBQueryResult * query(const std::string &queryString, bool init=true)=0
Definition: RelationalDBConnection.cc:80
FileSystem::sizeInBytes
static uintmax_t sizeInBytes(const std::string &filePath)
Definition: FileSystem.cc:376
HDB::HDBManager::removeCostFunctionPlugin
virtual void removeCostFunctionPlugin(RowID pluginID) const
Definition: HDBManager.cc:684
HDB::HDBManager::fileName
std::string fileName() const
Definition: HDBManager.cc:612
HDB::FUImplementation
Definition: FUImplementation.hh:53
HDB::RFArchitecture
Definition: RFArchitecture.hh:50
HDB::HDBManager::costEstimationDataIDs
virtual std::set< RowID > costEstimationDataIDs(const CostEstimationData &match, bool useCompiledQueries=false, RelationalDBQueryResult *compiledQuery=NULL) const
Definition: HDBManager.cc:6778
HDB::HDBManager::getDBConnection
RelationalDBConnection * getDBConnection() const
Definition: HDBManager.cc:6987
HDB::CachedHDBManager::CachedHDBManager
CachedHDBManager(const std::string &hdbFile)
Definition: CachedHDBManager.cc:58
HDB::HDBManager::removeCostEstimationData
virtual void removeCostEstimationData(RowID id) const
Definition: HDBManager.cc:5479
HDB::HDBManager::createImplementationOfFU
virtual FUImplementation * createImplementationOfFU(FUArchitecture &architecture, RowID id) const
Definition: HDBManager.cc:4615
HDB::HDBRegistry::addHDB
void addHDB(CachedHDBManager *hdbManager)
Definition: HDBRegistry.cc:100
HDB::HDBManager::removeRFImplementation
virtual void removeRFImplementation(RowID implID) const
Definition: HDBManager.cc:1808
HDB::CachedHDBManager::validateCache
void validateCache() const
Definition: CachedHDBManager.cc:572
HDB::HDBManager::removeFUArchitecture
virtual void removeFUArchitecture(RowID archID) const
Definition: HDBManager.cc:941
HDB::HDBManager::modifyCostFunctionPlugin
virtual void modifyCostFunctionPlugin(RowID id, const CostFunctionPlugin &plugin)
Definition: HDBManager.cc:7080
HDB::HDBManager::removeRFArchitecture
virtual void removeRFArchitecture(RowID archID) const
Definition: HDBManager.cc:1535
HDB::CachedHDBManager::lastModificationTime_
std::time_t lastModificationTime_
used to detect modifications to the HDB file (which invalidates cache)
Definition: CachedHDBManager.hh:146
HDB::HDBManager::createImplementationOfRF
virtual RFImplementation * createImplementationOfRF(RowID id) const
Definition: HDBManager.cc:4837
HDB::HDBRegistry::instance
static HDBRegistry & instance()
Definition: HDBRegistry.cc:62
HDB::CachedHDBManager::rfImplCache_
std::map< RowID, RFImplementation * > rfImplCache_
RF Implementation cache.
Definition: CachedHDBManager.hh:136
HDB::CachedHDBManager::instance
static CachedHDBManager & instance(const std::string &hdbFile)
Definition: CachedHDBManager.cc:89