The iObjectProvider class is base interface for work with database objects. Using on database writers and database caches.
More...
#include <iobjectprovider.h>
|
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.
|
|
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.
|
|
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.
◆ 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
-
obj | This is object for removing. |
wait | This 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
-
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. |
- 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
-
sqlFile | This 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
-
templateObject | This is template object for prepare a select request. |
result | This is return value, list of selected objects. |
- Returns
- true if objects have in db else false.
Implemented in QH::SqlDBWriter.
◆ 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
-
templateVal | This 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.
◆ getObjectRaw()
getObjectRaw This method return object without test object type.
- Note
- If you want get object with check object type use getObject method.
- Parameters
-
templateVal | This is template object with request to database. |
- Returns
- The database object pointer (not casted).
Definition at line 13 of file iobjectprovider.cpp.
◆ 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
-
saveObject | This is object for inserting. |
wait | This arguments force current thread wait for the function finishing. |
autoincrementIdResult | is 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
-
saveObject | This is object for updating. |
wait | This 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
-
list | This 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
-
saveObject | This is object for updating. |
wait | This 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: