TreeFrogFramework  1.18
tdatabasecontext.h
Go to the documentation of this file.
1 #ifndef TDATABASECONTEXT_H
2 #define TDATABASECONTEXT_H
3 
4 #include <QMap>
5 #include <QSqlDatabase>
6 #include <TSqlTransaction>
7 #include <TKvsDatabase>
8 #include <TGlobal>
9 
10 
12 {
13 public:
15  virtual ~TDatabaseContext();
16 
17  QSqlDatabase &getSqlDatabase(int id);
18  TKvsDatabase &getKvsDatabase(TKvsDatabase::Type type);
19 
20  void setTransactionEnabled(bool enable);
21  void release();
22  bool beginTransaction(QSqlDatabase &database);
23  void commitTransactions();
24  void rollbackTransactions();
25  int idleTime() const;
26 
27 protected:
28  void releaseKvsDatabases();
29  void releaseSqlDatabases();
30 
31  QMap<int, QSqlDatabase> sqlDatabases;
32  QMap<int, TKvsDatabase> kvsDatabases;
33 
34 private:
35  TSqlTransaction transactions;
36  uint idleElapsed {0};
37 
40 };
41 
42 #endif // TDATABASECONTEXT_H
#define T_CORE_EXPORT
Definition: tglobal.h:81
Definition: tfnamespace.h:295
The TDatabaseContext class is the base class of contexts for database access.
Definition: tdatabasecontext.h:11
#define T_DISABLE_COPY(Class)
Definition: tglobal.h:137
#define T_DISABLE_MOVE(Class)
Definition: tglobal.h:141
QMap< int, QSqlDatabase > sqlDatabases
Definition: tdatabasecontext.h:31
QMap< int, TKvsDatabase > kvsDatabases
Definition: tdatabasecontext.h:32