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  QString GetDatabaseName() const;
26  DatabaseParams GetDatabaseParams(void) const;
27  void SetDatabaseParams(const DatabaseParams &params);
28 
29  void SetLocalHostname(const QString &name);
30  QString GetHostName(void) const;
31 
32  void IgnoreDatabase(bool bIgnore);
33  bool IsDatabaseIgnored(void) const;
34 
35  void SetSuppressDBMessages(bool bUpgraded);
36  bool SuppressDBMessages(void) const;
37 
38  void ClearSettingsCache(const QString &key = QString());
39  void ActivateSettingsCache(bool activate = true);
40  void OverrideSettingForSession(const QString &key, const QString &newValue);
41  void ClearOverrideSettingForSession(const QString &key);
42 
43  void SaveSetting(const QString &key, int newValue);
44  void SaveSetting(const QString &key, const QString &newValue);
45  bool SaveSettingOnHost(const QString &key, const QString &newValue,
46  const QString &host);
47  bool ClearSetting(const QString &key);
48  bool ClearSettingOnHost(const QString &key, const QString &host);
49 
50  bool GetSettings(QMap<QString,QString> &_key_value_pairs);
51 
52  QString GetSetting( const QString &_key, const QString &defaultval);
53  bool GetBoolSetting( const QString &key, bool defaultval);
54  int GetNumSetting( const QString &key, int defaultval);
55  double GetFloatSetting(const QString &key, double defaultval);
56 
57  QString GetSetting( const QString &key);
58  bool GetBoolSetting( const QString &key);
59  int GetNumSetting( const QString &key);
60  double GetFloatSetting(const QString &key);
61 
62  QString GetSettingOnHost(
63  const QString &_key, const QString &_host, const QString &defaultval);
64  int GetNumSettingOnHost(
65  const QString &key, const QString &host, int defaultval);
66  double GetFloatSettingOnHost(
67  const QString &key, const QString &host, double defaultval);
68 
69  QString GetSettingOnHost( const QString &key, const QString &host);
70  int GetNumSettingOnHost( const QString &key, const QString &host);
71  double GetFloatSettingOnHost(const QString &key, const QString &host);
72 
73  void GetResolutionSetting(const QString &type, int &width, int &height,
74  double &forced_aspect, double &refresh_rate,
75  int index = -1);
76  void GetResolutionSetting(const QString &t, int &w, int &h,
77  int i = -1);
78 
79  void WriteDelayedSettings(void);
80 
81  void SetHaveDBConnection(bool connected);
82  void SetHaveSchema(bool schema);
83  bool HaveSchema(void) const;
84  bool HaveValidDatabase(void) const;
85 
86  static MythDB *getMythDB();
87  static void destroyMythDB();
88  static QString toCommaList(const QMap<QString, QVariant> &bindings,
89  uint indent = 0, uint softMaxColumn = 80);
90 
91  protected:
92  MythDB();
93  ~MythDB();
94 
95  private:
96  Q_DISABLE_COPY_MOVE(MythDB);
97  MythDBPrivate *d {nullptr}; // NOLINT(readability-identifier-naming)
98 };
99 
100  MBASE_PUBLIC MythDB *GetMythDB();
102  MBASE_PUBLIC MythDB *GetMythTestDB(const QString& testname);
103 
104 #endif
toCommaList
static QString toCommaList(const QVector< uint > &list)
Definition: tv_play.cpp:6659
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