Click here to Skip to main content
15,892,161 members
Articles / Web Development / HTML

QxOrm - C++ ORM (Object Relational Mapping) Library

Rate me:
Please Sign up or sign in to vote.
4.90/5 (61 votes)
24 Apr 2019GPL326 min read 140.9K   321   140  
QxOrm C++ library: Persistence (based on QtSql Qt library) - Serialization (based on boost::serialization library) - Reflection (introspection)
/****************************************************************************
**
** http://www.qxorm.com/
** http://sourceforge.net/projects/qxorm/
** Original file by Lionel Marty
**
** This file is part of the QxOrm library
**
** This software is provided 'as-is', without any express or implied
** warranty. In no event will the authors be held liable for any
** damages arising from the use of this software.
**
** GNU Lesser General Public License Usage
** This file must be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file 'license.lgpl.txt' included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you have questions regarding the use of this file, please contact :
** contact@qxorm.com
**
****************************************************************************/

#ifndef _QX_FUNCTION_9_H_
#define _QX_FUNCTION_9_H_

#ifdef _MSC_VER
#pragma once
#endif

/*!
 * \file QxFunction_9.h
 * \author Lionel Marty
 * \ingroup QxFunction
 * \brief Concrete function class registered into QxOrm context with 9 parameters
 */

#include <QxFunction/IxFunction.h>
#include <QxFunction/QxParameters.h>

namespace qx {

/*!
 * \ingroup QxFunction
 * \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
 */
template <class Owner, typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9>
class QxFunction_9 : public IxFunction
{

public:

   typedef boost::function<R (Owner *, P1, P2, P3, P4, P5, P6, P7, P8, P9)> type_fct;
   typedef typename qx::trait::remove_attr<P1, false>::type type_P1;
   typedef typename qx::trait::remove_attr<P2, false>::type type_P2;
   typedef typename qx::trait::remove_attr<P3, false>::type type_P3;
   typedef typename qx::trait::remove_attr<P4, false>::type type_P4;
   typedef typename qx::trait::remove_attr<P5, false>::type type_P5;
   typedef typename qx::trait::remove_attr<P6, false>::type type_P6;
   typedef typename qx::trait::remove_attr<P7, false>::type type_P7;
   typedef typename qx::trait::remove_attr<P8, false>::type type_P8;
   typedef typename qx::trait::remove_attr<P9, false>::type type_P9;
   QX_FUNCTION_CLASS_MEMBER_FCT(QxFunction_9);

   virtual qx_bool isValidParams(const QString & params) const          { Q_UNUSED(params); return true; }
   virtual qx_bool isValidParams(const type_any_params & params) const  { Q_UNUSED(params); return true; }

private:

   template <class T, bool bReturnValue /* = false */>
   struct QxInvokerFct
   {
      static inline qx_bool invoke(void * pOwner, const T & params, boost::any * ret, const QxFunction_9 * pThis)
      {
         QX_FUNCTION_INVOKE_START_WITH_OWNER();
         QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1);
         QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2);
         QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3);
         QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4);
         QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5);
         QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6);
         QX_FUNCTION_FETCH_PARAM(type_P7, p7, get_param_7);
         QX_FUNCTION_FETCH_PARAM(type_P8, p8, get_param_8);
         QX_FUNCTION_FETCH_PARAM(type_P9, p9, get_param_9);
         try { pThis->m_fct(static_cast<Owner *>(pOwner), p1, p2, p3, p4, p5, p6, p7, p8, p9); }
         QX_FUNCTION_CATCH_AND_RETURN_INVOKE();
      }
   };

   template <class T>
   struct QxInvokerFct<T, true>
   {
      static inline qx_bool invoke(void * pOwner, const T & params, boost::any * ret, const QxFunction_9 * pThis)
      {
         QX_FUNCTION_INVOKE_START_WITH_OWNER();
         QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1);
         QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2);
         QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3);
         QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4);
         QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5);
         QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6);
         QX_FUNCTION_FETCH_PARAM(type_P7, p7, get_param_7);
         QX_FUNCTION_FETCH_PARAM(type_P8, p8, get_param_8);
         QX_FUNCTION_FETCH_PARAM(type_P9, p9, get_param_9);
         try { R retTmp = pThis->m_fct(static_cast<Owner *>(pOwner), p1, p2, p3, p4, p5, p6, p7, p8, p9); if (ret) { (* ret) = boost::any(retTmp); } }
         QX_FUNCTION_CATCH_AND_RETURN_INVOKE();
      }
   };

};

template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9>
class QxFunction_9<void, R, P1, P2, P3, P4, P5, P6, P7, P8, P9> : public IxFunction
{

public:

