QxOrm
1.5.0
C++ Object Relational Mapping library
|
00001 /**************************************************************************** 00002 ** 00003 ** https://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_FUNCTION_9_H_ 00033 #define _QX_FUNCTION_9_H_ 00034 00035 #ifdef _MSC_VER 00036 #pragma once 00037 #endif 00038 00046 #include <QxFunction/IxFunction.h> 00047 #include <QxFunction/QxParameters.h> 00048 00049 namespace qx { 00050 00055 template <class Owner, typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9> 00056 class QxFunction_9 : public IxFunction 00057 { 00058 00059 public: 00060 00061 typedef std::function<R (Owner *, P1, P2, P3, P4, P5, P6, P7, P8, P9)> type_fct; 00062 typedef typename qx::trait::remove_attr<P1, false>::type type_P1; 00063 typedef typename qx::trait::remove_attr<P2, false>::type type_P2; 00064 typedef typename qx::trait::remove_attr<P3, false>::type type_P3; 00065 typedef typename qx::trait::remove_attr<P4, false>::type type_P4; 00066 typedef typename qx::trait::remove_attr<P5, false>::type type_P5; 00067 typedef typename qx::trait::remove_attr<P6, false>::type type_P6; 00068 typedef typename qx::trait::remove_attr<P7, false>::type type_P7; 00069 typedef typename qx::trait::remove_attr<P8, false>::type type_P8; 00070 typedef typename qx::trait::remove_attr<P9, false>::type type_P9; 00071 QX_FUNCTION_CLASS_MEMBER_FCT(QxFunction_9); 00072 00073 virtual int getParamCount() const { return 9; } 00074 virtual qx_bool isValidParams(const QString & params) const { Q_UNUSED(params); return true; } 00075 virtual qx_bool isValidParams(const type_any_params & params) const { Q_UNUSED(params); return true; } 00076 00077 private: 00078 00079 template <class T, bool bReturnValue /* = false */> 00080 struct QxInvokerFct 00081 { 00082 static inline qx_bool invoke(void * pOwner, const T & params, qx::any * ret, const QxFunction_9 * pThis) 00083 { 00084 QX_FUNCTION_INVOKE_START_WITH_OWNER(); 00085 QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1); 00086 QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2); 00087 QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3); 00088 QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4); 00089 QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5); 00090 QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6); 00091 QX_FUNCTION_FETCH_PARAM(type_P7, p7, get_param_7); 00092 QX_FUNCTION_FETCH_PARAM(type_P8, p8, get_param_8); 00093 QX_FUNCTION_FETCH_PARAM(type_P9, p9, get_param_9); 00094 try { pThis->m_fct(static_cast<Owner *>(pOwner), p1, p2, p3, p4, p5, p6, p7, p8, p9); } 00095 QX_FUNCTION_CATCH_AND_RETURN_INVOKE(); 00096 } 00097 }; 00098 00099 template <class T> 00100 struct QxInvokerFct<T, true> 00101 { 00102 static inline qx_bool invoke(void * pOwner, const T & params, qx::any * ret, const QxFunction_9 * pThis) 00103 { 00104 QX_FUNCTION_INVOKE_START_WITH_OWNER(); 00105 QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1); 00106 QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2); 00107 QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3); 00108 QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4); 00109 QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5); 00110 QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6); 00111 QX_FUNCTION_FETCH_PARAM(type_P7, p7, get_param_7); 00112 QX_FUNCTION_FETCH_PARAM(type_P8, p8, get_param_8); 00113 QX_FUNCTION_FETCH_PARAM(type_P9, p9, get_param_9); 00114 try { R retTmp = pThis->m_fct(static_cast<Owner *>(pOwner), p1, p2, p3, p4, p5, p6, p7, p8, p9); if (ret) { (* ret) = qx::any(retTmp); } } 00115 QX_FUNCTION_CATCH_AND_RETURN_INVOKE(); 00116 } 00117 }; 00118 00119 }; 00120 00121 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9> 00122 class QxFunction_9<void, R, P1, P2, P3, P4, P5, P6, P7, P8, P9> : public IxFunction 00123 { 00124 00125 public: 00126 00127 typedef std::function<R (P1, P2, P3, P4, P5, P6, P7, P8, P9)> type_fct; 00128 typedef typename qx::trait::remove_attr<P1, false>::type type_P1; 00129 typedef typename qx::trait::remove_attr<P2, false>::type type_P2; 00130 typedef typename qx::trait::remove_attr<P3, false>::type type_P3; 00131 typedef typename qx::trait::remove_attr<P4, false>::type type_P4; 00132 typedef typename qx::trait::remove_attr<P5, false>::type type_P5; 00133 typedef typename qx::trait::remove_attr<P6, false>::type type_P6; 00134 typedef typename qx::trait::remove_attr<P7, false>::type type_P7; 00135 typedef typename qx::trait::remove_attr<P8, false>::type type_P8; 00136 typedef typename qx::trait::remove_attr<P9, false>::type type_P9; 00137 QX_FUNCTION_CLASS_FCT(QxFunction_9); 00138 00139 virtual int getParamCount() const { return 9; } 00140 virtual qx_bool isValidParams(const QString & params) const { Q_UNUSED(params); return true; } 00141 virtual qx_bool isValidParams(const type_any_params & params) const { Q_UNUSED(params); return true; } 00142 00143 private: 00144 00145 template <class T, bool bReturnValue /* = false */> 00146 struct QxInvokerFct 00147 { 00148 static inline qx_bool invoke(const T & params, qx::any * ret, const QxFunction_9 * pThis) 00149 { 00150 QX_FUNCTION_INVOKE_START_WITHOUT_OWNER(); 00151 QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1); 00152 QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2); 00153 QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3); 00154 QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4); 00155 QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5); 00156 QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6); 00157 QX_FUNCTION_FETCH_PARAM(type_P7, p7, get_param_7); 00158 QX_FUNCTION_FETCH_PARAM(type_P8, p8, get_param_8); 00159 QX_FUNCTION_FETCH_PARAM(type_P9, p9, get_param_9); 00160 try { pThis->m_fct(p1, p2, p3, p4, p5, p6, p7, p8, p9); } 00161 QX_FUNCTION_CATCH_AND_RETURN_INVOKE(); 00162 } 00163 }; 00164 00165 template <class T> 00166 struct QxInvokerFct<T, true> 00167 { 00168 static inline qx_bool invoke(const T & params, qx::any * ret, const QxFunction_9 * pThis) 00169 { 00170 QX_FUNCTION_INVOKE_START_WITHOUT_OWNER(); 00171 QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1); 00172 QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2); 00173 QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3); 00174 QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4); 00175 QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5); 00176 QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6); 00177 QX_FUNCTION_FETCH_PARAM(type_P7, p7, get_param_7); 00178 QX_FUNCTION_FETCH_PARAM(type_P8, p8, get_param_8); 00179 QX_FUNCTION_FETCH_PARAM(type_P9, p9, get_param_9); 00180 try { R retTmp = pThis->m_fct(p1, p2, p3, p4, p5, p6, p7, p8, p9); if (ret) { (* ret) = qx::any(retTmp); } } 00181 QX_FUNCTION_CATCH_AND_RETURN_INVOKE(); 00182 } 00183 }; 00184 00185 }; 00186 00187 namespace function { 00188 00189 template <class Owner, typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9> 00190 IxFunction_ptr bind_fct_9(const typename QxFunction_9<Owner, R, P1, P2, P3, P4, P5, P6, P7, P8, P9>::type_fct & fct) 00191 { 00192 typedef std::is_same<Owner, void> qx_verify_owner_tmp; 00193 static_assert(qx_verify_owner_tmp::value, "qx_verify_owner_tmp::value"); 00194 IxFunction_ptr ptr = std::make_shared<QxFunction_9<void, R, P1, P2, P3, P4, P5, P6, P7, P8, P9> >(fct); 00195 return ptr; 00196 } 00197 00198 template <class Owner, typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9> 00199 IxFunction_ptr bind_member_fct_9(const typename QxFunction_9<Owner, R, P1, P2, P3, P4, P5, P6, P7, P8, P9>::type_fct & fct) 00200 { 00201 typedef std::is_same<Owner, void> qx_verify_owner_tmp; 00202 static_assert(! qx_verify_owner_tmp::value, "! qx_verify_owner_tmp::value"); 00203 IxFunction_ptr ptr = std::make_shared<QxFunction_9<Owner, R, P1, P2, P3, P4, P5, P6, P7, P8, P9> >(fct); 00204 return ptr; 00205 } 00206 00207 } // namespace function 00208 } // namespace qx 00209 00210 #endif // _QX_FUNCTION_9_H_