TreeFrogFramework 2.10
Loading...
Searching...
No Matches
tdatabasecontext.h
Go to the documentation of this file.
1#pragma once
2#include <QMap>
3#include <TSqlTransaction>
4#include <TGlobal>
5
6class QSqlDatabase;
7class TKvsDatabase;
8class TCache;
9
10
12public:
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();
27 static TDatabaseContext *currentDatabaseContext();
28 static void setCurrentDatabaseContext(TDatabaseContext *context);
29
30protected:
31 void releaseKvsDatabases();
32 void releaseSqlDatabases();
33
34 QMap<int, TSqlTransaction> sqlDatabases;
35 QMap<int, TKvsDatabase> kvsDatabases;
36
37private:
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
#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