32#ifndef _IX_PERSISTABLE_COLLECTION_H_
33#define _IX_PERSISTABLE_COLLECTION_H_
84template <
typename Key,
typename Value,
typename T>
108 if (relation.count() == 0) {
return qx::dao::count<T>(lCount, query, pDatabase); }
112 virtual QSqlError
qxFetchById(
const QVariant &
id = QVariant(),
const QStringList & columns = QStringList(),
const QStringList & relation = QStringList(), QSqlDatabase * pDatabase = NULL)
123 if (relation.count() == 0) { err =
qx::dao::fetch_all((* coll), pDatabase, columns); }
136 virtual QSqlError
qxInsert(
const QStringList & relation = QStringList(), QSqlDatabase * pDatabase = NULL,
bool bUseExecBatch =
false)
139 if (relation.count() == 0) { err =
qx::dao::insert((* coll), pDatabase, bUseExecBatch); }
144 virtual QSqlError
qxUpdate(
const qx::QxSqlQuery & query =
qx::QxSqlQuery(),
const QStringList & columns = QStringList(),
const QStringList & relation = QStringList(), QSqlDatabase * pDatabase = NULL,
bool bUseExecBatch =
false)
156 else if (relation.count() == 0) { err =
qx::dao::save((* coll), pDatabase); }
161 virtual QSqlError
qxDeleteById(
const QVariant &
id = QVariant(), QSqlDatabase * pDatabase = NULL,
bool bUseExecBatch =
false)
170 virtual QSqlError
qxDestroyById(
const QVariant &
id = QVariant(), QSqlDatabase * pDatabase = NULL,
bool bUseExecBatch =
false)
185 virtual qx_bool qxExist(
const QVariant &
id = QVariant(), QSqlDatabase * pDatabase = NULL)
192 { Q_UNUSED(bAsList); std::shared_ptr<qx::IxPersistableCollection> coll = std::make_shared<qx::QxPersistableCollection<Key, Value, T> >();
return coll; }
199 virtual QString
toJson(
const QString & format = QString())
const
202 virtual QJsonValue
toJson_(
const QString & format = QString())
const
Common interface (abstract class) for persistents classes using QX_PERSISTABLE_HPP() and QX_PERSISTAB...
QxOrm thread-safe container (keep insertion order + quick access by index + quick access by key)
Provide a serialization engine with Qt QJson classes (this feature requires Qt5)
qx::IxClass : common interface for all classes registered into QxOrm context
qx::IxPersistableCollection : common interface (abstract class) for collection persistent classes bas...
virtual bool __remove(long idx)=0
virtual long __count() const =0
virtual ~IxPersistableCollection()
virtual qx::IxPersistable_ptr __at(long idx) const =0
IxPersistableCollection()
qx::IxPersistable : common interface (abstract class) for persistents classes using QX_PERSISTABLE_HP...
qx_bool : boolean type with code and description message when an error occured
qx::QxCollection<Key, Value> : QxOrm thread-safe container (keep insertion order + quick access by in...
long count() const
Return the number of items in the list (same as 'size()')
void clear()
Remove all items from the list.
bool removeByIndex(long index)
Remove the item at index position 'index'.
const_reference_value getByIndex(long index) const
Return the item at index position 'index'.
qx::QxInvalidValueX : list of invalid values
qx::QxPersistableCollectionHelper<T>::type : return the collection type used by qx::IxPersistable int...
qx::QxCollection< qx_type_primary_key, qx_type_ptr > type_coll
qx::trait::get_primary_key< T >::type qx_type_primary_key
qx::QxPersistableCollection< qx_type_primary_key, qx_type_ptr, T > type
std::shared_ptr< T > qx_type_ptr
qx::QxPersistableCollection<Key, Value, T> : concrete class for collection persistent classes based o...
virtual QSqlError qxDeleteAll(QSqlDatabase *pDatabase=NULL)
Delete all lines of a table (database) mapped to current C++ class (registered into QxOrm context)
virtual bool __remove(long idx)
virtual qx_bool fromJson(const QString &json, const QString &format=QString())
virtual QSqlError qxCount(long &lCount, const qx::QxSqlQuery &query=qx::QxSqlQuery(), QSqlDatabase *pDatabase=NULL, const QStringList &relation=QStringList())
Return the number of lines in the table (database) mapped to the current C++ class (registered into Q...
virtual ~QxPersistableCollection()
virtual qx::IxClass * qxClass() const
Access to introspection engine (or reflection engine) of QxOrm library.
virtual QSqlError qxDestroyAll(QSqlDatabase *pDatabase=NULL)
Delete all lines of a table (database) mapped to current C++ class (registered into QxOrm context)
virtual qx_bool qxExist(const QVariant &id=QVariant(), QSqlDatabase *pDatabase=NULL)
Search if current instance already exists into database.
virtual QSqlError qxDestroyById(const QVariant &id=QVariant(), QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false)
Delete current instance from database.
virtual QSqlError qxDeleteByQuery(const qx::QxSqlQuery &query, QSqlDatabase *pDatabase=NULL)
Delete all lines of a table (database) mapped to current C++ class (registered into QxOrm context) an...
virtual QSqlError qxExecuteQuery(qx::QxSqlQuery &query, qx::IxPersistableCollection *list=NULL, QSqlDatabase *pDatabase=NULL)
Execute a custom SQL query or a stored procedure, all columns that can be mapped to the instance of t...
virtual QSqlError qxDestroyByQuery(const qx::QxSqlQuery &query, QSqlDatabase *pDatabase=NULL)
Delete all lines of a table (database) mapped to current C++ class (registered into QxOrm context) an...
virtual QSqlError qxExecuteQuery(qx::QxSqlQuery &query, QSqlDatabase *pDatabase=NULL)
Execute a custom SQL query or a stored procedure, all columns that can be mapped to the instance of t...
virtual QSqlError qxFetchById(const QVariant &id=QVariant(), const QStringList &columns=QStringList(), const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL)
Fetch current instance (retrieve all its properties) mapped to a table in the database (current insta...
virtual QJsonValue toJson_(const QString &format=QString()) const
virtual QSqlError qxFetchAll(qx::IxPersistableCollection *list=NULL, const QStringList &columns=QStringList(), const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL)
Fetch a list of objects (retrieve all elements and properties associated) of current type (container ...
virtual QSqlError qxDeleteById(const QVariant &id=QVariant(), QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false)
Delete current instance from database.
virtual QSqlError qxSave(const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL, qx::dao::save_mode::e_save_mode eSaveRecursiveMode=qx::dao::save_mode::e_none)
Insert (if no exist) or update (if already exist) current instance into database.
virtual std::shared_ptr< qx::IxPersistableCollection > qxNewPersistableCollection(bool bAsList=false) const
Create a new collection smart-pointer to fetch a list of items of current class type.
virtual qx::QxInvalidValueX qxValidate(const QStringList &groups=QStringList())
Check if current instance is valid or not.
virtual qx::IxPersistable_ptr __at(long idx) const
virtual QString toJson(const QString &format=QString()) const
virtual long qxCount(const qx::QxSqlQuery &query=qx::QxSqlQuery(), QSqlDatabase *pDatabase=NULL, const QStringList &relation=QStringList())
Return the number of lines in the table (database) mapped to the current C++ class (registered into Q...
virtual long __count() const
QxPersistableCollection()
virtual qx_bool fromJson_(const QJsonValue &json, const QString &format=QString())
virtual QSqlError qxFetchByQuery(const qx::QxSqlQuery &query, qx::IxPersistableCollection *list=NULL, const QStringList &columns=QStringList(), const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL)
Fetch a list of objects (retrieve all elements and properties associated) of current type (container ...
virtual QSqlError qxInsert(const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false)
Insert current instance into database.
virtual QSqlError qxUpdate(const qx::QxSqlQuery &query=qx::QxSqlQuery(), const QStringList &columns=QStringList(), const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false)
Update current instance into database (you can add a user SQL query to the default SQL query builded ...
static T * getSingleton()
qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library,...
#define QX_REGISTER_CLASS_NAME_TEMPLATE_3(className)
#define QX_REGISTER_CLASS_NAME(className)
#define QX_REGISTER_CLASS_NAME_TEMPLATE_1(className)
qx::trait::get_primary_key<T>::type : return primary key type of T, by default primary key is long ty...
QSqlError destroy_all(QSqlDatabase *pDatabase=NULL)
Destroy all lines of a table (database) mapped to a C++ class T (registered into QxOrm context),...
QSqlError execute_query(qx::QxSqlQuery &query, T &t, QSqlDatabase *pDatabase=NULL)
Execute a custom SQL query or a stored procedure, all columns that can be mapped to the instance of t...
QSqlError save(T &t, QSqlDatabase *pDatabase=NULL)
Insert (if no exist) or update (if already exist) an element or a list of elements into database.
QSqlError fetch_by_id(T &t, QSqlDatabase *pDatabase=NULL, const QStringList &columns=QStringList())
Fetch an object t (retrieve all its properties) of type T (registered into QxOrm context) mapped to a...
QSqlError fetch_by_query_with_relation(const QString &relation, const qx::QxSqlQuery &query, T &t, QSqlDatabase *pDatabase=NULL)
Fetch a list of objects (retrieve all elements and properties associated) of type T (container regist...
QSqlError fetch_by_id_with_relation(const QString &relation, T &t, QSqlDatabase *pDatabase=NULL)
Fetch an object t (retrieve all its properties) of type T (registered into QxOrm context) mapped to a...
QSqlError delete_by_id(T &t, QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false)
Delete a line (or list of lines) of a table (database) mapped to a C++ object of type T (registered i...
qx_bool exist(T &t, QSqlDatabase *pDatabase=NULL)
Search if an element (or list of elements) already exists into database.
QSqlError save_with_relation(const QString &relation, T &t, QSqlDatabase *pDatabase=NULL)
Insert (if no exist) or update (if already exist) an element and its relationships (or a list of elem...
QSqlError insert_with_relation(const QString &relation, T &t, QSqlDatabase *pDatabase=NULL)
Insert an element and its relationships (or a list of elements + relationships) into database.
QSqlError insert(T &t, QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false)
Insert an element or a list of elements into database.
QSqlError destroy_by_query(const qx::QxSqlQuery &query, QSqlDatabase *pDatabase=NULL)
Destroy all lines of a table (database) mapped to a C++ class T (registered into QxOrm context) and f...
QSqlError delete_all(QSqlDatabase *pDatabase=NULL)
Delete all lines of a table (database) mapped to a C++ class T (registered into QxOrm context)
QSqlError update_by_query(const qx::QxSqlQuery &query, T &t, QSqlDatabase *pDatabase=NULL, const QStringList &columns=QStringList(), bool bUseExecBatch=false)
Update an element or a list of elements into database (adding a user SQL query to the default SQL que...
QSqlError fetch_by_query(const qx::QxSqlQuery &query, T &t, QSqlDatabase *pDatabase=NULL, const QStringList &columns=QStringList())
Fetch a list of objects (retrieve all elements and properties associated) of type T (container regist...
QSqlError update_by_query_with_relation(const QString &relation, const qx::QxSqlQuery &query, T &t, QSqlDatabase *pDatabase=NULL)
Update an element and its relationships (or a list of elements + relationships) into database (adding...
QSqlError fetch_all(T &t, QSqlDatabase *pDatabase=NULL, const QStringList &columns=QStringList())
Fetch a list of objects (retrieve all elements and properties associated) of type T (container regist...
QSqlError delete_by_query(const qx::QxSqlQuery &query, QSqlDatabase *pDatabase=NULL)
Delete all lines of a table (database) mapped to a C++ class T (registered into QxOrm context) and fi...
QSqlError count_with_relation(long &lCount, const QStringList &relation, const qx::QxSqlQuery &query=qx::QxSqlQuery(), QSqlDatabase *pDatabase=NULL)
Return the number of lines in the table (database) mapped to the C++ class T (registered into QxOrm c...
QSqlError fetch_all_with_relation(const QString &relation, T &t, QSqlDatabase *pDatabase=NULL)
Fetch a list of objects (retrieve all elements and properties associated) of type T (container regist...
QSqlError save_with_relation_recursive(T &t, qx::dao::save_mode::e_save_mode eSaveMode=qx::dao::save_mode::e_check_insert_or_update, QSqlDatabase *pDatabase=NULL, qx::QxSqlRelationParams *pRelationParams=NULL)
Insert (if no exist) or update (if already exist) recursively an element and all levels of relationsh...
long count(const qx::QxSqlQuery &query=qx::QxSqlQuery(), QSqlDatabase *pDatabase=NULL)
Return the number of lines in the table (database) mapped to the C++ class T (registered into QxOrm c...
QSqlError destroy_by_id(T &t, QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false)
Destroy a line (or list of lines) of a table (database) mapped to a C++ object of type T (registered ...
qx::trait::is_qx_registered<T>::value : return true if T is registered into QxOrm context to provide ...
qx_bool from_json(const QJsonValue &j, T &t, const QString &format=QString())
QJsonValue to_json(const T &t, const QString &format=QString())
QString to_string(const T &obj, unsigned int flags=1, const QString &format=QString())
qx_bool from_string(T &obj, const QString &sString, unsigned int flags=1, const QString &format=QString())
Root namespace for all QxOrm library features.
QxInvalidValueX validate(T &t, const QString &group)
std::shared_ptr< qx::IxPersistableCollection > IxPersistableCollection_ptr
std::shared_ptr< qx::IxPersistable > IxPersistable_ptr
qx::trait::is_qx_registered<T>::value : return true if T is registered into QxOrm context to provide ...