| QxOrm 1.1.8 C++ Object Relational Mapping library

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

QxClassX.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_CLASS_X_H_
    00027 #define _QX_CLASS_X_H_
    00028
    00029 #ifdef _MSC_VER
    00030 #pragma once
    00031 #endif
    00032
    00040 #include <boost/mpl/if.hpp>
    00041 #include <boost/mpl/or.hpp>
    00042 #include <boost/mpl/logical.hpp>
    00043 #include <boost/type_traits/is_pointer.hpp>
    00044
    00045 #include <QxCommon/QxBool.h>
    00046
    00047 #include <QxRegister/IxClass.h>
    00048
    00049 #include <QxSingleton/QxSingleton.h>
    00050
    00051 #include <QxCollection/QxCollection.h>
    00052
    00053 #include <QxTraits/is_smart_ptr.h>
    00054
    00055 namespace qx {
    00056
    00061 class QX_DLL_EXPORT QxClassX : public QxSingleton<QxClassX>
    00062 {
    00063
    00064    friend class QxSingleton<QxClassX>;
    00065    friend class IxClass;
    00066
    00067 public:
    00068
    00069    typedef IxFunction::type_any_params type_any_params;
    00070
    00071 protected:
    00072
    00073    QxCollection<QString, IxClass *> m_lstClass;
    00074
    00075 private:
    00076
    00077    QxClassX() : QxSingleton<QxClassX>("qx::QxClassX") { ; }
    00078    virtual ~QxClassX() { ; }
    00079
    00080    IxClass * get(const QString & sKey) const;
    00081    bool exist(const QString & sKey) const;
    00082    bool insert(const QString & sKey, IxClass * pClass);
    00083    bool remove(const QString & sKey);
    00084    void clear();
    00085
    00086 public:
    00087
    00088    static boost::any create(const QString & sKey);
    00089    static IxClass * getClass(const QString & sKey);
    00090    static IxDataMemberX * getDataMemberX(const QString & sKey);
    00091    static IxFunctionX * getFctMemberX(const QString & sKey);
    00092    static IxDataMember * getDataMember(const QString & sClassKey, const QString & sDataKey, bool bRecursive = true);
    00093    static IxFunction * getFctMember(const QString & sClassKey, const QString & sFctKey, bool bRecursive = true);
    00094
    00095    template <class U>
    00096    static inline qx_bool invoke(const QString & sClassKey, const QString & sFctKey, U & pOwner, const QString & params = QString(), boost::any * ret = NULL)
    00097    {
    00098       typedef typename boost::mpl::if_c< boost::is_pointer<U>::value, QxClassX::invoke_ptr<U>, QxClassX::invoke_default<U> >::type type_invoke_1;
    00099       typedef typename boost::mpl::if_c< qx::trait::is_smart_ptr<U>::value, QxClassX::invoke_ptr<U>, type_invoke_1 >::type type_invoke_2;
    00100       return type_invoke_2::invoke(sClassKey, sFctKey, pOwner, params, ret);
    00101    }
    00102
    00103    template <class U>
    00104    static inline qx_bool invoke(const QString & sClassKey, const QString & sFctKey, U & pOwner, const type_any_params & params, boost::any * ret = NULL)
    00105    {
    00106       typedef typename boost::mpl::if_c< boost::is_pointer<U>::value, QxClassX::invoke_ptr<U>, QxClassX::invoke_default<U> >::type type_invoke_1;
    00107       typedef typename boost::mpl::if_c< qx::trait::is_smart_ptr<U>::value, QxClassX::invoke_ptr<U>, type_invoke_1 >::type type_invoke_2;
    00108       return type_invoke_2::invoke(sClassKey, sFctKey, pOwner, params, ret);
    00109    }
    00110
    00111 private:
    00112
    00113    template <class U>
    00114    struct invoke_ptr
    00115    {
    00116       static inline qx_bool invoke(const QString & sClassKey, const QString & sFctKey, U & pOwner, const QString & params = QString(), boost::any * ret = NULL)
    00117       { return QxClassX::invokeVoidPtr(sClassKey, sFctKey, static_cast<void *>(& (* pOwner)), params, ret); }
    00118       static inline qx_bool invoke(const QString & sClassKey, const QString & sFctKey, U & pOwner, const type_any_params & params, boost::any * ret = NULL)
    00119       { return QxClassX::invokeVoidPtr(sClassKey, sFctKey, static_cast<void *>(& (* pOwner)), params, ret); }
    00120    };
    00121
    00122    template <class U>
    00123    struct invoke_default
    00124    {
    00125       static inline qx_bool invoke(const QString & sClassKey, const QString & sFctKey, U & pOwner, const QString & params = QString(), boost::any * ret = NULL)
    00126       { return QxClassX::invokeVoidPtr(sClassKey, sFctKey, static_cast<void *>(& pOwner), params, ret); }
    00127       static inline qx_bool invoke(const QString & sClassKey, const QString & sFctKey, U & pOwner, const type_any_params & params, boost::any * ret = NULL)
    00128       { return QxClassX::invokeVoidPtr(sClassKey, sFctKey, static_cast<void *>(& pOwner), params, ret); }
    00129    };
    00130
    00131    static qx_bool invokeVoidPtr(const QString & sClassKey, const QString & sFctKey, void * pOwner, const QString & params = QString(), boost::any * ret = NULL);
    00132    static qx_bool invokeVoidPtr(const QString & sClassKey, const QString & sFctKey, void * pOwner, const type_any_params & params, boost::any * ret = NULL);
    00133
    00134 };
    00135
    00136 } // namespace qx
    00137
    00138 QX_DLL_EXPORT_QX_SINGLETON_HPP(qx::QxClassX)
    00139
    00140 #endif // _QX_CLASS_X_H_

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines