QxOrm 1.1.8
C++ Object Relational Mapping library
IxSqlRelation.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** http://www.qxorm.com/
00004 ** http://sourceforge.net/projects/qxorm/
00005 ** Original file by Lionel Marty
00006 **
00007 ** This file is part of the QxOrm library
00008 **
00009 ** This software is provided 'as-is', without any express or implied
00010 ** warranty. In no event will the authors be held liable for any
00011 ** damages arising from the use of this software.
00012 **
00013 ** GNU Lesser General Public License Usage
00014 ** This file must be used under the terms of the GNU Lesser
00015 ** General Public License version 2.1 as published by the Free Software
00016 ** Foundation and appearing in the file 'license.lgpl.txt' included in the
00017 ** packaging of this file.  Please review the following information to
00018 ** ensure the GNU Lesser General Public License version 2.1 requirements
00019 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00020 **
00021 ** If you have questions regarding the use of this file, please contact :
00022 ** contact@qxorm.com
00023 **
00024 ****************************************************************************/
00025 
00026 #ifndef _IX_SQL_RELATION_H_
00027 #define _IX_SQL_RELATION_H_
00028 
00029 #ifdef _MSC_VER
00030 #pragma once
00031 #endif
00032 
00040 #include <QxDao/QxSqlRelationParams.h>
00041 #include <QxDao/QxSoftDelete.h>
00042 
00043 #include <QxCollection/QxCollection.h>
00044 
00045 namespace qx {
00046 
00047 class IxDataMember;
00048 class IxDataMemberX;
00049 class IxSqlRelation;
00050 
00051 typedef QxCollection<QString, IxSqlRelation *> IxSqlRelationX;
00052 
00057 class QX_DLL_EXPORT IxSqlRelation
00058 {
00059 
00060 public:
00061 
00062    enum join_type { left_outer_join, inner_join };
00063 
00064 protected:
00065 
00066    IxDataMember *    m_pDataMember;       
00067    IxDataMemberX *   m_pDataMemberX;      
00068    IxDataMember *    m_pDataMemberId;     
00069    long              m_lOffsetRelation;   
00070    join_type         m_eJoinType;         
00071    QxSoftDelete      m_oSoftDelete;       
00072 
00073    QxCollection<QString, IxDataMember *> * m_lstDataMemberPtr;    
00074    IxSqlRelationX * m_lstSqlRelationPtr;                          
00075 
00076 public:
00077 
00078    IxSqlRelation(IxDataMember * p) : m_pDataMember(p), m_pDataMemberX(NULL), m_pDataMemberId(NULL), m_lOffsetRelation(100), m_eJoinType(left_outer_join), m_lstDataMemberPtr(NULL), m_lstSqlRelationPtr(NULL) { qAssert(p); }
00079    virtual ~IxSqlRelation() = 0;
00080 
00081    inline QxCollection<QString, IxDataMember *> * getLstDataMember() const { return m_lstDataMemberPtr; }
00082    inline IxSqlRelationX * getLstRelation() const                          { return m_lstSqlRelationPtr; }
00083 
00084    inline void setSqlJoinType(join_type e)         { m_eJoinType = e; }
00085    inline join_type getSqlJoinType() const         { return m_eJoinType; }
00086    inline IxDataMember * getDataMember() const     { return m_pDataMember; }
00087    inline IxDataMemberX * getDataMemberX() const   { return m_pDataMemberX; }
00088    inline IxDataMember * getDataId() const         { return m_pDataMemberId; }
00089 
00090    QString getKey() const;
00091    long getDataCount() const;
00092    long getRelationCount() const;
00093    IxDataMember * getDataByKey(const QString & sKey) const;
00094    IxDataMember * nextData(long & lIndex) const;
00095    IxSqlRelation * nextRelation(long & lIndex) const;
00096    QString table() const;
00097    QString tableAlias(QxSqlRelationParams & params) const;
00098    QString getSqlJoin() const;
00099 
00100    virtual void init() = 0;
00101    virtual bool getCartesianProduct() const = 0;
00102    virtual QVariant getIdFromQuery(bool bEager, QxSqlRelationParams & params) const = 0;
00103    virtual void updateOffset(bool bEager, QxSqlRelationParams & params) const = 0;
00104    virtual void createTable(QxSqlRelationParams & params) const = 0;
00105    virtual void lazySelect(QxSqlRelationParams & params) const = 0;
00106    virtual void eagerSelect(QxSqlRelationParams & params) const = 0;
00107    virtual void lazyFrom(QxSqlRelationParams & params) const = 0;
00108    virtual void eagerFrom(QxSqlRelationParams & params) const = 0;
00109    virtual void lazyJoin(QxSqlRelationParams & params) const = 0;
00110    virtual void eagerJoin(QxSqlRelationParams & params) const = 0;
00111    virtual void lazyWhere(QxSqlRelationParams & params) const = 0;
00112    virtual void eagerWhere(QxSqlRelationParams & params) const = 0;
00113    virtual void lazyWhereSoftDelete(QxSqlRelationParams & params) const = 0;
00114    virtual void eagerWhereSoftDelete(QxSqlRelationParams & params) const = 0;
00115    virtual void lazyFetch_ResolveInput(QxSqlRelationParams & params) const = 0;
00116    virtual void eagerFetch_ResolveInput(QxSqlRelationParams & params) const = 0;
00117    virtual void lazyFetch_ResolveOutput(QxSqlRelationParams & params) const = 0;
00118    virtual void eagerFetch_ResolveOutput(QxSqlRelationParams & params) const = 0;
00119    virtual void lazyInsert(QxSqlRelationParams & params) const = 0;
00120    virtual void lazyInsert_Values(QxSqlRelationParams & params) const = 0;
00121    virtual void lazyUpdate(QxSqlRelationParams & params) const = 0;
00122    virtual void lazyInsert_ResolveInput(QxSqlRelationParams & params) const = 0;
00123    virtual void lazyUpdate_ResolveInput(QxSqlRelationParams & params) const = 0;
00124    virtual QSqlError onBeforeSave(QxSqlRelationParams & params) const = 0;
00125    virtual QSqlError onAfterSave(QxSqlRelationParams & params) const = 0;
00126    virtual QSqlError createExtraTable(QxSqlRelationParams & params) const = 0;
00127 
00128 #ifndef NDEBUG
00129    bool verifyOffset(QxSqlRelationParams & params, bool bId) const;
00130 #else
00131    inline bool verifyOffset(QxSqlRelationParams & params, bool bId) const { Q_UNUSED(params); Q_UNUSED(bId); return true; }
00132 #endif // NDEBUG
00133 
00134 };
00135 
00136 } // namespace qx
00137 
00138 #endif // _IX_SQL_RELATION_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines