MythTV  master
mythdb.h
Go to the documentation of this file.
1 #ifndef MYTHDB_H_
2 #define MYTHDB_H_
3 
4 #include <QMap>
5 #include <QString>
6 #include <QVariant>
7 #include "mythbaseexp.h"
8 #include "mythdbcon.h"
9 #include "mythdbparams.h"
10 #include "qtuplift.h"
11 
12 class MythDBPrivate;
13 class MDBManager;
14 
15 class MBASE_PUBLIC MythDB
16 {
17  friend class MSqlQuery;
18  public:
19  MDBManager *GetDBManager(void);
20 
21  static QString GetError(const QString &where, const MSqlQuery &query);
22  static void DBError(const QString &where, const MSqlQuery &query);
23  static QString DBErrorMessage(const QSqlError &err);
24 
25  DatabaseParams GetDatabaseParams(void) const;
26  void SetDatabaseParams(const DatabaseParams &params);
27 
28  void SetLocalHostname(const QString &name);
29  QString GetHostName(void) const;
30 
31  void IgnoreDatabase(bool bIgnore);
32  bool IsDatabaseIgnored(void) const;
33 
34  void SetSuppressDBMessages(bool bUpgraded);
35  bool SuppressDBMessages(void) const;
36 
37  void ClearSettingsCache(const QString &key = QString());
38  void ActivateSettingsCache(bool activate = true);
39  void OverrideSettingForSession(const QString &key, const QString &newValue);
40  void ClearOverrideSettingForSession(const QString &key);
41 
42  void SaveSetting(const QString &key, int newValue);
43  void SaveSetting(const QString &key, const QString &newValue);
44  bool SaveSettingOnHost(const QString &key, const QString &newValue,
45  const QString &host);
46  bool ClearSetting(const QString &key);
47  bool ClearSettingOnHost(const QString &key, const QString &host);
48 
49  bool GetSettings(QMap<QString,QString> &_key_value_pairs);
50 
51  QString GetSetting( const QString &_key, const QString &defaultval);
52  bool GetBoolSetting( const QString &key, bool defaultval);
53  int GetNumSetting( const QString &key, int defaultval);
54  double GetFloatSetting(const QString &key, double defaultval);
55 
56  QString GetSetting( const QString &key);
57  bool GetBoolSetting( const QString &key);
58  int GetNumSetting( const QString &key);
59  double GetFloatSetting(const QString &key);
60 
61  QString GetSettingOnHost(
62  const QString &_key, const QString &_host, const QString &defaultval);
63  int GetNumSettingOnHost(
64  const QString &key, const QString &host, int defaultval);
65  double GetFloatSettingOnHost(
66  const QString &key, const QString &host, double defaultval);
67 
68  QString GetSettingOnHost( const QString &key, const QString &host);
69  int GetNumSettingOnHost( const QString &key, const QString &host);
70  double GetFloatSettingOnHost(const QString &key, const QString &host);
71 
72  void GetResolutionSetting(const QString &type, int &width, int &height,
73  double &forced_aspect, double &refresh_rate,
74  int index = -1);
75  void GetResolutionSetting(const QString &t, int &w, int &h,
76  int i = -1);
77 
78  void WriteDelayedSettings(void);
79 
80  void SetHaveDBConnection(bool connected);
81  void SetHaveSchema(bool schema);
82  bool HaveSchema(void) const;
83  bool HaveValidDatabase(void) const;
84 
85  static MythDB *getMythDB();
86  static void destroyMythDB();
87  static QString toCommaList(const QMap<QString, QVariant> &bindings,
88  uint indent = 0, uint softMaxColumn = 80);
89 
90  protected:
91  MythDB();
92  ~MythDB();
93 
94  private:
95  Q_DISABLE_COPY_MOVE(MythDB);
96  MythDBPrivate *d {nullptr}; // NOLINT(readability-identifier-naming)
97 };
98 
99  MBASE_PUBLIC MythDB *GetMythDB();
101  MBASE_PUBLIC MythDB *GetMythTestDB(const QString& testname);
102 
103 #endif
toCommaList
static QString toCommaList(const QVector< uint > &list)
Definition: tv_play.cpp:6660
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:128
DatabaseParams
Structure containing the basic Database parameters.
Definition: mythdbparams.h:10
mythbaseexp.h
MDBManager
DB connection pool, used by MSqlQuery. Do not use directly.
Definition: mythdbcon.h:55
mythdbcon.h
qtuplift.h
MythDBPrivate
Definition: mythdb.cpp:92
DestroyMythDB
MBASE_PUBLIC void DestroyMythDB()
Definition: mythdb.cpp:55
MBASE_PUBLIC
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
GetMythTestDB
MBASE_PUBLIC MythDB * GetMythTestDB(const QString &testname)
Definition: mythdb.cpp:60
hardwareprofile.i18n.t
t
Definition: i18n.py:36
uint
unsigned int uint
Definition: compat.h:79
ClearSettingsCache
static int ClearSettingsCache(const MythUtilCommandLineParser &)
Definition: backendutils.cpp:33
d
static const iso6937table * d
Definition: iso6937tables.cpp:1025
indent
static QString indent(uint level)
Definition: mythsettings.cpp:21
GetMythDB
MBASE_PUBLIC MythDB * GetMythDB()
Definition: mythdb.cpp:50
mythdbparams.h