OpenASIP  2.0
CostDatabase.hh
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 CostDatabase.hh
26  *
27  * Declaration of CostDatabase 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 #ifndef TTA_COST_DATABASE_HH
35 #define TTA_COST_DATABASE_HH
36 
37 
38 #include <vector>
39 #include <map>
40 #include <string>
41 #include "CompilerWarnings.hh"
42 IGNORE_CLANG_WARNING("-Wkeyword-macro")
43 #include <boost/regex.hpp>
45 
46 #include "CostDBTypes.hh"
47 #include "Exception.hh"
48 
49 namespace HDB {
50  class HDBManager;
51 }
52 
53 class CostDBEntry;
54 class SearchStrategy;
56 class EntryKeyProperty;
57 class CostDBEntryKey;
59 
60 
61 /**
62  * Stores database entries and search strategy for making queries.
63  */
64 class CostDatabase {
65 public:
66  static CostDatabase& instance(const HDB::HDBManager& hdb);
67  virtual ~CostDatabase();
68 
70  void buildRegisterFiles(const std::string& rfEstimatorPluginName);
71  void buildFunctionUnits(const std::string& fuEstimatorPluginName);
72  void buildBuses(const std::string& busEstimatorPluginName);
73  void buildSockets(const std::string& socketEstimatorPluginName);
74  bool isRegisterFilesBuilt();
75  bool isFunctionUnitsBuilt();
76  bool isBusesBuilt();
77  bool isSocketsBuilt();
78 
79  void insertEntry(CostDBEntry* entry);
80  void setSearchStrategy(SearchStrategy* strategy);
82  const CostDBEntryKey& searchKey,
83  const CostDBTypes::MatchTypeTable& match) const;
84 
85 private:
86  /// CostDatabase must be created with instance() method.
87  CostDatabase(const HDB::HDBManager& hdb);
88 
89  /// Finds string matches using regular expressions.
90  boost::smatch getValues(const std::string& text, const std::string& regex);
91 
92  /// Value type for map of search types.
93  typedef std::pair<
95  /// Map of database entries according to entry type.
96  typedef std::map<
98  /// Search type for each entry type.
99  typedef std::map<
101 
102  /// Search strategy used for queries.
104  /// Database entries.
106  /// HDB used for creating cost database.
108  /// Flag to note is register files built
110  /// Flag to note is function units built
112  /// Flag to note is buses built
114  /// Flag to note is sockets built
116 
117  /// Unique instance of the class.
119  /// Registry of CostDatabases.
121  /// Copying not allowed.
122  CostDatabase(const CostDatabase&);
123  /// Assignment not allowed.
125 };
126 
127 #endif
CostDatabase
Definition: CostDatabase.hh:64
CostDatabase::buildSockets
void buildSockets(const std::string &socketEstimatorPluginName)
Definition: CostDatabase.cc:758
EntryKeyFieldProperty
Definition: EntryKeyFieldProperty.hh:47
POP_CLANG_DIAGS
#define POP_CLANG_DIAGS
Definition: CompilerWarnings.hh:96
CostDBTypes::MatchTypeTable
std::vector< MatchType * > MatchTypeTable
Table of types of match.
Definition: CostDBTypes.hh:114
CostDatabase::hdb_
const HDB::HDBManager & hdb_
HDB used for creating cost database.
Definition: CostDatabase.hh:107
CostDBTypes.hh
HDB
Definition: CostDatabase.hh:49
CostDatabase::searchStrategy_
SearchStrategy * searchStrategy_
Search strategy used for queries.
Definition: CostDatabase.hh:103
CostDatabase::getValues
boost::smatch getValues(const std::string &text, const std::string &regex)
Finds string matches using regular expressions.
Definition: CostDatabase.cc:1001
CostDatabase::buildRegisterFiles
void buildRegisterFiles(const std::string &rfEstimatorPluginName)
Definition: CostDatabase.cc:204
Exception.hh
CostDatabaseRegistry
Definition: CostDatabaseRegistry.hh:46
IGNORE_CLANG_WARNING
#define IGNORE_CLANG_WARNING(X)
Definition: CompilerWarnings.hh:85
CostDBTypes::EntryTable
std::vector< CostDBEntry * > EntryTable
Table of database entries.
Definition: CostDBTypes.hh:111
CostDatabase::registry_
CostDatabaseRegistry * registry_
Registry of CostDatabases.
Definition: CostDatabase.hh:120
CostDatabase::isBusesBuilt
bool isBusesBuilt()
Definition: CostDatabase.cc:965
SearchStrategy
Definition: SearchStrategy.hh:45
CostDatabase::buildDefaultCostDatabase
void buildDefaultCostDatabase()
Definition: CostDatabase.cc:180
CostDatabase::MatchTypeMap
std::map< const EntryKeyProperty *, CostDBTypes::MatchTypeTable > MatchTypeMap
Search type for each entry type.
Definition: CostDatabase.hh:100
CostDatabase::operator=
CostDatabase & operator=(const CostDatabase &)
Assignment not allowed.
CostDatabase::busesBuilt_
bool busesBuilt_
Flag to note is buses built.
Definition: CostDatabase.hh:113
CostDatabase::MatchTypeMapType
std::pair< const EntryKeyProperty *, CostDBTypes::MatchTypeTable > MatchTypeMapType
Value type for map of search types.
Definition: CostDatabase.hh:94
CostDBEntry
Definition: CostDBEntry.hh:52
CostDatabase::search
CostDBTypes::EntryTable search(const CostDBEntryKey &searchKey, const CostDBTypes::MatchTypeTable &match) const
Definition: CostDatabase.cc:888
CostDatabase::CostDatabase
CostDatabase(const HDB::HDBManager &hdb)
CostDatabase must be created with instance() method.
Definition: CostDatabase.cc:76
HDB::HDBManager
Definition: HDBManager.hh:82
EntryKeyProperty
Definition: EntryKeyProperty.hh:57
CostDatabase::buildFunctionUnits
void buildFunctionUnits(const std::string &fuEstimatorPluginName)
Definition: CostDatabase.cc:441
CostDatabase::~CostDatabase
virtual ~CostDatabase()
Definition: CostDatabase.cc:137
CostDatabase::registerFilesBuilt_
bool registerFilesBuilt_
Flag to note is register files built.
Definition: CostDatabase.hh:109
CostDatabase::entries_
EntryMap entries_
Database entries.
Definition: CostDatabase.hh:105
CostDatabase::isSocketsBuilt
bool isSocketsBuilt()
Definition: CostDatabase.cc:975
CostDatabase::socketsBuilt_
bool socketsBuilt_
Flag to note is sockets built.
Definition: CostDatabase.hh:115
CostDatabase::functionUnitsBuilt_
bool functionUnitsBuilt_
Flag to note is function units built.
Definition: CostDatabase.hh:111
CostDBEntryKey
Definition: CostDBEntryKey.hh:52
CostDatabase::isRegisterFilesBuilt
bool isRegisterFilesBuilt()
Definition: CostDatabase.cc:945
CostDatabase::setSearchStrategy
void setSearchStrategy(SearchStrategy *strategy)
Definition: CostDatabase.cc:985
CostDatabase::insertEntry
void insertEntry(CostDBEntry *entry)
Definition: CostDatabase.cc:908
CostDatabase::buildBuses
void buildBuses(const std::string &busEstimatorPluginName)
Definition: CostDatabase.cc:642
CostDatabase::EntryMap
std::map< const EntryKeyProperty *, CostDBTypes::EntryTable > EntryMap
Map of database entries according to entry type.
Definition: CostDatabase.hh:97
CompilerWarnings.hh
CostDatabase::instance_
static CostDatabase * instance_
Unique instance of the class.
Definition: CostDatabase.hh:118
CostDatabase::isFunctionUnitsBuilt
bool isFunctionUnitsBuilt()
Definition: CostDatabase.cc:955
CostDatabase::instance
static CostDatabase & instance(const HDB::HDBManager &hdb)
Definition: CostDatabase.cc:166