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

The iObjectProvider class is base interface for work with database objects. Using on database writers and database caches. More...

#include <iobjectprovider.h>

Inheritance diagram for QH::iObjectProvider:
Inheritance graph
Collaboration diagram for QH::iObjectProvider:
Collaboration graph

Public Member Functions

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.
 
virtual void setSQLSources (const QStringList &list)=0
 setSQLSources This method set sql sources for deployed database.
 
virtual bool doQuery (const QString &query, const QVariantMap &bindValues={}, bool wait=false, QSqlQuery *result=nullptr) const =0
 doQuery This method execute a query in this database.
 
virtual bool doSql (const QString &sqlFile, bool wait=true) const =0
 doSql This method execute a query in this database.
 

Detailed Description

The iObjectProvider class is base interface for work with database objects. Using on database writers and database caches.

Definition at line 25 of file iobjectprovider.h.

Member Function Documentation

◆ deleteObject()

virtual bool QH::iObjectProvider::deleteObject ( const QSharedPointer< PKG::DBObject > &  obj,
bool  wait 
)
pure virtual

deleteObject This method execute a delete method of obj and remove current object from database.

Parameters
objThis is object for removing.
waitThis arguments force current thread wait for the function finishing.
Returns
true if object is removed successful else false.

Implemented in QH::SqlDBWriter.

◆ doQuery()

virtual bool QH::iObjectProvider::doQuery ( const QString &  query,
const QVariantMap &  bindValues = {},
bool  wait = false,
QSqlQuery *  result = nullptr 
) const
pure virtual

doQuery This method execute a query in this database.

Parameters
queryThis is query that will be executed.
bindValuesThis is values that need to bind before excute query.
resultThis is query result value.
Warning
The result works onlt on await mode. Set the wait param to true.
Returns
true if the query finished successful

Implemented in QH::ISqlDB, and QH::SqlDBWriter.

◆ doSql()

virtual bool QH::iObjectProvider::doSql ( const QString &  sqlFile,
bool  wait = true 
) const
pure virtual

doSql This method execute a query in this database.

Parameters
sqlFileThis is sql file that will be executed.
Returns
true if the query finished successful

Implemented in QH::ISqlDB, and QH::SqlDBWriter.

◆ getAllObjects()

virtual bool QH::iObjectProvider::getAllObjects ( const PKG::DBObject templateObject,
QList< QSharedPointer< PKG::DBObject > > &  result 
)
pure virtual

getAllObjects This method execute a select method of the templateObject and return list of all selected from databaes or cache objects

Parameters
templateObjectThis is template object for prepare a select request.
resultThis is return value, list of selected objects.
Returns
true if objects have in db else false.

Implemented in QH::SqlDBWriter.

Here is the caller graph for this function:

◆ getObject()

template<class TYPE >
QSharedPointer< TYPE > QH::iObjectProvider::getObject ( const TYPE &  templateVal)
inline

getObject this method return a strong pointer to DBObject created by select method of the template object (templateVal).

Parameters
templateValThis is template object with a select data base request.
Note
This method return a database object with a type as a type of templateVal object. If you want to get a object of C class but the database contains object of D class then you get object with the C class and this object will be saved to cache. So next time if you want get a object D class you get a object with C class. This is possible only when the objects have the same id. that is, classes C and D are no different except for a command. So this behavior should not lead to errors.
The type of input templateVal object must be child type of the DBObject class.
Returns
return strong pointer to DBObject ot nullptr id object not exits.

Definition at line 39 of file iobjectprovider.h.

Here is the caller graph for this function:

◆ getObjectRaw()

QSharedPointer< DBObject > QH::iObjectProvider::getObjectRaw ( const PKG::DBObject templateVal)

getObjectRaw This method return object without test object type.

Note
If you want get object with check object type use getObject method.
Parameters
templateValThis is template object with request to database.
Returns
The database object pointer (not casted).

Definition at line 13 of file iobjectprovider.cpp.

Here is the call graph for this function:

◆ insertObject()

virtual bool QH::iObjectProvider::insertObject ( const QSharedPointer< PKG::DBObject > &  saveObject,
bool  wait,
const QWeakPointer< unsigned int > &  autoincrementIdResult 
)
pure virtual

insertObject This method execute a insert method of the saveObject and insert it into database.

Note
This method insert object into database only. IF object is exits in the database then this method return false.
Parameters
saveObjectThis is object for inserting.
waitThis arguments force current thread wait for the function finishing.
autoincrementIdResultis id of the insert query to the Table with autoincrement id field.
Returns
true if objects is saved successful else false. Note return two value. First is boolean result, second is id of inserted value.
Note
id will be returned only for the autoincement records.

Implemented in QH::SqlDBWriter.

◆ replaceObject()

virtual bool QH::iObjectProvider::replaceObject ( const QSharedPointer< PKG::DBObject > &  saveObject,
bool  wait 
)
pure virtual

replaceObject This method execute a replace method of the saveObject and insert or save if not exists, all changes into database.

Note
This method update object in the database only. If you try update not exists object then this method return false.
Parameters
saveObjectThis is object for updating.
waitThis arguments force current thread wait for the function finishing.
Returns
true if objects is updated successful else false.

Implemented in QH::SqlDBWriter.

◆ setSQLSources()

virtual void QH::iObjectProvider::setSQLSources ( const QStringList &  list)
pure virtual

setSQLSources This method set sql sources for deployed database.

Parameters
listThis is list of sql files with database sources.

For more information about sql sources see the DataBaseNode::SQLSources method.

Implemented in QH::ISqlDB, and QH::SqlDBWriter.

◆ updateObject()

virtual bool QH::iObjectProvider::updateObject ( const QSharedPointer< PKG::DBObject > &  saveObject,
bool  wait 
)
pure virtual

updateObject This method execute a update method of the saveObject and save all changes into database.

Note
This method update object in the database only.
Warning
This method do not guarantee that return false if The updated object is not exist.
Parameters
saveObjectThis is object for updating.
waitThis arguments force current thread wait for the function finishing.
Returns
true if objects is updated successful else false.

Implemented in QH::SqlDBWriter.


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