| QxOrm 1.4.4 C++ Object Relational Mapping library

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

QxSqlRelationParams.h
Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** http://www.qxorm.com/
    00004 ** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
    00005 **
    00006 ** This file is part of the QxOrm library
    00007 **
    00008 ** This software is provided 'as-is', without any express or implied
    00009 ** warranty. In no event will the authors be held liable for any
    00010 ** damages arising from the use of this software
    00011 **
    00012 ** Commercial Usage
    00013 ** Licensees holding valid commercial QxOrm licenses may use this file in
    00014 ** accordance with the commercial license agreement provided with the
    00015 ** Software or, alternatively, in accordance with the terms contained in
    00016 ** a written agreement between you and Lionel Marty
    00017 **
    00018 ** GNU General Public License Usage
    00019 ** Alternatively, this file may be used under the terms of the GNU
    00020 ** General Public License version 3.0 as published by the Free Software
    00021 ** Foundation and appearing in the file 'license.gpl3.txt' included in the
    00022 ** packaging of this file. Please review the following information to
    00023 ** ensure the GNU General Public License version 3.0 requirements will be
    00024 ** met : http://www.gnu.org/copyleft/gpl.html
    00025 **
    00026 ** If you are unsure which license is appropriate for your use, or
    00027 ** if you have questions regarding the use of this file, please contact :
    00028 ** contact@qxorm.com
    00029 **
    00030 ****************************************************************************/
    00031
    00032 #ifndef _QX_SQL_RELATION_PARAMS_H_
    00033 #define _QX_SQL_RELATION_PARAMS_H_
    00034
    00035 #ifdef _MSC_VER
    00036 #pragma once
    00037 #endif
    00038
    00046 #include <QtSql/qsqldatabase.h>
    00047 #include <QtSql/qsqlquery.h>
    00048
    00049 #include <QxDao/QxSqlJoin.h>
    00050 #include <QxDao/QxSqlSaveMode.h>
    00051
    00052 #include <QxCollection/QxCollection.h>
    00053
    00054 namespace qx {
    00055
    00056 class QxSqlRelationLinked;
    00057 class IxSqlQueryBuilder;
    00058 class IxSqlRelation;
    00059
    00064 class QX_DLL_EXPORT QxSqlRelationParams
    00065 {
    00066
    00067 public:
    00068
    00069    typedef std::shared_ptr<QxSqlRelationLinked> type_relation_linked_ptr;
    00070    typedef QHash<QString, type_relation_linked_ptr> type_lst_relation_linked;
    00071
    00072 protected:
    00073
    00074    QVariant                         m_vId;
    00075    long                             m_lIndex;
    00076    long                             m_lIndexOwner;
    00077    long                             m_lOffset;
    00078    QString *                        m_sql;
    00079    IxSqlQueryBuilder *              m_builder;
    00080    QSqlQuery *                      m_query;
    00081    QSqlDatabase *                   m_database;
    00082    void *                           m_pOwner;
    00083    qx::dao::sql_join::join_type     m_eJoinType;
    00084    type_lst_relation_linked *       m_pRelationX;
    00085    QString                          m_sTableAlias;
    00086    qx::dao::save_mode::e_save_mode  m_eSaveMode;
    00087    bool                             m_bRecursiveMode;
    00088    QSet<void *>                     m_lstRecursiveItems;
    00089    QPair<QSet<QString>, long> *     m_pColumns;
    00090
    00091 public:
    00092
    00093    QxSqlRelationParams();
    00094    QxSqlRelationParams(long lIndex, long lOffset, QString * sql, IxSqlQueryBuilder * builder, QSqlQuery * query, void * pOwner);
    00095    QxSqlRelationParams(long lIndex, long lOffset, QString * sql, IxSqlQueryBuilder * builder, QSqlQuery * query, void * pOwner, const QVariant & vId);
    00096    virtual ~QxSqlRelationParams();
    00097
    00098    inline QVariant id() const                               { return m_vId; }
    00099    inline long index() const                                { return m_lIndex; }
    00100    inline long indexOwner() const                           { return m_lIndexOwner; }
    00101    inline long offset() const                               { return m_lOffset; }
    00102    inline QString & sql()                                   { qAssert(m_sql); return (* m_sql); }
    00103    inline const QString & sql() const                       { qAssert(m_sql); return (* m_sql); }
    00104    inline QSqlQuery & query()                               { qAssert(m_query); return (* m_query); }
    00105    inline const QSqlQuery & query() const                   { qAssert(m_query); return (* m_query); }
    00106    inline QSqlDatabase & database()                         { qAssert(m_database); return (* m_database); }
    00107    inline const QSqlDatabase & database() const             { qAssert(m_database); return (* m_database); }
    00108    inline IxSqlQueryBuilder & builder()                     { qAssert(m_builder); return (* m_builder); }
    00109    inline const IxSqlQueryBuilder & builder() const         { qAssert(m_builder); return (* m_builder); }
    00110    inline void * owner() const                              { return m_pOwner; }
    00111    inline qx::dao::sql_join::join_type joinType() const     { return m_eJoinType; }
    00112    inline type_lst_relation_linked * relationX() const      { return m_pRelationX; }
    00113    inline QString getTableAlias() const                     { return m_sTableAlias; }
    00114    inline qx::dao::save_mode::e_save_mode saveMode() const  { return m_eSaveMode; }
    00115    inline bool recursiveMode() const                        { return m_bRecursiveMode; }
    00116    inline bool existRecursiveItem(void * p) const           { return m_lstRecursiveItems.contains(p); }
    00117    inline QSet<QString> getColumns() const                  { return (m_pColumns ? m_pColumns->first : QSet<QString>()); }
    00118    inline bool checkColumns(const QString & s) const        { return (! m_pColumns || m_pColumns->first.isEmpty() || m_pColumns->first.contains(s)); }
    00119    inline long getColumnsCount() const                      { return (m_pColumns ? m_pColumns->first.count() : 0); }
    00120    inline long getColumnsOffset() const                     { return (m_pColumns ? m_pColumns->second : 0); }
    00121
    00122    inline void setId(const QVariant & vId)                     { m_vId = vId; }
    00123    inline void setIndex(long lIndex)                           { m_lIndex = lIndex; }
    00124    inline void setIndexOwner(long lIndex)                      { m_lIndexOwner = lIndex; }
    00125    inline void setOffset(long lOffset)                         { m_lOffset = lOffset; }
    00126    inline void setSql(QString * sql)                           { m_sql = sql; }
    00127    inline void setBuilder(IxSqlQueryBuilder * builder)         { m_builder = builder; }
    00128    inline void setQuery(QSqlQuery * query)                     { m_query = query; }
    00129    inline void setDatabase(QSqlDatabase * database)            { m_database = database; }
    00130    inline void setOwner(void * pOwner)                         { m_pOwner = pOwner; }
    00131    inline void setJoinType(qx::dao::sql_join::join_type e)     { m_eJoinType = e; }
    00132    inline void setRelationX(type_lst_relation_linked * p)      { m_pRelationX = p; }
    00133    inline void setTableAlias(const QString & s)                { m_sTableAlias = s; }
    00134    inline void setSaveMode(qx::dao::save_mode::e_save_mode e)  { m_eSaveMode = e; }
    00135    inline void setRecursiveMode(bool b)                        { m_bRecursiveMode = b; }
    00136    inline void insertRecursiveItem(void * p)                   { if (p) { m_lstRecursiveItems.insert(p); } }
    00137    inline void setColumns(QPair<QSet<QString>, long> * p)      { m_pColumns = p; }
    00138    inline void setColumnsOffset(long l)                        { if (m_pColumns) { m_pColumns->second = l; } }
    00139
    00140 };
    00141
    00142 } // namespace qx
    00143
    00144 #endif // _QX_SQL_RELATION_PARAMS_H_