Heart 1.3.842.34c2ab5
Heart is base back end library for your c++ Qt projects.
QH::SqlDB Class Referencefinal

The SqlDB class This is base implementation fo datatbase. The SqlDB do not use caches, all request run on the sqlwtiter class. More...

#include <sqldb.h>

Inheritance diagram for QH::SqlDB:
Inheritance graph
Collaboration diagram for QH::SqlDB:
Collaboration graph

Public Member Functions

 SqlDB ()
 
- Public Member Functions inherited from QH::ISqlDB
 ISqlDB (qint64 updateInterval=DEFAULT_UPDATE_INTERVAL, SqlDBCasheWriteMode mode=SqlDBCasheWriteMode::Default)
 ISqlDB This is default constructor of dbcache.
 
 ~ISqlDB () override
 
SqlDBWriterwriter () 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 &params)
 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::DBObjectgetObjectRaw (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 deleteFromCache (const QSharedPointer< PKG::DBObject > &delObj) override final
 
bool insertToCache (const QSharedPointer< PKG::DBObject > &obj) override final
 
bool updateCache (const QSharedPointer< PKG::DBObject > &obj) override final
 
QList< QSharedPointer< PKG::DBObject > > getFromCache (const PKG::DBObject *obj) override final
 getFromCache This method return strong pointer to the database object from cache (pool).
 
void pushToQueue (const QSharedPointer< PKG::DBObject > &obj, CacheAction type) override final
 
void globalUpdateDataBasePrivate (qint64 currentTime) override final
 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.
 
void globalUpdateDataBase (SqlDBCasheWriteMode mode) override final
 globalUpdateDataBase This is base method for syncing data from the cache with database.
 
- Protected Member Functions inherited from QH::ISqlDB
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 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.
 

Additional Inherited Members

- Signals inherited from QH::ISqlDB
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.
 

Detailed Description

The SqlDB class This is base implementation fo datatbase. The SqlDB do not use caches, all request run on the sqlwtiter class.

Definition at line 18 of file sqldb.h.

Constructor & Destructor Documentation

◆ SqlDB()

QH::SqlDB::SqlDB ( )

Definition at line 11 of file sqldb.cpp.

Member Function Documentation

◆ deleteFromCache()

void QH::SqlDB::deleteFromCache ( const QSharedPointer< PKG::DBObject > &  delObj)
finaloverrideprotected

Definition at line 15 of file sqldb.cpp.

◆ getFromCache()

QList< QSharedPointer< PKG::DBObject > > QH::SqlDB::getFromCache ( const PKG::DBObject obj)
finaloverrideprotectedvirtual

getFromCache This method return strong pointer to the database object from cache (pool).

Parameters
objThis is database cache id.
Returns
database Object from cache. if object with objKey not exits return nullptr.

Implements QH::ISqlDB.

Definition at line 30 of file sqldb.cpp.

◆ globalUpdateDataBase()

void QH::SqlDB::globalUpdateDataBase ( SqlDBCasheWriteMode  mode)
finaloverrideprotectedvirtual

globalUpdateDataBase This is base method for syncing data from the cache with database.

Parameters
modeThis is mode writing into database.

Reimplemented from QH::ISqlDB.

Definition at line 45 of file sqldb.cpp.

◆ globalUpdateDataBasePrivate()

void QH::SqlDB::globalUpdateDataBasePrivate ( qint64  currentTime)
finaloverrideprotectedvirtual

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.

Parameters
currentTimeThis is current time for saving time of the invoke of this method.

Reimplemented from QH::ISqlDB.

Definition at line 41 of file sqldb.cpp.

◆ insertToCache()

bool QH::SqlDB::insertToCache ( const QSharedPointer< PKG::DBObject > &  obj)
finaloverrideprotected

Definition at line 19 of file sqldb.cpp.

◆ pushToQueue()

void QH::SqlDB::pushToQueue ( const QSharedPointer< PKG::DBObject > &  obj,
CacheAction  type 
)
finaloverrideprotected

Definition at line 35 of file sqldb.cpp.

◆ updateCache()

bool QH::SqlDB::updateCache ( const QSharedPointer< PKG::DBObject > &  obj)
finaloverrideprotected

Definition at line 24 of file sqldb.cpp.


The documentation for this class was generated from the following files: