QxOrm 1.1.8
C++ Object Relational Mapping library
QxFunction_6.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 _QX_FUNCTION_6_H_
00027 #define _QX_FUNCTION_6_H_
00028 
00029 #ifdef _MSC_VER
00030 #pragma once
00031 #endif
00032 
00040 #include <QxFunction/IxFunction.h>
00041 #include <QxFunction/QxParameters.h>
00042 
00043 namespace qx {
00044 
00049 template <class Owner, typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
00050 class QxFunction_6 : public IxFunction
00051 {
00052 
00053 public:
00054 
00055    typedef boost::function<R (Owner *, P1, P2, P3, P4, P5, P6)> type_fct;
00056    typedef typename qx::trait::remove_attr<P1, false>::type type_P1;
00057    typedef typename qx::trait::remove_attr<P2, false>::type type_P2;
00058    typedef typename qx::trait::remove_attr<P3, false>::type type_P3;
00059    typedef typename qx::trait::remove_attr<P4, false>::type type_P4;
00060    typedef typename qx::trait::remove_attr<P5, false>::type type_P5;
00061    typedef typename qx::trait::remove_attr<P6, false>::type type_P6;
00062    QX_FUNCTION_CLASS_MEMBER_FCT(QxFunction_6);
00063 
00064    virtual qx_bool isValidParams(const QString & params) const          { Q_UNUSED(params); return true; }
00065    virtual qx_bool isValidParams(const type_any_params & params) const  { Q_UNUSED(params); return true; }
00066 
00067 private:
00068 
00069    template <class T, bool bReturnValue /* = false */>
00070    struct QxInvokerFct
00071    {
00072       static inline qx_bool invoke(void * pOwner, const T & params, boost::any * ret, const QxFunction_6 * pThis)
00073       {
00074          QX_FUNCTION_INVOKE_START_WITH_OWNER();
00075          QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1);
00076          QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2);
00077          QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3);
00078          QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4);
00079          QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5);
00080          QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6);
00081          try { pThis->m_fct(static_cast<Owner *>(pOwner), p1, p2, p3, p4, p5, p6); }
00082          QX_FUNCTION_CATCH_AND_RETURN_INVOKE();
00083       }
00084    };
00085 
00086    template <class T>
00087    struct QxInvokerFct<T, true>
00088    {
00089       static inline qx_bool invoke(void * pOwner, const T & params, boost::any * ret, const QxFunction_6 * pThis)
00090       {
00091          QX_FUNCTION_INVOKE_START_WITH_OWNER();
00092          QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1);
00093          QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2);
00094          QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3);
00095          QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4);
00096          QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5);
00097          QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6);
00098          try { R retTmp = pThis->m_fct(static_cast<Owner *>(pOwner), p1, p2, p3, p4, p5, p6); if (ret) { (* ret) = boost::any(retTmp); } }
00099          QX_FUNCTION_CATCH_AND_RETURN_INVOKE();
00100       }
00101    };
00102 
00103 };
00104 
00105 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
00106 class QxFunction_6<void, R, P1, P2, P3, P4, P5, P6> : public IxFunction
00107 {
00108 
00109 public:
00110 
00111    typedef boost::function<R (P1, P2, P3, P4, P5, P6)> type_fct;
00112    typedef typename qx::trait::remove_attr<P1, false>::type type_P1;
00113    typedef typename qx::trait::remove_attr<P2, false>::type type_P2;
00114    typedef typename qx::trait::remove_attr<P3, false>::type type_P3;
00115    typedef typename qx::trait::remove_attr<P4, false>::type type_P4;
00116    typedef typename qx::trait::remove_attr<P5, false>::type type_P5;
00117    typedef typename qx::trait::remove_attr<P6, false>::type type_P6;
00118    QX_FUNCTION_CLASS_FCT(QxFunction_6);
00119 
00120    virtual qx_bool isValidParams(const QString & params) const          { Q_UNUSED(params); return true; }
00121    virtual qx_bool isValidParams(const type_any_params & params) const  { Q_UNUSED(params); return true; }
00122 
00123 private:
00124 
00125    template <class T, bool bReturnValue /* = false */>
00126    struct QxInvokerFct
00127    {
00128       static inline qx_bool invoke(const T & params, boost::any * ret, const QxFunction_6 * pThis)
00129       {
00130          QX_FUNCTION_INVOKE_START_WITHOUT_OWNER();
00131          QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1);
00132          QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2);
00133          QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3);
00134          QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4);
00135          QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5);
00136          QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6);
00137          try { pThis->m_fct(p1, p2, p3, p4, p5, p6); }
00138          QX_FUNCTION_CATCH_AND_RETURN_INVOKE();
00139       }
00140    };
00141 
00142    template <class T>
00143    struct QxInvokerFct<T, true>
00144    {
00145       static inline qx_bool invoke(const T & params, boost::any * ret, const QxFunction_6 * pThis)
00146       {
00147          QX_FUNCTION_INVOKE_START_WITHOUT_OWNER();
00148          QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1);
00149          QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2);
00150          QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3);
00151          QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4);
00152          QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5);
00153          QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6);
00154          try { R retTmp = pThis->m_fct(p1, p2, p3, p4, p5, p6); if (ret) { (* ret) = boost::any(retTmp); } }
00155          QX_FUNCTION_CATCH_AND_RETURN_INVOKE();
00156       }
00157    };
00158 
00159 };
00160 
00161 namespace function {
00162 
00163 template <class Owner, typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
00164 IxFunction_ptr bind_fct_6(const typename QxFunction_6<Owner, R, P1, P2, P3, P4, P5, P6>::type_fct & fct)
00165 {
00166    typedef boost::is_same<Owner, void> qx_verify_owner_tmp;
00167    BOOST_STATIC_ASSERT(qx_verify_owner_tmp::value);
00168    IxFunction_ptr ptr; ptr.reset(new QxFunction_6<void, R, P1, P2, P3, P4, P5, P6>(fct));
00169    return ptr;
00170 }
00171 
00172 template <class Owner, typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
00173 IxFunction_ptr bind_member_fct_6(const typename QxFunction_6<Owner, R, P1, P2, P3, P4, P5, P6>::type_fct & fct)
00174 {
00175    typedef boost::is_same<Owner, void> qx_verify_owner_tmp;
00176    BOOST_STATIC_ASSERT(! qx_verify_owner_tmp::value);
00177    IxFunction_ptr ptr; ptr.reset(new QxFunction_6<Owner, R, P1, P2, P3, P4, P5, P6>(fct));
00178    return ptr;
00179 }
00180 
00181 } // namespace function
00182 } // namespace qx
00183 
00184 #endif // _QX_FUNCTION_6_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines