mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Read-Only Configuration-Database support (#1046)
This commit is contained in:
@@ -16,9 +16,10 @@ class AuthTable : public DBManager
|
||||
|
||||
public:
|
||||
/// construct wrapper with auth table
|
||||
AuthTable(const QString& rootPath = "", QObject* parent = nullptr)
|
||||
AuthTable(const QString& rootPath = "", QObject* parent = nullptr, bool readonlyMode = false)
|
||||
: DBManager(parent)
|
||||
{
|
||||
setReadonlyMode(readonlyMode);
|
||||
if(!rootPath.isEmpty()){
|
||||
// Init Hyperion database usage
|
||||
setRootPath(rootPath);
|
||||
|
@@ -119,6 +119,13 @@ public:
|
||||
///
|
||||
bool deleteTable(const QString& table) const;
|
||||
|
||||
///
|
||||
/// @brief Sets a table in read-only mode.
|
||||
/// Updates will not written to the table
|
||||
/// @param[in] readOnly True read-only, false - read/write
|
||||
///
|
||||
void setReadonlyMode(bool readOnly) { _readonlyMode = readOnly; };
|
||||
|
||||
private:
|
||||
|
||||
Logger* _log;
|
||||
@@ -127,6 +134,8 @@ private:
|
||||
/// table in database
|
||||
QString _table;
|
||||
|
||||
bool _readonlyMode;
|
||||
|
||||
/// addBindValue to query given by QVariantList
|
||||
void doAddBindValue(QSqlQuery& query, const QVariantList& variants) const;
|
||||
};
|
||||
|
@@ -14,9 +14,11 @@ class InstanceTable : public DBManager
|
||||
{
|
||||
|
||||
public:
|
||||
InstanceTable(const QString& rootPath, QObject* parent = nullptr)
|
||||
InstanceTable(const QString& rootPath, QObject* parent = nullptr, bool readonlyMode = false)
|
||||
: DBManager(parent)
|
||||
{
|
||||
|
||||
setReadonlyMode(readonlyMode);
|
||||
// Init Hyperion database usage
|
||||
setRootPath(rootPath);
|
||||
setDatabaseName("hyperion");
|
||||
|
@@ -17,9 +17,11 @@ class MetaTable : public DBManager
|
||||
|
||||
public:
|
||||
/// construct wrapper with plugins table and columns
|
||||
MetaTable(QObject* parent = nullptr)
|
||||
MetaTable(QObject* parent = nullptr, bool readonlyMode = false)
|
||||
: DBManager(parent)
|
||||
{
|
||||
setReadonlyMode(readonlyMode);
|
||||
|
||||
setTable("meta");
|
||||
createTable(QStringList()<<"uuid TEXT"<<"created_at TEXT");
|
||||
};
|
||||
|
Reference in New Issue
Block a user