Heart 1.3.848.aa44c26
Heart is base back end library for your c++ Qt projects.
|
The AsyncSqlDbWriter class is some as SqlDBWriter but run all command in own thread. This class is thread save. More...
#include <asyncsqldbwriter.h>
Public Member Functions | |
AsyncSqlDBWriter (QObject *ptr=nullptr) | |
~AsyncSqlDBWriter () | |
Public Member Functions inherited from QH::SqlDBWriter | |
SqlDBWriter (QThread *thread, QObject *ptr=nullptr) | |
virtual bool | initDb (const QString &initDbParams=DEFAULT_DB_PATH) |
initDb This method is wraper of the initDb(const QVariantMap ¶ms) method. This implementation read a initDbParams file and get all params from json. | |
virtual bool | initDb (const QVariantMap ¶ms) |
initDb This method initialize a database params and create a new database if the old database not exists. | |
virtual bool | isValid () const |
isValid This method return true if database is successful inited and working correctly. | |
bool | getAllObjects (const PKG::DBObject &templateObject, QList< QSharedPointer< PKG::DBObject > > &result) override |
getAllObjects This method execute a select method of the templateObject and return list of all selected from databaes or cache objects | |
bool | updateObject (const QSharedPointer< PKG::DBObject > &ptr, bool wait=false) override |
updateObject This method execute a update method of the saveObject and save all changes into database. | |
bool | deleteObject (const QSharedPointer< PKG::DBObject > &ptr, bool wait=false) override |
deleteObject This method execute a delete method of obj and remove current object from database. | |
bool | insertObject (const QSharedPointer< PKG::DBObject > &ptr, bool wait=false, const QWeakPointer< unsigned int > &autoincrementIdResult={}) override |
insertObject This method execute a insert method of the saveObject and insert it into database. | |
bool | replaceObject (const QSharedPointer< PKG::DBObject > &ptr, bool wait=false) override |
replaceObject This method execute a replace method of the saveObject and insert or save if not exists, all changes into database. | |
void | setSQLSources (const QStringList &list) override |
setSQLSources This method set sql sources for deployed database. | |
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. | |
QString | databaseLocation () const |
databaseLocation This method return location of database. If it is sqlite then return path to db file else return database name. | |
virtual | ~SqlDBWriter () override |
virtual bool | updateQuery (const QSharedPointer< QH::PKG::DBObject > &ptr) const |
updateQuery This method execute update query of object. For more Information see DBObject::prepareUpdateQuery. | |
virtual bool | selectQuery (const QH::PKG::DBObject &requestObject, QList< QSharedPointer< QH::PKG::DBObject > > &result) |
selectQuery generate select query to database from parameters. | |
virtual bool | deleteQuery (const QSharedPointer< QH::PKG::DBObject > &deleteObject) const |
deleteQuery This method prepare the delete object query. | |
virtual bool | insertQuery (const QSharedPointer< QH::PKG::DBObject > &insertObject, const QWeakPointer< unsigned int > &autoIncrementID={}) const |
insertQuery This method prepare the insert object query. | |
virtual bool | replaceQuery (const QSharedPointer< QH::PKG::DBObject > &insertObject) const |
replaceQuery This method prepare the replce object query. | |
Public Member Functions inherited from QH::Async | |
bool | asyncLauncher (const Job &job, bool await=false, bool freaze=true) const |
asyncLauncher This method invoke a job on the thread (using the asyncHandler method) of this object. | |
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. | |
Additional Inherited Members | |
Public Types inherited from QH::Async | |
using | Job = std::function< bool()> |
Protected Member Functions inherited from QH::SqlDBWriter | |
bool | enableFK () |
enableFK This method enable foreign key for the sqlite database. | |
bool | disableFK () |
disableFK This method disable foreign key for the sqlite database. | |
virtual QVariantMap | getInitParams (const QString &initFile) const |
getInitPararm This method read parameters of database. | |
virtual QVariantMap | defaultInitPararm () const |
defaultInitPararm This method return default parameters of the database. | |
virtual QSqlDatabase | initSqlDataBasse (const QString &driverName, const QString &name) |
initSqlDataBasse This method create ad database connection. Without configuration. This method invoked in the initDbPrivate method. | |
QSqlDatabase * | db () |
db This method return db connection. If SqlDBWriter in not inited then return nullptr. For more information about initialization the SqlDBWriter see the SqlDBWriter::initDb method. | |
const QSqlDatabase * | db () const |
db This is constant implementation of the SqlDBWriter::db method. | |
Protected Member Functions inherited from QH::Async | |
Async (QThread *thread, QObject *ptr=nullptr) | |
Async This is default constructor of the async object. | |
~Async () | |
bool | waitFor (bool *condition, int timeout=WAIT_TIME, bool freaze=true) const |
waitFor This is base wait function. | |
bool | waitFor (const Job &condition, int timeout=WAIT_TIME, bool freaze=true) const |
waitFor This is base wait function. | |
The AsyncSqlDbWriter class is some as SqlDBWriter but run all command in own thread. This class is thread save.
Definition at line 20 of file asyncsqldbwriter.h.
QH::AsyncSqlDBWriter::AsyncSqlDBWriter | ( | QObject * | ptr = nullptr | ) |
Definition at line 20 of file asyncsqldbwriter.cpp.
QH::AsyncSqlDBWriter::~AsyncSqlDBWriter | ( | ) |
Definition at line 26 of file asyncsqldbwriter.cpp.