| QxOrm 1.2.4 C++ Object Relational Mapping library

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

- File List
- File Members

qx_boost_class_export.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_BOOST_SERIALIZATION_EXPORT_HPP_
    00027 #define _QX_BOOST_SERIALIZATION_EXPORT_HPP_
    00028
    00029 #ifdef _MSC_VER
    00030 #pragma once
    00031 #endif
    00032
    00033 #include <QxCommon/QxConfig.h>
    00034
    00035 #if _QX_USE_MODIFY_BOOST_SERIALIZATION_EXPORT_HPP
    00036
    00037 #include <utility>
    00038 #include <cstddef> // NULL
    00039
    00040 #include <boost/config.hpp>
    00041 #include <boost/static_assert.hpp>
    00042 #include <boost/preprocessor/stringize.hpp>
    00043 #include <boost/type_traits/is_polymorphic.hpp>
    00044
    00045 #ifndef BOOST_SERIALIZATION_DEFAULT_TYPE_INFO
    00046     #include <boost/serialization/extended_type_info_typeid.hpp>
    00047 #endif // BOOST_SERIALIZATION_DEFAULT_TYPE_INFO
    00048
    00049 #include <boost/serialization/static_warning.hpp>
    00050 #include <boost/serialization/type_info_implementation.hpp>
    00051 #include <boost/serialization/assume_abstract.hpp>
    00052 #include <boost/serialization/force_include.hpp>
    00053 #include <boost/serialization/singleton.hpp>
    00054
    00055 #include <boost/archive/detail/register_archive.hpp>
    00056 #include <boost/mpl/assert.hpp>
    00057 #include <boost/mpl/and.hpp>
    00058 #include <boost/mpl/not.hpp>
    00059 #include <boost/mpl/bool.hpp>
    00060
    00061 #include <iostream>
    00062
    00063 namespace boost {
    00064 namespace archive {
    00065 namespace detail {
    00066
    00067 class basic_pointer_iserializer;
    00068 class basic_pointer_oserializer;
    00069
    00070 template<class Archive, class T>
    00071 class pointer_iserializer;
    00072 template<class Archive, class T>
    00073 class pointer_oserializer;
    00074
    00075 template <class Archive, class Serializable>
    00076 struct export_impl
    00077 {
    00078     static const basic_pointer_iserializer &
    00079     enable_load(mpl::true_){
    00080         return boost::serialization::singleton<
    00081             pointer_iserializer<Archive, Serializable>
    00082         >::get_const_instance();
    00083     }
    00084
    00085     static const basic_pointer_oserializer &
    00086     enable_save(mpl::true_){
    00087         return boost::serialization::singleton<
    00088             pointer_oserializer<Archive, Serializable>
    00089         >::get_const_instance();
    00090     }
    00091     inline static void enable_load(mpl::false_) {}
    00092     inline static void enable_save(mpl::false_) {}
    00093 };
    00094
    00095 // On many platforms, naming a specialization of this template is
    00096 // enough to cause its argument to be instantiated.
    00097 template <void(*)()>
    00098 struct instantiate_function {};
    00099
    00100 template <class Archive, class Serializable>
    00101 struct ptr_serialization_support
    00102 {
    00103 # if defined(BOOST_MSVC)
    00104     virtual BOOST_DLLEXPORT void instantiate() BOOST_USED;
    00105 # elif defined(__BORLANDC__)
    00106     static BOOST_DLLEXPORT void instantiate() BOOST_USED;
    00107     enum { x = sizeof(instantiate(),3) };
    00108 # else
    00109     static BOOST_DLLEXPORT void instantiate() BOOST_USED;
    00110     typedef instantiate_function<
    00111         &ptr_serialization_support::instantiate
    00112     > x;
    00113 # endif
    00114 };
    00115
    00116 template <class Archive, class Serializable>
    00117 BOOST_DLLEXPORT void
    00118 ptr_serialization_support<Archive,Serializable>::instantiate()
    00119 {
    00120     export_impl<Archive,Serializable>::enable_save(
    00121         #if ! defined(__BORLANDC__)
    00122         BOOST_DEDUCED_TYPENAME
    00123         #endif
    00124         Archive::is_saving()
    00125     );
    00126
    00127     export_impl<Archive,Serializable>::enable_load(
    00128         #if ! defined(__BORLANDC__)
    00129         BOOST_DEDUCED_TYPENAME
    00130         #endif
    00131         Archive::is_loading()
    00132     );
    00133 }
    00134
    00135 template<class T>
    00136 struct guid_initializer
    00137 {
    00138     const guid_initializer & export_guid(char const* /* key */, mpl::false_){
    00139         // generates the statically-initialized objects whose constructors
    00140         // register the information allowing serialization of T objects
    00141         // through pointers to their base classes.
    00142         instantiate_ptr_serialization((T*)0, 0, adl_tag());
    00143         return *this;
    00144     }
    00145     const guid_initializer & export_guid(char const* /*key*/, mpl::true_){
    00146         return *this;
    00147     }
    00148     const guid_initializer & export_guid(char const* key){
    00149         BOOST_STATIC_WARNING(boost::is_polymorphic<T>::value);
    00150         assert(NULL != key);
    00151         boost::serialization::singleton<
    00152             BOOST_DEDUCED_TYPENAME
    00153             boost::serialization::type_info_implementation<T>::type
    00154         >::get_mutable_instance().key_register(key);
    00155         // note: exporting an abstract base class will have no effect
    00156         // and cannot be used to instantitiate serialization code
    00157         // (one might be using this in a DLL to instantiate code)
    00158         //BOOST_STATIC_WARNING(! boost::serialization::is_abstract<T>::value);
    00159         return export_guid(key, boost::serialization::is_abstract<T>());
    00160     }
    00161 };
    00162
    00163 } // namespace detail
    00164 } // namespace archive
    00165 } // namespace boost
    00166
    00167 #define BOOST_CLASS_EXPORT_GUID(T, K)                                               \
    00168 namespace                                                                           \
    00169 {                                                                                   \
    00170     ::boost::archive::detail::guid_initializer< T > const &                         \
    00171         boost_serialization_guid_initializer_##T                                    \
    00172         = ::boost::serialization::singleton<                                        \
    00173             ::boost::archive::detail::guid_initializer< T >                         \
    00174           >::get_mutable_instance().export_guid(K);                                 \
    00175 }
    00176
    00177 // check for unnecessary export.  T isn't polymorphic so there is no
    00178 // need to export it.
    00179 #define BOOST_CLASS_EXPORT_CHECK(T)                              \
    00180     BOOST_STATIC_WARNING(                                        \
    00181         boost::is_polymorphic<U>::value                          \
    00182     );                                                           \
    00183
    00184
    00185 // the default exportable class identifier is the class name
    00186 // the default list of archives types for which code id generated
    00187 // are the originally included with this serialization system
    00188 #define BOOST_CLASS_EXPORT(T)                   \
    00189     BOOST_CLASS_EXPORT_GUID(                    \
    00190         T,                                      \
    00191         BOOST_PP_STRINGIZE(T)                   \
    00192     )                                           \
    00193
    00194
    00195 #endif // _QX_USE_MODIFY_BOOST_SERIALIZATION_EXPORT_HPP
    00196 #endif // _QX_BOOST_SERIALIZATION_EXPORT_HPP_