| QxOrm 1.1.8 C++ Object Relational Mapping library

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

- File List
- File Members

get_base_class.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_GET_BASE_CLASS_H_
    00027 #define _QX_GET_BASE_CLASS_H_
    00028
    00029 #ifdef _MSC_VER
    00030 #pragma once
    00031 #endif
    00032
    00040 #include <boost/mpl/if.hpp>
    00041 #include <boost/mpl/logical.hpp>
    00042 #include <boost/type_traits/is_same.hpp>
    00043
    00044 #include <QxTraits/get_class_name.h>
    00045
    00046 namespace qx {
    00047 namespace trait {
    00048
    00049 class no_base_class_defined
    00050 { no_base_class_defined() { ; }; virtual ~no_base_class_defined() { ; }; virtual void dummy() = 0; };
    00051
    00056 template <class T>
    00057 class get_base_class
    00058 { public: typedef qx::trait::no_base_class_defined type; };
    00059
    00060 template <class T>
    00061 class is_base_class_defined
    00062 { public: enum { value = (boost::is_same<typename qx::trait::get_base_class<T>::type, qx::trait::no_base_class_defined>::value ? 0 : 1) }; };
    00063
    00064 template <class T>
    00065 class get_base_class_2
    00066 {
    00067 private: typedef typename qx::trait::get_base_class<T>::type type_base;
    00068 private: enum { is_base_ok = (boost::is_same<type_base, qx::trait::no_base_class_defined>::value ? 0 : 1) };
    00069 public: typedef typename boost::mpl::if_c<is_base_ok, type_base, T>::type type;
    00070 };
    00071
    00072 } // namespace trait
    00073 } // namespace qx
    00074
    00075 QX_REGISTER_CLASS_NAME(qx::trait::no_base_class_defined)
    00076
    00077 #define QX_REGISTER_BASE_CLASS(derivedClass, baseClass) \
    00078 namespace qx { namespace trait { \
    00079 template <> \
    00080 class get_base_class< derivedClass > \
    00081 { public: typedef baseClass type; }; \
    00082 } } // namespace qx::trait
    00083
    00084 #define QX_GET_BASE_CLASS(T)                       qx::trait::get_base_class< T >::type
    00085 #define QX_GET_BASE_CLASS_WITH_TYPENAME(T)         qx::trait::get_base_class< typename T >::type
    00086 #define QX_IS_BASE_CLASS_DEFINED(T)                qx::trait::is_base_class_defined< T >::value
    00087 #define QX_IS_BASE_CLASS_DEFINED_WITH_TYPENAME(T)  qx::trait::is_base_class_defined< typename T >::value
    00088 #define QX_GET_BASE_CLASS_2(T)                     qx::trait::get_base_class_2< T >::type
    00089 #define QX_GET_BASE_CLASS_2_WITH_TYPENAME(T)       qx::trait::get_base_class_2< typename T >::type
    00090
    00091 #endif // _QX_GET_BASE_CLASS_H_

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines