TreeFrogFramework  2.8
tdatabasecontext.h
Go to the documentation of this file.
1 #pragma once
2 #include <QMap>
3 #include <TSqlTransaction>
4 #include <TGlobal>
5 
6 class QSqlDatabase;
7 class TKvsDatabase;
8 class TCache;
9 
10 
12 public:
14  virtual ~TDatabaseContext();
15 
16  QSqlDatabase &getSqlDatabase(int id = 0);
17  TKvsDatabase &getKvsDatabase(Tf::KvsEngine engine);
18 
19  void setTransactionEnabled(bool enable, int id = 0);
20  void release();
21  void commitTransactions();
22  bool commitTransaction(int id = 0);
23  void rollbackTransactions();
24  bool rollbackTransaction(int id = 0);
25  int idleTime() const;
26  TCache *cache();
28  static void setCurrentDatabaseContext(TDatabaseContext *context);
29 
30 protected:
31  void releaseKvsDatabases();
32  void releaseSqlDatabases();
33 
34  QMap<int, TSqlTransaction> sqlDatabases;
35  QMap<int, TKvsDatabase> kvsDatabases;
36 
37 private:
38  uint idleElapsed {0};
39  TCache *cachep {nullptr};
40 
43 };
44 
The TCache class stores items so that can be served faster.
Definition: tcache.h:7
The TDatabaseContext class is the base class of contexts for database access.
Definition: tdatabasecontext.h:11
QMap< int, TKvsDatabase > kvsDatabases
Definition: tdatabasecontext.h:35
QMap< int, TSqlTransaction > sqlDatabases
Definition: tdatabasecontext.h:34
KvsEngine
Definition: tfnamespace.h:239
T_CORE_EXPORT TDatabaseContext * currentDatabaseContext()
Definition: tglobal.cpp:143
T_CORE_EXPORT TCache * cache() noexcept
Definition: tglobal.cpp:116
#define T_CORE_EXPORT
Definition: tdeclexport.h:28
#define T_DISABLE_COPY(Class)
Definition: tdeclexport.h:37
#define T_DISABLE_MOVE(Class)
Definition: tdeclexport.h:41