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  MythDB(const MythDB &) = delete; // not copyable
21  MythDB &operator=(const MythDB &) = delete; // not copyable
22 
23  static QString GetError(const QString &where, const MSqlQuery &query);
24  static void DBError(const QString &where, const MSqlQuery &query);
25  static QString DBErrorMessage(const QSqlError &err);
26 
27  DatabaseParams GetDatabaseParams(void) const;
28  void SetDatabaseParams(const DatabaseParams &params);
29 
30  void SetLocalHostname(const QString &name);
31  QString GetHostName(void) const;
32 
33  void IgnoreDatabase(bool bIgnore);
34  bool IsDatabaseIgnored(void) const;
35 
36  void SetSuppressDBMessages(bool bUpgraded);
37  bool SuppressDBMessages(void) const;
38 
39  void ClearSettingsCache(const QString &key = QString());
40  void ActivateSettingsCache(bool activate = true);
41  void OverrideSettingForSession(const QString &key, const QString &newValue);
42  void ClearOverrideSettingForSession(const QString &key);
43 
44  void SaveSetting(const QString &key, int newValue);
45  void SaveSetting(const QString &key, const QString &newValue);
46  bool SaveSettingOnHost(const QString &key, const QString &newValue,
47  const QString &host);
48  bool ClearSetting(const QString &key);
49  bool ClearSettingOnHost(const QString &key, const QString &host);
50 
51  bool GetSettings(QMap<QString,QString> &_key_value_pairs);
52 
53  QString GetSetting( const QString &_key, const QString &defaultval);
54  bool GetBoolSetting( const QString &key, bool defaultval);
55  int GetNumSetting( const QString &key, int defaultval);
56  double GetFloatSetting(const QString &key, double defaultval);
57 
58  QString GetSetting( const QString &key);
59  bool GetBoolSetting( const QString &key);
60  int GetNumSetting( const QString &key);
61  double GetFloatSetting(const QString &key);
62 
63  QString GetSettingOnHost(
64  const QString &_key, const QString &_host, const QString &defaultval);
65  int GetNumSettingOnHost(
66  const QString &key, const QString &host, int defaultval);
67  double GetFloatSettingOnHost(
68  const QString &key, const QString &host, double defaultval);
69 
70  QString GetSettingOnHost( const QString &key, const QString &host);
71  int GetNumSettingOnHost( const QString &key, const QString &host);
72  double GetFloatSettingOnHost(const QString &key, const QString &host);
73 
74  void GetResolutionSetting(const QString &type, int &width, int &height,
75  double &forced_aspect, double &refresh_rate,
76  int index = -1);
77  void GetResolutionSetting(const QString &t, int &w, int &h,
78  int i = -1);
79 
80  void WriteDelayedSettings(void);
81 
82  void SetHaveDBConnection(bool connected);
83  void SetHaveSchema(bool schema);
84  bool HaveSchema(void) const;
85  bool HaveValidDatabase(void) const;
86 
87  static MythDB *getMythDB();
88  static void destroyMythDB();
89  static QString toCommaList(const QMap<QString, QVariant> &bindings,
90  uint indent = 0, uint softMaxColumn = 80);
91 
92  protected:
93  MythDB();
94  ~MythDB();
95 
96  private:
97  MythDBPrivate *d {nullptr}; // NOLINT(readability-identifier-naming)
98 };
99 
102 
103 #endif
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:126
DatabaseParams
Structure containing the basic Database parameters.
Definition: mythdbparams.h:10
mythbaseexp.h
d
static const uint16_t * d
Definition: iso6937tables.cpp:1025
MDBManager
DB connection pool, used by MSqlQuery. Do not use directly.
Definition: mythdbcon.h:54
MythDB::MythDB
MythDB(const MythDB &)=delete
mythdbcon.h
MythDBPrivate
Definition: mythdb.cpp:66
DestroyMythDB
MBASE_PUBLIC void DestroyMythDB()
Definition: mythdb.cpp:51
MBASE_PUBLIC
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
hardwareprofile.i18n.t
t
Definition: i18n.py:36
MythDB
Definition: mythdb.h:15
GetSetting
t<< doc.toString(4);f.close();LOG(VB_JOBQUEUE, LOG_INFO, "Copying video file");bool res=copyFile(filename, saveDirectory+title+"/"+baseName);if(!res) return 0;if(QFile::exists(filename+".png")) { LOG(VB_JOBQUEUE, LOG_INFO, "Copying preview image");res=copyFile(filename+".png", saveDirectory+title+"/"+baseName+".png");if(!res) return 0;} LOG(VB_JOBQUEUE, LOG_INFO, "Item Archived OK");return 1;}int NativeArchive::exportVideo(QDomElement &itemNode, const QString &saveDirectory){ QString dbVersion=gCoreContext-> GetSetting("DBSchemaVer", "")
uint
unsigned int uint
Definition: compat.h:140
MythDB::GetResolutionSetting
void GetResolutionSetting(const QString &t, int &w, int &h, int i=-1)
MythDB::GetResolutionSetting
void GetResolutionSetting(const QString &type, int &width, int &height, double &forced_aspect, double &refresh_rate, int index=-1)
MythDB::operator=
MythDB & operator=(const MythDB &)=delete
toCommaList
static QString toCommaList(const QSet< uint > &list)
Definition: tv_play.cpp:8393
ClearSettingsCache
static int ClearSettingsCache(const MythUtilCommandLineParser &)
Definition: backendutils.cpp:39
indent
static QString indent(uint level)
Definition: mythsettings.cpp:17
GetMythDB
MBASE_PUBLIC MythDB * GetMythDB()
Definition: mythdb.cpp:46
query
MSqlQuery query(MSqlQuery::InitCon())
mythdbparams.h