   typedef boost::function<R (P1, P2, P3, P4, P5, P6, P7, P8, P9)> type_fct;
   typedef typename qx::trait::remove_attr<P1, false>::type type_P1;
   typedef typename qx::trait::remove_attr<P2, false>::type type_P2;
   typedef typename qx::trait::remove_attr<P3, false>::type type_P3;
   typedef typename qx::trait::remove_attr<P4, false>::type type_P4;
   typedef typename qx::trait::remove_attr<P5, false>::type type_P5;
   typedef typename qx::trait::remove_attr<P6, false>::type type_P6;
   typedef typename qx::trait::remove_attr<P7, false>::type type_P7;
   typedef typename qx::trait::remove_attr<P8, false>::type type_P8;
   typedef typename qx::trait::remove_attr<P9, false>::type type_P9;
   QX_FUNCTION_CLASS_FCT(QxFunction_9);

   virtual qx_bool isValidParams(const QString & params) const          { Q_UNUSED(params); return true; }
   virtual qx_bool isValidParams(const type_any_params & params) const  { Q_UNUSED(params); return true; }

private:

   template <class T, bool bReturnValue /* = false */>
   struct QxInvokerFct
   {
      static inline qx_bool invoke(const T & params, boost::any * ret, const QxFunction_9 * pThis)
      {
         QX_FUNCTION_INVOKE_START_WITHOUT_OWNER();
         QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1);
         QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2);
         QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3);
         QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4);
         QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5);
         QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6);
         QX_FUNCTION_FETCH_PARAM(type_P7, p7, get_param_7);
         QX_FUNCTION_FETCH_PARAM(type_P8, p8, get_param_8);
         QX_FUNCTION_FETCH_PARAM(type_P9, p9, get_param_9);
         try { pThis->m_fct(p1, p2, p3, p4, p5, p6, p7, p8, p9); }
         QX_FUNCTION_CATCH_AND_RETURN_INVOKE();
      }
   };

   template <class T>
   struct QxInvokerFct<T, true>
   {
      static inline qx_bool invoke(const T & params, boost::any * ret, const QxFunction_9 * pThis)
      {
         QX_FUNCTION_INVOKE_START_WITHOUT_OWNER();
         QX_FUNCTION_FETCH_PARAM(type_P1, p1, get_param_1);
         QX_FUNCTION_FETCH_PARAM(type_P2, p2, get_param_2);
         QX_FUNCTION_FETCH_PARAM(type_P3, p3, get_param_3);
         QX_FUNCTION_FETCH_PARAM(type_P4, p4, get_param_4);
         QX_FUNCTION_FETCH_PARAM(type_P5, p5, get_param_5);
         QX_FUNCTION_FETCH_PARAM(type_P6, p6, get_param_6);
         QX_FUNCTION_FETCH_PARAM(type_P7, p7, get_param_7);
         QX_FUNCTION_FETCH_PARAM(type_P8, p8, get_param_8);
         QX_FUNCTION_FETCH_PARAM(type_P9, p9, get_param_9);
         try { R retTmp = pThis->m_fct(p1, p2, p3, p4, p5, p6, p7, p8, p9); if (ret) { (* ret) = boost::any(retTmp); } }
         QX_FUNCTION_CATCH_AND_RETURN_INVOKE();
      }
   };

};

namespace function {

template <class Owner, typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9>
IxFunction_ptr bind_fct_9(const typename QxFunction_9<Owner, R, P1, P2, P3, P4, P5, P6, P7, P8, P9>::type_fct & fct)
{
   typedef boost::is_same<Owner, void> qx_verify_owner_tmp;
   BOOST_STATIC_ASSERT(qx_verify_owner_tmp::value);
   IxFunction_ptr ptr; ptr.reset(new QxFunction_9<void, R, P1, P2, P3, P4, P5, P6, P7, P8, P9>(fct));
   return ptr;
}

template <class Owner, typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9>
IxFunction_ptr bind_member_fct_9(const typename QxFunction_9<Owner, R, P1, P2, P3, P4, P5, P6, P7, P8, P9>::type_fct & fct)
{
   typedef boost::is_same<Owner, void> qx_verify_owner_tmp;
   BOOST_STATIC_ASSERT(! qx_verify_owner_tmp::value);
   IxFunction_ptr ptr; ptr.reset(new QxFunction_9<Owner, R, P1, P2, P3, P4, P5, P6, P7, P8, P9>(fct));
   return ptr;
}

} // namespace function
} // namespace qx

#endif // _QX_FUNCTION_9_H_

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
France France
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions