SerializationExportWrapper.hpp

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2010
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 
00030 #define COVERAGE_IGNORE
00031 
00032 
00060 #include <boost/version.hpp>
00061 #include <new> // Apparently 'new' (for boost's two phase construction) isn't included sometimes...
00062 
00063 // Make sure includes happen in the correct place.  This has to go before
00064 // the SERIALIZATIONEXPORTWRAPPER_HPP_ guard, since we need it to be seen
00065 // by both .hpp and .cpp files.
00066 #if BOOST_VERSION < 103600
00067 // Boost 1.34 and older - export goes in headers
00068 #ifndef CHASTE_SERIALIZATION_CPP
00069 #include <boost/serialization/export.hpp>
00070 #endif // CHASTE_SERIALIZATION_CPP
00071 
00072 #else
00073 // Boost 1.36 and newer - export goes in .cpp, along with archive includes
00074 #ifdef CHASTE_SERIALIZATION_CPP
00075 #include "CheckpointArchiveTypes.hpp"
00076 #include <boost/serialization/export.hpp>
00077 #endif // CHASTE_SERIALIZATION_CPP
00078 
00079 #endif
00080 // Done includes
00081 
00082 
00083 #ifndef SERIALIZATIONEXPORTWRAPPER_HPP_
00084 #define SERIALIZATIONEXPORTWRAPPER_HPP_
00085 
00086 
00087 // Deal with buggy versions
00088 #if (BOOST_VERSION == 103500)
00089 #error "Chaste won't work with Boost 1-35 due to a bug in its serialization library"
00090 /* There's a bug in 1-35 which involves a
00091  * #include <boost/serialization/extended_type_info_typeid.hpp>
00092  * missing at the end of <boost/serialization/export.hpp>
00093  * It's probably not worth fixing.
00094  */
00095 #endif
00096 
00097 // We don't yet support >= 1.41
00098 #if BOOST_VERSION >= 104100
00099 #error "Chaste doesn't yet support Boost versions >= 1.41"
00100 #endif
00101 
00102 
00103 
00104 // Handle broken BOOST_CLASS_EXPORT in Boost 1.36 & 1.37
00105 #if BOOST_VERSION >= 103600 && BOOST_VERSION < 103800
00106 
00114 #define CHASTE_CLASS_EXPORT_GUID(T, K, S)                                           \
00115 namespace                                                                           \
00116 {                                                                                   \
00117     ::boost::archive::detail::guid_initializer< T > const &                         \
00118         BOOST_PP_CAT(BOOST_PP_CAT(boost_serialization_guid_initializer_, __LINE__), S)               \
00119         = ::boost::serialization::singleton<                                        \
00120             ::boost::archive::detail::guid_initializer< T >                         \
00121           >::get_mutable_instance().export_guid(K);                                 \
00122 }
00123 
00129 #define CHASTE_CLASS_EXPORT_TEMPLATED(T, S)                   \
00130     CHASTE_CLASS_EXPORT_GUID(                    \
00131         T,                                      \
00132         BOOST_PP_STRINGIZE(T), S                   \
00133     )                                           \
00134 
00135 
00139 #define CHASTE_CLASS_EXPORT_INTERNAL(T)                   \
00140    CHASTE_CLASS_EXPORT_TEMPLATED(T, T)
00141 
00142 #else // BOOST_VERSION >= 103600 && BOOST_VERSION < 103800
00143 
00144 //Do exactly as we did before (so that archives created with 1.33 don't have to be re-generated)
00150 #define CHASTE_CLASS_EXPORT_TEMPLATED(T, S)                   \
00151    BOOST_CLASS_EXPORT(T)
00152 
00157 #define CHASTE_CLASS_EXPORT_INTERNAL(T)                   \
00158    BOOST_CLASS_EXPORT(T)
00159 #endif // BOOST_VERSION >= 103600 && BOOST_VERSION < 103800
00160 
00161 
00162 
00163 template<class> struct pack;
00167 template<class T> struct pack<void (T)> {
00168     typedef T type; 
00169 };
00170 
00171 
00172 
00173 // Macros for templated classes
00174 
00183 #define EXPORT_TEMPLATE_CLASS3_INTERNAL(CLASS, E, S, P) \
00184     CHASTE_CLASS_EXPORT_TEMPLATED( pack<void (CLASS< E,S,P >)>::type, CLASS##E##S##P );
00185 
00193 #define EXPORT_TEMPLATE_CLASS2_INTERNAL(CLASS, E, S) \
00194     CHASTE_CLASS_EXPORT_TEMPLATED( pack<void (CLASS< E,S >)>::type, CLASS##E##S );
00195 
00202 #define EXPORT_TEMPLATE_CLASS1_INTERNAL(CLASS, D) \
00203     CHASTE_CLASS_EXPORT_TEMPLATED( pack<void (CLASS< D >)>::type, CLASS##D );
00204 
00211 #define EXPORT_TEMPLATE_CLASS_ALL_DIMS_INTERNAL(CLASS) \
00212     EXPORT_TEMPLATE_CLASS2(CLASS, 1, 1) \
00213     EXPORT_TEMPLATE_CLASS2(CLASS, 1, 2) \
00214     EXPORT_TEMPLATE_CLASS2(CLASS, 1, 3) \
00215     EXPORT_TEMPLATE_CLASS2(CLASS, 2, 2) \
00216     EXPORT_TEMPLATE_CLASS2(CLASS, 2, 3) \
00217     EXPORT_TEMPLATE_CLASS2(CLASS, 3, 3)
00218 
00225 #define EXPORT_TEMPLATE_CLASS_SAME_DIMS_INTERNAL(CLASS) \
00226     EXPORT_TEMPLATE_CLASS1(CLASS, 1) \
00227     EXPORT_TEMPLATE_CLASS1(CLASS, 2) \
00228     EXPORT_TEMPLATE_CLASS1(CLASS, 3)
00229 
00230 
00231 #endif // SERIALIZATIONEXPORTWRAPPER_HPP_
00232 
00233 // Now the magic for different Boost versions.
00234 // Again this goes outside the include guard, so it is seen by both .hpp and .cpp files.
00235 
00236 // However, we don't want to define things twice, so...
00237 #if !defined(CHASTE_CLASS_EXPORT) || defined(CHASTE_SERIALIZATION_CPP)
00238 #ifdef CHASTE_SERIALIZATION_CPP
00239 // Remove the definitions from when we were included via an .hpp file
00240 #undef CHASTE_CLASS_EXPORT
00241 #undef EXPORT_TEMPLATE_CLASS_SAME_DIMS
00242 #undef EXPORT_TEMPLATE_CLASS_ALL_DIMS
00243 #undef EXPORT_TEMPLATE_CLASS1
00244 #undef EXPORT_TEMPLATE_CLASS2
00245 #undef EXPORT_TEMPLATE_CLASS3
00246 #endif // CHASTE_SERIALIZATION_CPP
00247 
00248 
00249 #if (BOOST_VERSION < 103600  && ! defined(CHASTE_SERIALIZATION_CPP)) || \
00250     (BOOST_VERSION >= 103600 && defined(CHASTE_SERIALIZATION_CPP))
00251 // Boost 1.34 and older - export goes in headers
00252 // Boost 1.36 and newer - export goes in .cpp
00253 
00258 #define CHASTE_CLASS_EXPORT(T)                 CHASTE_CLASS_EXPORT_INTERNAL(T)
00259 
00264 #define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS) EXPORT_TEMPLATE_CLASS_SAME_DIMS_INTERNAL(CLASS)
00265 
00270 #define EXPORT_TEMPLATE_CLASS_ALL_DIMS(CLASS)  EXPORT_TEMPLATE_CLASS_ALL_DIMS_INTERNAL(CLASS)
00271 
00276 #define EXPORT_TEMPLATE_CLASS1(CLASS, D)       EXPORT_TEMPLATE_CLASS1_INTERNAL(CLASS, D)
00277 
00283 #define EXPORT_TEMPLATE_CLASS2(CLASS, E, S)    EXPORT_TEMPLATE_CLASS2_INTERNAL(CLASS, E, S)
00284 
00291 #define EXPORT_TEMPLATE_CLASS3(CLASS, E, S, P) EXPORT_TEMPLATE_CLASS3_INTERNAL(CLASS, E, S, P)
00292 
00293 #else
00294 
00299 #define CHASTE_CLASS_EXPORT(T)
00300 
00304 #define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
00305 
00309 #define EXPORT_TEMPLATE_CLASS_ALL_DIMS(CLASS)
00310 
00315 #define EXPORT_TEMPLATE_CLASS1(CLASS, D)
00316 
00322 #define EXPORT_TEMPLATE_CLASS2(CLASS, E, S)
00323 
00330 #define EXPORT_TEMPLATE_CLASS3(CLASS, E, S, P)
00331 
00332 #endif
00333 #endif
00334 
00335 
00336 
00337 #undef COVERAGE_IGNORE

Generated by  doxygen 1.6.2