CARMA C++
ResultsCache.h
Go to the documentation of this file.
1 #ifndef CARMA_DBMS_RESULTSCACHE_H
2 #define CARMA_DBMS_RESULTSCACHE_H
3 
14 #include <string>
15 #include <map>
16 #include "carma/dbms/Column.h"
17 #include "carma/dbms/Typedefs.h"
18 #include "carma/util/Logger.h"
19 #include "carma/util/PthreadMutex.h"
20 
21 namespace carma {
22  namespace dbms {
23 
24  class DBConnection;
25  class DBConfigurator;
26  class Table;
50 class ResultsCache {
51 public:
52 
53 
61  static ResultsCache& getCache(const DBConnection * const dbc=NULL);
62 
69  static void closeCache();
70 
75  static bool cacheExists();
76 
83  //const carma::dbms::ID2MDMap& getMonitorConfigurations();
84 
94 
101 
105  const std::map<int,std::string>& getTagIDToNameMap() const;
106 
112  //const carma::dbms::Column<int>& getAllTagIDs();
113 
118  //const carma::dbms::Table& getMonitorDataTableIndexTable();
119 
127  void cache(const std::string& identifier, const carma::dbms::Table& table);
128 
136  const carma::dbms::Table& getTable(const std::string& identifier) const;
137 
143  bool tableIDExists(const std::string identifier) const;
144 
145 protected:
146  ResultsCache();
147  ResultsCache(const carma::dbms::DBConnection* const dbc);
148 
149 
150 private:
151  //static carma::dbms::ID2MDMap *tagID2MD_;
152  const static carma::dbms::Table *fullMCTable_;
153  const static carma::dbms::Table *currentMCTable_;
154  //const static carma::dbms::Column<int> *allTagIDs_;
155  const carma::dbms::DBConnection *dbc_;
156  log4cpp::Category& logger_;
157  // number of clients currently using the singleton
158  static ResultsCache *resultsCache_;
159  static std::map<std::string,carma::dbms::Table> * tableCache_;
160  static std::map<int,std::string> * tagIDToNameMap_;
161 
168  static carma::util::PthreadMutex resultsCacheMutex_;
169 
170 };
171 
172 }}
173 
174 
175 #endif // CARMA_DBMS_RESULTSCACHE_H
Class to mimic a db table The Table class is meant to mimic a database table.
Definition: Table.h:34
static void closeCache()
indicate that one&#39;s use of the cache is complete.
static ResultsCache & getCache(const DBConnection *const dbc=NULL)
get the singleton instance of the ResultsCache, the specified (valid) DBConnection object will be use...
static bool cacheExists()
does the singleton currently exist?
bool tableIDExists(const std::string identifier) const
does the specified id (and hence table) exist in the table cache?
Column template class.
const std::map< int, std::string > & getTagIDToNameMap() const
return the map of tagIDs to canonical names
void cache(const std::string &identifier, const carma::dbms::Table &table)
return (and cache if not already done) a column listing all the tagIDs in the DB
A simple wrapper class that makes use of ::pthread_mutex_t easier in a C++ world. ...
Definition: PthreadMutex.h:41
A class for caching and retrieving results of database queries.
Definition: ResultsCache.h:50
const carma::dbms::Table & getCurrentMonitorConfigurationTable()
get a table containing the current monitor configurations, This table is guaranteed to have exactly o...
an abstract class from which database queries may be launched.
Definition: DBConnection.h:46
typdefs for carma::dbms.
const carma::dbms::Table & getTable(const std::string &identifier) const
get a cached table from the table cache
const carma::dbms::Table & getFullMonitorConfigurationTable()
return (and cache if not already done) a mapping of all tagIDs in the database to their corresponding...