QxFunction_9.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /****************************************************************************
  2. **
  3. ** https://www.qxorm.com/
  4. ** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
  5. **
  6. ** This file is part of the QxOrm library
  7. **
  8. ** This software is provided 'as-is', without any express or implied
  9. ** warranty. In no event will the authors be held liable for any
  10. ** damages arising from the use of this software
  11. **
  12. ** Commercial Usage
  13. ** Licensees holding valid commercial QxOrm licenses may use this file in
  14. ** accordance with the commercial license agreement provided with the
  15. ** Software or, alternatively, in accordance with the terms contained in
  16. ** a written agreement between you and Lionel Marty
  17. **
  18. ** GNU General Public License Usage
  19. ** Alternatively, this file may be used under the terms of the GNU
  20. ** General Public License version 3.0 as published by the Free Software
  21. ** Foundation and appearing in the file 'license.gpl3.txt' included in the
  22. ** packaging of this file. Please review the following information to
  23. ** ensure the GNU General Public License version 3.0 requirements will be
  24. ** met : http://www.gnu.org/copyleft/gpl.html
  25. **
  26. ** If you are unsure which license is appropriate for your use, or
  27. ** if you have questions regarding the use of this file, please contact :
  28. ** contact@qxorm.com
  29. **
  30. ****************************************************************************/
  31. #ifndef _QX_FUNCTION_9_H_
  32. #define _QX_FUNCTION_9_H_
  33. #ifdef _MSC_VER
  34. #pragma once
  35. #endif
  36. /*!
  37. * \file QxFunction_9.h
  38. * \author Lionel Marty
  39. * \ingroup QxFunction
  40. * \brief Concrete function class registered into QxOrm context with 9 parameters
  41. */
  42. #include <QxFunction/IxFunction.h>
  43. #include <QxFunction/QxParameters.h>
  44. namespace qx {
  45. /*!
  46. * \ingroup QxFunction
  47. * \brief qx::QxFunction_9<Owner, R, P1, P2, P3, P4, P5, P6, P7, P8, P9> : concrete function registered into QxOrm context defined into class Owner, returning an object of type R and with 9 parameters P1, P2, P3, P4, P5, P6, P7, P8, P9
  48. */
  49. template <class Owner, typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9>
  50. class QxFunction_9 : public IxFunction
  51. {
  52. public:
  53. typedef std::function<R (Owner *, P1, P2, P3, P4, P5, P6, P7, P8, P9)> type_fct;
  54. typedef typename qx::trait::remove_attr<P1, false>::type type_P1;
  55. typedef typename qx::trait::remove_attr<P2, false>::type type_P2;
  56. typedef typename qx::trait::remove_attr<P3, false>::type type_P3;
  57. typedef typename qx::trait::remove_attr<P4, false>::type type_P4;
  58. typedef typename qx::trait::remove_attr<P5, false>::type type_P5;
  59. typedef typename qx::trait::remove_attr<P6, false>::type type_P6;
  60. typedef typename qx::trait::remove_attr<P7, false>::type type_P7;
  61. typedef typename qx::trait::remove_attr<P8, false>::type type_P8;
  62. typedef typename qx::trait::remove_attr<P9, false>::type type_P9;
  63. QX_FUNCTION_CLASS_MEMBER_FCT(QxFunction_9);
  64. virtual int getParamCount() const { return 9; }
  65. virtual qx_bool isValidParams(const QString & params) const { Q_UNUSED(params); return true; }
  66. virtual qx_bool isValidParams(const type_any_params & params) const { Q_UNUSED(params); return true; }
  67. private:
  68. template <class T, bool bReturnValue /* = false */>
  69. struct QxInvokerFct
  70. {
  71. static inline qx_bool invoke(void * pOwner, const T & params, qx::any * ret, const QxFunction_9 * pThis)
  72. {
  73. QX_FUNCTION_INVOKE_START_WITH_OWNER();
  74. QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1);
  75. QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2);
  76. QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3);
  77. QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4);
  78. QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5);
  79. QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6);
  80. QX_FUNCTION_FETCH_PARAM(type_P7, p7, get_param_7);
  81. QX_FUNCTION_FETCH_PARAM(type_P8, p8, get_param_8);
  82. QX_FUNCTION_FETCH_PARAM(type_P9, p9, get_param_9);
  83. try { pThis->m_fct(static_cast<Owner *>(pOwner), p1, p2, p3, p4, p5, p6, p7, p8, p9); }
  84. QX_FUNCTION_CATCH_AND_RETURN_INVOKE();
  85. }
  86. };
  87. template <class T>
  88. struct QxInvokerFct<T, true>
  89. {
  90. static inline qx_bool invoke(void * pOwner, const T & params, qx::any * ret, const QxFunction_9 * pThis)
  91. {
  92. QX_FUNCTION_INVOKE_START_WITH_OWNER();
  93. QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1);
  94. QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2);
  95. QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3);
  96. QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4);
  97. QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5);
  98. QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6);
  99. QX_FUNCTION_FETCH_PARAM(type_P7, p7, get_param_7);
  100. QX_FUNCTION_FETCH_PARAM(type_P8, p8, get_param_8);
  101. QX_FUNCTION_FETCH_PARAM(type_P9, p9, get_param_9);
  102. 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); } }
  103. QX_FUNCTION_CATCH_AND_RETURN_INVOKE();
  104. }
  105. };
  106. };
  107. template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9>
  108. class QxFunction_9<void, R, P1, P2, P3, P4, P5, P6, P7, P8, P9> : public IxFunction
  109. {
  110. public:
  111. typedef std::function<R (P1, P2, P3, P4, P5, P6, P7, P8, P9)> type_fct;
  112. typedef typename qx::trait::remove_attr<P1, false>::type type_P1;
  113. typedef typename qx::trait::remove_attr<P2, false>::type type_P2;
  114. typedef typename qx::trait::remove_attr<P3, false>::type type_P3;
  115. typedef typename qx::trait::remove_attr<P4, false>::type type_P4;
  116. typedef typename qx::trait::remove_attr<P5, false>::type type_P5;
  117. typedef typename qx::trait::remove_attr<P6, false>::type type_P6;
  118. typedef typename qx::trait::remove_attr<P7, false>::type type_P7;
  119. typedef typename qx::trait::remove_attr<P8, false>::type type_P8;
  120. typedef typename qx::trait::remove_attr<P9, false>::type type_P9;
  121. QX_FUNCTION_CLASS_FCT(QxFunction_9);
  122. virtual int getParamCount() const { return 9; }
  123. virtual qx_bool isValidParams(const QString & params) const { Q_UNUSED(params); return true; }
  124. virtual qx_bool isValidParams(const type_any_params & params) const { Q_UNUSED(params); return true; }
  125. private:
  126. template <class T, bool bReturnValue /* = false */>
  127. struct QxInvokerFct
  128. {
  129. static inline qx_bool invoke(const T & params, qx::any * ret, const QxFunction_9 * pThis)
  130. {
  131. QX_FUNCTION_INVOKE_START_WITHOUT_OWNER();
  132. QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1);
  133. QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2);
  134. QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3);
  135. QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4);
  136. QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5);
  137. QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6);
  138. QX_FUNCTION_FETCH_PARAM(type_P7, p7, get_param_7);
  139. QX_FUNCTION_FETCH_PARAM(type_P8, p8, get_param_8);
  140. QX_FUNCTION_FETCH_PARAM(type_P9, p9, get_param_9);
  141. try { pThis->m_fct(p1, p2, p3, p4, p5, p6, p7, p8, p9); }
  142. QX_FUNCTION_CATCH_AND_RETURN_INVOKE();
  143. }
  144. };
  145. template <class T>
  146. struct QxInvokerFct<T, true>
  147. {
  148. static inline qx_bool invoke(const T & params, qx::any * ret, const QxFunction_9 * pThis)
  149. {
  150. QX_FUNCTION_INVOKE_START_WITHOUT_OWNER();
  151. QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1);
  152. QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2);
  153. QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3);
  154. QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4);
  155. QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5);
  156. QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6);
  157. QX_FUNCTION_FETCH_PARAM(type_P7, p7, get_param_7);
  158. QX_FUNCTION_FETCH_PARAM(type_P8, p8, get_param_8);
  159. QX_FUNCTION_FETCH_PARAM(type_P9, p9, get_param_9);
  160. try { R retTmp = pThis->m_fct(p1, p2, p3, p4, p5, p6, p7, p8, p9); if (ret) { (* ret) = qx::any(retTmp); } }
  161. QX_FUNCTION_CATCH_AND_RETURN_INVOKE();
  162. }
  163. };
  164. };
  165. namespace function {
  166. template <class Owner, typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9>
  167. IxFunction_ptr bind_fct_9(const typename QxFunction_9<Owner, R, P1, P2, P3, P4, P5, P6, P7, P8, P9>::type_fct & fct)
  168. {
  169. typedef std::is_same<Owner, void> qx_verify_owner_tmp;
  170. static_assert(qx_verify_owner_tmp::value, "qx_verify_owner_tmp::value");
  171. IxFunction_ptr ptr = std::make_shared<QxFunction_9<void, R, P1, P2, P3, P4, P5, P6, P7, P8, P9> >(fct);
  172. return ptr;
  173. }
  174. template <class Owner, typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9>
  175. IxFunction_ptr bind_member_fct_9(const typename QxFunction_9<Owner, R, P1, P2, P3, P4, P5, P6, P7, P8, P9>::type_fct & fct)
  176. {
  177. typedef std::is_same<Owner, void> qx_verify_owner_tmp;
  178. static_assert(! qx_verify_owner_tmp::value, "! qx_verify_owner_tmp::value");
  179. IxFunction_ptr ptr = std::make_shared<QxFunction_9<Owner, R, P1, P2, P3, P4, P5, P6, P7, P8, P9> >(fct);
  180. return ptr;
  181. }
  182. } // namespace function
  183. } // namespace qx
  184. #endif // _QX_FUNCTION_9_H_