8#ifndef IOBJECTPROVIDER_H
9#define IOBJECTPROVIDER_H
12#include <QSharedPointer>
39 QSharedPointer<TYPE>
getObject(
const TYPE &templateVal) {
41 static_assert (std::is_base_of_v<PKG::DBObject, TYPE>,
42 "The getObject must be work with DBObject child types only");
44 static_assert (!std::is_pointer_v<TYPE>,
45 "The getObject must be work with non pointer types.");
48 auto val = getObjectRaw(templateVal);
49 auto result = val.template dynamicCast<TYPE>();
50 if (!result && !val.isNull()) {
52 qCritical() <<
"getObject method returned object with deffirent type of TYPE,"
53 " check getAllObjects merhod";
66 QSharedPointer<PKG::DBObject> getObjectRaw(
const PKG::DBObject &templateVal);
75 QList<QSharedPointer<PKG::DBObject>> &result) = 0;
84 virtual bool replaceObject(
const QSharedPointer<PKG::DBObject>& saveObject,
bool wait) = 0;
94 virtual bool updateObject(
const QSharedPointer<PKG::DBObject>& saveObject,
bool wait) = 0;
105 virtual bool insertObject(
const QSharedPointer<PKG::DBObject>& saveObject,
107 const QWeakPointer<unsigned int>& autoincrementIdResult) = 0;
115 virtual bool deleteObject(
const QSharedPointer<PKG::DBObject>& obj,
bool wait) = 0;
133 virtual bool doQuery(
const QString& query,
const QVariantMap& bindValues = {},
134 bool wait =
false, QSqlQuery* result =
nullptr)
const = 0;
141 virtual bool doSql(
const QString& sqlFile,
bool wait =
true)
const = 0;
The DBObject class- main class for work with data base.
The iObjectProvider class is base interface for work with database objects. Using on database writers...
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 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 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 void setSQLSources(const QStringList &list)=0
setSQLSources This method set sql sources for deployed database.
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...
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.
QSharedPointer< TYPE > getObject(const TYPE &templateVal)
getObject this method return a strong pointer to DBObject created by select method of the template ob...
virtual bool doSql(const QString &sqlFile, bool wait=true) const =0
doSql This method execute a query in this database.
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 select...
#define HEARTSHARED_EXPORT
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...