Heart 1.3.848.aa44c26
Heart is base back end library for your c++ Qt projects.
|
The ISqlDB class it is db cache and bridge for DbWriters. Work Scheme of the database cache: More...
#include <isqldb.h>
Signals | |
void | sigItemChanged (const QSharedPointer< QH::PKG::DBObject > &obj) |
sigItemChanged This signal emitted when database object is changed. | |
void | sigItemDeleted (const QH::DbAddress &obj) |
sigItemDeleted This signal emitted when database object is deleted. | |
Public Member Functions | |
ISqlDB (qint64 updateInterval=DEFAULT_UPDATE_INTERVAL, SqlDBCasheWriteMode mode=SqlDBCasheWriteMode::Default) | |
ISqlDB This is default constructor of dbcache. | |
~ISqlDB () override | |
SqlDBWriter * | writer () const |
writer This method return is database writer object. For more inforamation about writer see the SqlDBWriter class. | |
void | setWriter (SqlDBWriter *writer) |
setWriter This method set new writer for this cache. | |
bool | getAllObjects (const PKG::DBObject &templateObject, QList< QSharedPointer< QH::PKG::DBObject > > &result) override |
bool | updateObject (const QSharedPointer< QH::PKG::DBObject > &saveObject, bool wait=false) override |
bool | deleteObject (const QSharedPointer< QH::PKG::DBObject > &delObj, bool wait=false) override |
bool | insertObject (const QSharedPointer< QH::PKG::DBObject > &saveObject, bool wait=false, const QWeakPointer< unsigned int > &autoincrementIdResult={}) override |
bool | replaceObject (const QSharedPointer< QH::PKG::DBObject > &saveObject, bool wait=false) override |
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. | |
bool | doSql (const QString &sqlFile, bool wait) const override |
doSql This method execute a query in this database. | |
bool | changeObjects (const PKG::DBObject &templateObject, const std::function< bool(const QSharedPointer< PKG::DBObject > &)> &changeAction) |
changeObjects This method change object of the database. | |
qint64 | getUpdateInterval () const |
getUpdateInterval This method return update interval for save changes into database. This is work for default and On_New_Thread mdes. For more information see the QH::SqlDBCasheWriteMode enum. | |
void | setUpdateInterval (const qint64 &value) |
getUpdateInterval This method set new value of an update interval for save changes into database. This is work for default and On_New_Thread mdes. For more information see the QH::SqlDBCasheWriteMode enum. | |
virtual bool | init (const QString &initDbParams="") |
init This method init the cache object and invoke the SqlDBWriter::initDb method. | |
virtual bool | init (const QVariantMap ¶ms) |
init This method init the cache object and invoke the SqlDBWriter::initDb method. | |
void | setSQLSources (const QStringList &list) override |
setSQLSources This method set sql sources for deployed database. | |
Public Member Functions inherited from QH::iObjectProvider | |
template<class TYPE > | |
QSharedPointer< TYPE > | getObject (const TYPE &templateVal) |
getObject this method return a strong pointer to DBObject created by select method of the template object (templateVal). | |
QSharedPointer< PKG::DBObject > | getObjectRaw (const PKG::DBObject &templateVal) |
getObjectRaw This method return object without test object type. | |
virtual bool | getAllObjects (const PKG::DBObject &templateObject, QList< QSharedPointer< PKG::DBObject > > &result)=0 |
getAllObjects This method execute a select method of the templateObject and return list of all selected from databaes or cache objects | |
virtual bool | replaceObject (const QSharedPointer< PKG::DBObject > &saveObject, bool wait)=0 |
replaceObject This method execute a replace method of the saveObject and insert or save if not exists, all changes into database. | |
virtual bool | updateObject (const QSharedPointer< PKG::DBObject > &saveObject, bool wait)=0 |
updateObject This method execute a update method of the saveObject and save all changes into database. | |
virtual bool | insertObject (const QSharedPointer< PKG::DBObject > &saveObject, bool wait, const QWeakPointer< unsigned int > &autoincrementIdResult)=0 |
insertObject This method execute a insert method of the saveObject and insert it into database. | |
virtual bool | deleteObject (const QSharedPointer< PKG::DBObject > &obj, bool wait)=0 |
deleteObject This method execute a delete method of obj and remove current object from database. | |
Public Member Functions inherited from QH::SoftDelete | |
SoftDelete () | |
virtual | ~SoftDelete () |
~SoftDelete This destructor has bin crashed if the softDelete method not will be invoked before delete this object. IF you try delete this object on release distribution then you get error message only without invoked std::abort method. | |
void | softDelete () |
softDelete This method remove this object and save all changes into database. | |
Protected Member Functions | |
void | prepareForDelete () override |
prepareForDelete This method must be prepare object for delete. Override this for working main functions of this class. For more information see the SoftDelete class and SoftDelete::~SoftDelete distructor. | |
qint64 | getLastUpdateTime () const |
getLastUpdateTime This method return time of last update. | |
void | setLastUpdateTime (const qint64 &value) |
setLastUpdateTime This method set new value of the update time. | |
virtual void | deleteFromCache (const QSharedPointer< QH::PKG::DBObject > &delObj)=0 |
deleteFromCache This method delete object from db cache, bat not from 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 this method return false. | |
virtual bool | updateCache (const QSharedPointer< QH::PKG::DBObject > &obj)=0 |
updateCache This method update already exits object on the cache, but not database. | |
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). | |
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. | |
SqlDBCasheWriteMode | getMode () const |
getMode This method return mode of work database cache. For more information see the QH::SqlDBCasheWriteMode enum. | |
void | setMode (const SqlDBCasheWriteMode &mode) |
setMode This method set a new value of the mode database cache. | |
virtual void | globalUpdateDataBasePrivate (qint64 currentTime) |
globalUpdateDataBasePrivate This method update(write) all data from cache into database. Override this method if you want change method of writing a data from cache. | |
virtual void | globalUpdateDataBase (SqlDBCasheWriteMode mode=SqlDBCasheWriteMode::Default) |
globalUpdateDataBase This is base method for syncing data from the cache with database. | |
The ISqlDB class it is db cache and bridge for DbWriters. Work Scheme of the database cache:
This class implements only base functions of the cache. You need to override this class and create implementation for all methods of work with the cache.
QH::ISqlDB::ISqlDB | ( | qint64 | updateInterval = DEFAULT_UPDATE_INTERVAL , |
SqlDBCasheWriteMode | mode = SqlDBCasheWriteMode::Default |
||
) |
ISqlDB This is default constructor of dbcache.
updateInterval | See the SqlDBCache::setUpdateInterval for more information. |
mode | See the SqlDBCache::setMode method for more information. |
Definition at line 139 of file isqldb.cpp.
|
override |
Definition at line 146 of file isqldb.cpp.
bool QH::ISqlDB::changeObjects | ( | const PKG::DBObject & | templateObject, |
const std::function< bool(const QSharedPointer< PKG::DBObject > &)> & | changeAction | ||
) |
changeObjects This method change object of the database.
templateObject | This is template for get objects from database. |
changeAction | This is lambda function for work with non const pointer of the object for change. |
Definition at line 293 of file isqldb.cpp.
|
protectedpure virtual |
deleteFromCache This method delete object from db cache, bat not from database.
delObj | [pointer to object for delete. |
|
override |
|
overridevirtual |
doQuery This method execute a query in this database.
query | This is query that will be executed. |
bindValues | This is values that need to bind before excute query. |
result | This is query result value. |
Implements QH::iObjectProvider.
Definition at line 247 of file isqldb.cpp.
|
overridevirtual |
doSql This method execute a query in this database.
sqlFile | This is sql file that will be executed. |
Implements QH::iObjectProvider.
Definition at line 257 of file isqldb.cpp.
|
override |
Definition at line 158 of file isqldb.cpp.
|
protectedpure virtual |
getFromCache This method return strong pointer to the database object from cache (pool).
obj | This is database cache id. |
Implemented in QH::SqlDB.
|
protected |
getLastUpdateTime This method return time of last update.
Definition at line 124 of file isqldb.cpp.
|
protected |
getMode This method return mode of work database cache. For more information see the QH::SqlDBCasheWriteMode enum.
Definition at line 318 of file isqldb.cpp.
qint64 QH::ISqlDB::getUpdateInterval | ( | ) | const |
getUpdateInterval This method return update interval for save changes into database. This is work for default and On_New_Thread mdes. For more information see the QH::SqlDBCasheWriteMode enum.
Definition at line 378 of file isqldb.cpp.
|
protectedvirtual |
globalUpdateDataBase This is base method for syncing data from the cache with database.
mode | This is mode writing into database. |
Reimplemented in QH::SqlDB.
Definition at line 22 of file isqldb.cpp.
|
protectedvirtual |
globalUpdateDataBasePrivate This method update(write) all data from cache into database. Override this method if you want change method of writing a data from cache.
currentTime | This is current time for saving time of the invoke of this method. |
Reimplemented in QH::SqlDB.
Definition at line 326 of file isqldb.cpp.
|
virtual |
init This method init the cache object and invoke the SqlDBWriter::initDb method.
initDbParams | This is path to json file with database params. |
Definition at line 265 of file isqldb.cpp.
|
virtual |
init This method init the cache object and invoke the SqlDBWriter::initDb method.
params | This is database params map. |
Definition at line 274 of file isqldb.cpp.
|
override |
|
protectedpure virtual |
insertToCache This method insert object into cache, but not database. If Object exists in the cache this method return false.
obj | This is object for save into cache. |
|
overrideprotectedvirtual |
prepareForDelete This method must be prepare object for delete. Override this for working main functions of this class. For more information see the SoftDelete class and SoftDelete::~SoftDelete distructor.
Implements QH::SoftDelete.
Definition at line 289 of file isqldb.cpp.
|
protectedvirtual |
pushToQueue this method should be add the object to the update queue in the physical data dash.
obj | This is obje for update. |
type | This is type of action. For more information see the CacheAction enum. |
Definition at line 132 of file isqldb.cpp.
|
override |
Definition at line 233 of file isqldb.cpp.
|
protected |
setLastUpdateTime This method set new value of the update time.
value | new time of update. |
Definition at line 128 of file isqldb.cpp.
|
protected |
setMode This method set a new value of the mode database cache.
mode | This is new value of mode working the database cache |
Definition at line 322 of file isqldb.cpp.
|
overridevirtual |
setSQLSources This method set sql sources for deployed database.
list | This is list of sql files with database sources. |
For more information about sql sources see the DataBaseNode::SQLSources method.
Implements QH::iObjectProvider.
Definition at line 283 of file isqldb.cpp.
void QH::ISqlDB::setUpdateInterval | ( | const qint64 & | value | ) |
getUpdateInterval This method set new value of an update interval for save changes into database. This is work for default and On_New_Thread mdes. For more information see the QH::SqlDBCasheWriteMode enum.
value | this is new update interval. |
Definition at line 382 of file isqldb.cpp.
void QH::ISqlDB::setWriter | ( | SqlDBWriter * | writer | ) |
setWriter This method set new writer for this cache.
writer | new writer. |
Definition at line 154 of file isqldb.cpp.
|
signal |
sigItemChanged This signal emitted when database object is changed.
obj | This is changed object. |
|
signal |
sigItemDeleted This signal emitted when database object is deleted.
obj | This is address of the removed object. |
|
protectedpure virtual |
updateCache This method update already exits object on the cache, but not database.
obj | This is object with changes for update the object rtom cache. |
|
override |
Definition at line 202 of file isqldb.cpp.
SqlDBWriter * QH::ISqlDB::writer | ( | ) | const |
writer This method return is database writer object. For more inforamation about writer see the SqlDBWriter class.
Definition at line 150 of file isqldb.cpp.