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