![]() |
QxOrm
1.2.4
C++ Object Relational Mapping library
|
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 _QX_SQL_RELATION_LINKED_H_ 00027 #define _QX_SQL_RELATION_LINKED_H_ 00028 00029 #ifdef _MSC_VER 00030 #pragma once 00031 #endif 00032 00040 #include <boost/tuple/tuple.hpp> 00041 #include <boost/tuple/tuple_comparison.hpp> 00042 #include <boost/tuple/tuple_io.hpp> 00043 00044 #include <QtSql/qsqlerror.h> 00045 00046 #include <QxCommon/QxBool.h> 00047 00048 #include <QxDao/IxSqlRelation.h> 00049 00050 #include <QxCollection/QxCollection.h> 00051 00052 namespace qx { 00053 00080 class QX_DLL_EXPORT QxSqlRelationLinked 00081 { 00082 00083 protected: 00084 00085 typedef boost::shared_ptr<QxSqlRelationLinked> type_ptr; 00086 typedef boost::tuple<qx::dao::sql_join::join_type, IxSqlRelation *> type_relation; 00087 typedef qx::QxCollection<QString, type_relation> type_lst_relation; 00088 typedef QHash<QString, type_ptr> type_lst_relation_linked; 00089 00090 type_lst_relation m_relationX; 00091 type_lst_relation_linked m_relationLinkedX; 00092 IxSqlRelationX * m_allRelationX; 00093 bool m_bRoot; 00094 00095 public: 00096 00097 QxSqlRelationLinked(); 00098 QxSqlRelationLinked(bool bRoot); 00099 virtual ~QxSqlRelationLinked(); 00100 00101 qx_bool buildHierarchy(IxSqlRelationX * pRelationX, const QStringList & sRelationX); 00102 00103 void hierarchySelect(QxSqlRelationParams & params); 00104 void hierarchyFrom(QxSqlRelationParams & params); 00105 void hierarchyJoin(QxSqlRelationParams & params); 00106 void hierarchyWhereSoftDelete(QxSqlRelationParams & params); 00107 void hierarchyResolveOutput(QxSqlRelationParams & params); 00108 QSqlError hierarchyOnBeforeSave(QxSqlRelationParams & params); 00109 QSqlError hierarchyOnAfterSave(QxSqlRelationParams & params); 00110 00111 bool getCartesianProduct() const; 00112 long getAllRelationCount() const; 00113 long getRelationCount() const; 00114 00115 protected: 00116 00117 qx_bool insertRelationToHierarchy(const QStringList & sRelationX, const QString & sKey, qx::dao::sql_join::join_type eJoinType); 00118 00119 }; 00120 00121 typedef boost::shared_ptr<QxSqlRelationLinked> QxSqlRelationLinked_ptr; 00122 00123 } // namespace qx 00124 00125 #endif // _QX_SQL_RELATION_LINKED_H_