99 QList<QSharedPointer<QH::PKG::DBObject>> &result)
override;
101 bool updateObject(
const QSharedPointer<QH::PKG::DBObject>& saveObject,
102 bool wait =
false)
override;
103 bool deleteObject(
const QSharedPointer<QH::PKG::DBObject>& delObj,
104 bool wait =
false)
override;
105 bool insertObject(
const QSharedPointer<QH::PKG::DBObject>& saveObject,
107 const QWeakPointer<unsigned int>& autoincrementIdResult = {})
override;
109 bool replaceObject(
const QSharedPointer<QH::PKG::DBObject>& saveObject,
110 bool wait =
false)
override;
112 bool doQuery(
const QString &query,
const QVariantMap& bindValues,
113 bool wait =
false, QSqlQuery* result =
nullptr)
const override;
115 bool doSql(
const QString &sqlFile,
bool wait)
const override;
125 const std::function<
bool (
const QSharedPointer<PKG::DBObject> &)> &changeAction);
143 virtual bool init(
const QString &initDbParams =
"");
150 virtual bool init(
const QVariantMap ¶ms);
182 virtual bool insertToCache(
const QSharedPointer<QH::PKG::DBObject> &obj) = 0;
189 virtual bool updateCache(
const QSharedPointer<QH::PKG::DBObject> &obj) = 0;
196 virtual QList<QSharedPointer<QH::PKG::DBObject>>
204 virtual void pushToQueue(
const QSharedPointer<QH::PKG::DBObject> &obj,
234 bool updateObjectP(
const QSharedPointer<QH::PKG::DBObject>& saveObject,
236 bool deleteObjectP(
const QSharedPointer<QH::PKG::DBObject>& delObj,
238 bool insertObjectP(
const QSharedPointer<QH::PKG::DBObject>& saveObject,
240 const QWeakPointer<unsigned int>& autoincrementIdResult);
241 bool replaceObjectP(
const QSharedPointer<QH::PKG::DBObject>& saveObject,
244 qint64 lastUpdateTime = 0;
251 QHash<CacheAction, QSharedPointer<QH::PKG::DBObject>> _changes;
252 QMutex _saveLaterMutex;
279 return static_cast<uint
>(action);
The DbAddress class use to work with database addresses. Database Address it is structure with 2 valu...
SqlDBCasheWriteMode getMode() const
getMode This method return mode of work database cache. For more information see the QH::SqlDBCasheWr...
void setWriter(SqlDBWriter *writer)
setWriter This method set new writer for this cache.
void prepareForDelete() override
prepareForDelete This method must be prepare object for delete. Override this for working main functi...
SqlDBWriter * writer() const
writer This method return is database writer object. For more inforamation about writer see the SqlDB...
bool insertObject(const QSharedPointer< QH::PKG::DBObject > &saveObject, bool wait=false, const QWeakPointer< unsigned int > &autoincrementIdResult={}) override
virtual QList< QSharedPointer< QH::PKG::DBObject > > getFromCache(const PKG::DBObject *obj)=0
getFromCache This method return strong pointer to the database object from cache (pool).
bool doQuery(const QString &query, const QVariantMap &bindValues, bool wait=false, QSqlQuery *result=nullptr) const override
doQuery This method execute a query in this database.
virtual bool init(const QString &initDbParams="")
init This method init the cache object and invoke the SqlDBWriter::initDb method.
bool getAllObjects(const PKG::DBObject &templateObject, QList< QSharedPointer< QH::PKG::DBObject > > &result) override
virtual void globalUpdateDataBasePrivate(qint64 currentTime)
globalUpdateDataBasePrivate This method update(write) all data from cache into database....
virtual void pushToQueue(const QSharedPointer< QH::PKG::DBObject > &obj, CacheAction type)
pushToQueue this method should be add the object to the update queue in the physical data dash.
bool doSql(const QString &sqlFile, bool wait) const override
doSql This method execute a query in this database.
void setLastUpdateTime(const qint64 &value)
setLastUpdateTime This method set new value of the update time.
bool deleteObject(const QSharedPointer< QH::PKG::DBObject > &delObj, bool wait=false) override
virtual void globalUpdateDataBase(SqlDBCasheWriteMode mode=SqlDBCasheWriteMode::Default)
globalUpdateDataBase This is base method for syncing data from the cache with database.
void setUpdateInterval(const qint64 &value)
getUpdateInterval This method set new value of an update interval for save changes into database....
void sigItemChanged(const QSharedPointer< QH::PKG::DBObject > &obj)
sigItemChanged This signal emitted when database object is changed.
virtual void deleteFromCache(const QSharedPointer< QH::PKG::DBObject > &delObj)=0
deleteFromCache This method delete object from db cache, bat not from database.
void sigItemDeleted(const QH::DbAddress &obj)
sigItemDeleted This signal emitted when database object is deleted.
bool changeObjects(const PKG::DBObject &templateObject, const std::function< bool(const QSharedPointer< PKG::DBObject > &)> &changeAction)
changeObjects This method change object of the database.
virtual bool updateCache(const QSharedPointer< QH::PKG::DBObject > &obj)=0
updateCache This method update already exits object on the cache, but not database.
ISqlDB(qint64 updateInterval=DEFAULT_UPDATE_INTERVAL, SqlDBCasheWriteMode mode=SqlDBCasheWriteMode::Default)
ISqlDB This is default constructor of dbcache.
void setSQLSources(const QStringList &list) override
setSQLSources This method set sql sources for deployed database.
virtual bool insertToCache(const QSharedPointer< QH::PKG::DBObject > &obj)=0
insertToCache This method insert object into cache, but not database. If Object exists in the cache t...
void setMode(const SqlDBCasheWriteMode &mode)
setMode This method set a new value of the mode database cache.
bool updateObject(const QSharedPointer< QH::PKG::DBObject > &saveObject, bool wait=false) override
bool replaceObject(const QSharedPointer< QH::PKG::DBObject > &saveObject, bool wait=false) override
qint64 getUpdateInterval() const
getUpdateInterval This method return update interval for save changes into database....
qint64 getLastUpdateTime() const
getLastUpdateTime This method return time of last update.
The DBObject class- main class for work with data base.
The SqlDBWriter class. This class write and read objects from database (hard level)....
The iObjectProvider class is base interface for work with database objects. Using on database writers...
#define DEFAULT_UPDATE_INTERVAL
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
uint qHash(NodeCoonectionStatus status)
qHash - Simple hash function of NodeCoonectionStatus
SqlDBCasheWriteMode
The SqlDBCasheWriteMode enum contains list of available modes of write data into database.
@ Default
This is default mode. The database is written to the database with each function call no more often t...
@ Force
This mode writes all changes to the database as soon as they come to the cache.
@ On_New_Thread
This mode write a changes into another thread.
@ Default
General trust of the node or client.
CacheAction
The CacheAction enum contains types of database cache actions. The any database caches save all chang...
@ Update
Invoke the SqlDBWriter::updateObject method of a private database writer implementation.
@ Insert
Invoke the SqlDBWriter::insertObject method of a private database writer implementation.
@ Delete
Invoke the SqlDBWriter::deleteObject method of a private database writer implementation.