QxOrm 1.4.9
C++ Object Relational Mapping library
Loading...
Searching...
No Matches
QxFunction_7.h
Go to the documentation of this file.
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
32#ifndef _QX_FUNCTION_7_H_
33#define _QX_FUNCTION_7_H_
34
35#ifdef _MSC_VER
36#pragma once
37#endif
38
48
49namespace qx {
50
55template <class Owner, typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
57{
58
59public:
60
61 typedef std::function<R (Owner *, P1, P2, P3, P4, P5, P6, P7)> type_fct;
70
71 virtual int getParamCount() const { return 7; }
72 virtual qx_bool isValidParams(const QString & params) const { Q_UNUSED(params); return true; }
73 virtual qx_bool isValidParams(const type_any_params & params) const { Q_UNUSED(params); return true; }
74
75private:
76
77 template <class T, bool bReturnValue /* = false */>
79 {
80 static inline qx_bool invoke(void * pOwner, const T & params, qx::any * ret, const QxFunction_7 * pThis)
81 {
83 QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1);
84 QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2);
85 QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3);
86 QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4);
87 QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5);
88 QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6);
89 QX_FUNCTION_FETCH_PARAM(type_P7, p7, get_param_7);
90 try { pThis->m_fct(static_cast<Owner *>(pOwner), p1, p2, p3, p4, p5, p6, p7); }
92 }
93 };
94
95 template <class T>
96 struct QxInvokerFct<T, true>
97 {
98 static inline qx_bool invoke(void * pOwner, const T & params, qx::any * ret, const QxFunction_7 * pThis)
99 {
101 QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1);
102 QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2);
103 QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3);
104 QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4);
105 QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5);
106 QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6);
107 QX_FUNCTION_FETCH_PARAM(type_P7, p7, get_param_7);
108 try { R retTmp = pThis->m_fct(static_cast<Owner *>(pOwner), p1, p2, p3, p4, p5, p6, p7); if (ret) { (* ret) = qx::any(retTmp); } }
110 }
111 };
112
113};
114
115template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
116class QxFunction_7<void, R, P1, P2, P3, P4, P5, P6, P7> : public IxFunction
117{
118
119public:
120
121 typedef std::function<R (P1, P2, P3, P4, P5, P6, P7)> type_fct;
130
131 virtual int getParamCount() const { return 7; }
132 virtual qx_bool isValidParams(const QString & params) const { Q_UNUSED(params); return true; }
133 virtual qx_bool isValidParams(const type_any_params & params) const { Q_UNUSED(params); return true; }
134
135private:
136
137 template <class T, bool bReturnValue /* = false */>
139 {
140 static inline qx_bool invoke(const T & params, qx::any * ret, const QxFunction_7 * pThis)
141 {
143 QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1);
144 QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2);
145 QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3);
146 QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4);
147 QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5);
148 QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6);
149 QX_FUNCTION_FETCH_PARAM(type_P7, p7, get_param_7);
150 try { pThis->m_fct(p1, p2, p3, p4, p5, p6, p7); }
152 }
153 };
154
155 template <class T>
156 struct QxInvokerFct<T, true>
157 {
158 static inline qx_bool invoke(const T & params, qx::any * ret, const QxFunction_7 * pThis)
159 {
161 QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1);
162 QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2);
163 QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3);
164 QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4);
165 QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5);
166 QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6);
167 QX_FUNCTION_FETCH_PARAM(type_P7, p7, get_param_7);
168 try { R retTmp = pThis->m_fct(p1, p2, p3, p4, p5, p6, p7); if (ret) { (* ret) = qx::any(retTmp); } }
170 }
171 };
172
173};
174
175namespace function {
176
177template <class Owner, typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
179{
180 typedef std::is_same<Owner, void> qx_verify_owner_tmp;
181 static_assert(qx_verify_owner_tmp::value, "qx_verify_owner_tmp::value");
182 IxFunction_ptr ptr = std::make_shared<QxFunction_7<void, R, P1, P2, P3, P4, P5, P6, P7> >(fct);
183 return ptr;
184}
185
186template <class Owner, typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
188{
189 typedef std::is_same<Owner, void> qx_verify_owner_tmp;
190 static_assert(! qx_verify_owner_tmp::value, "! qx_verify_owner_tmp::value");
191 IxFunction_ptr ptr = std::make_shared<QxFunction_7<Owner, R, P1, P2, P3, P4, P5, P6, P7> >(fct);
192 return ptr;
193}
194
195} // namespace function
196} // namespace qx
197
198#endif // _QX_FUNCTION_7_H_
Common interface for all functions registered into QxOrm context (used by introspection engine)
#define QX_FUNCTION_FETCH_PARAM(TYPE, VALUE, FCT)
#define QX_FUNCTION_INVOKE_START_WITHOUT_OWNER()
#define QX_FUNCTION_INVOKE_START_WITH_OWNER()
#define QX_FUNCTION_CATCH_AND_RETURN_INVOKE()
qx::function::detail::get_param_X() : provide some helper functions to retrieve parameters for all qx...
qx::IxFunction : common interface for all functions registered into QxOrm context (used by introspect...
Definition IxFunction.h:64
std::vector< qx::any > type_any_params
Definition IxFunction.h:74
qx_bool : boolean type with code and description message when an error occured
Definition QxBool.h:71
virtual qx_bool isValidParams(const QString &params) const
qx::trait::remove_attr< P4, false >::type type_P4
virtual qx_bool isValidParams(const type_any_params &params) const
std::function< R(P1, P2, P3, P4, P5, P6, P7)> type_fct
qx::trait::remove_attr< P6, false >::type type_P6
qx::trait::remove_attr< P2, false >::type type_P2
qx::trait::remove_attr< P5, false >::type type_P5
qx::trait::remove_attr< P1, false >::type type_P1
qx::trait::remove_attr< P7, false >::type type_P7
qx::trait::remove_attr< P3, false >::type type_P3
qx::QxFunction_7<Owner, R, P1, P2, P3, P4, P5, P6, P7> : concrete function registered into QxOrm cont...
qx::trait::remove_attr< P4, false >::type type_P4
std::function< R(Owner *, P1, P2, P3, P4, P5, P6, P7)> type_fct
qx::trait::remove_attr< P2, false >::type type_P2
qx::trait::remove_attr< P6, false >::type type_P6
qx::trait::remove_attr< P1, false >::type type_P1
qx::trait::remove_attr< P5, false >::type type_P5
virtual qx_bool isValidParams(const type_any_params &params) const
QX_FUNCTION_CLASS_MEMBER_FCT(QxFunction_7)
qx::trait::remove_attr< P7, false >::type type_P7
virtual int getParamCount() const
qx::trait::remove_attr< P3, false >::type type_P3
virtual qx_bool isValidParams(const QString &params) const
IxFunction_ptr bind_fct_7(const typename QxFunction_7< Owner, R, P1, P2, P3, P4, P5, P6, P7 >::type_fct &fct)
IxFunction_ptr bind_member_fct_7(const typename QxFunction_7< Owner, R, P1, P2, P3, P4, P5, P6, P7 >::type_fct &fct)
Root namespace for all QxOrm library features.
std::shared_ptr< IxFunction > IxFunction_ptr
Definition IxFunction.h:131
static qx_bool invoke(void *pOwner, const T &params, qx::any *ret, const QxFunction_7 *pThis)
static qx_bool invoke(void *pOwner, const T &params, qx::any *ret, const QxFunction_7 *pThis)
static qx_bool invoke(const T &params, qx::any *ret, const QxFunction_7 *pThis)
static qx_bool invoke(const T &params, qx::any *ret, const QxFunction_7 *pThis)