SerializationExportWrapper.hpp

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
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 
00070 #include <boost/version.hpp>
00071 
00073 // Make sure includes happen in the correct place.  This has to go before
00074 // the SERIALIZATIONEXPORTWRAPPER_HPP_ guard, since we need it to be seen
00075 // by both .hpp and .cpp files.
00076 
00077 #if BOOST_VERSION < 103600
00078 // Boost 1.34 and older - export goes in headers
00079 #ifndef CHASTE_SERIALIZATION_CPP
00080 #include <boost/serialization/export.hpp>
00081 #endif // CHASTE_SERIALIZATION_CPP
00082 
00083 #elif BOOST_VERSION < 104100
00084 // Boost 1.36-1.40 - export goes in .cpp, along with archive includes
00085 #ifdef CHASTE_SERIALIZATION_CPP
00086 #include "CheckpointArchiveTypes.hpp"
00087 #include <boost/serialization/export.hpp>
00088 #endif // CHASTE_SERIALIZATION_CPP
00089 
00090 #else
00091 // Boost 1.41 and newer - export goes in both, with archive includes in .cpp
00092 #include <boost/serialization/extended_type_info.hpp> // We get compile errors without this...
00093 #include <boost/serialization/export.hpp>
00094 #ifdef CHASTE_SERIALIZATION_CPP
00095 #include "CheckpointArchiveTypes.hpp"
00096 #endif // CHASTE_SERIALIZATION_CPP
00097 
00098 #endif
00099 // Done includes
00100 
00102 #if BOOST_VERSION >= 104100 && defined(CHASTE_SERIALIZATION_CPP)
00103 // .cpp file needs to use BOOST_CLASS_EXPORT_IMPLEMENT, so we need
00104 // to redefine the macros from the .hpp file.  Hence this can't go
00105 // in the include guard.
00106 
00107 #undef CHASTE_CLASS_EXPORT_TEMPLATED
00108 
00113 #define CHASTE_CLASS_EXPORT_TEMPLATED(T, S)    \
00114    BOOST_CLASS_EXPORT_IMPLEMENT(T)
00115 
00116 #undef CHASTE_CLASS_EXPORT_INTERNAL
00117 
00121 #define CHASTE_CLASS_EXPORT_INTERNAL(T)        \
00122    BOOST_CLASS_EXPORT_IMPLEMENT(T)
00123 
00124 #endif // BOOST_VERSION >= 104100 && defined(CHASTE_SERIALIZATION_CPP)
00125 
00127 
00128 #ifndef SERIALIZATIONEXPORTWRAPPER_HPP_
00129 #define SERIALIZATIONEXPORTWRAPPER_HPP_
00130 // Code in the next block is only compiled when the .hpp is first seen
00131 
00133 
00134 #include <boost/preprocessor/cat.hpp>
00135 #include <boost/preprocessor/stringize.hpp>
00136 
00137 // Handle broken BOOST_CLASS_EXPORT in Boost 1.36 & 1.37
00138 #if BOOST_VERSION >= 103600 && BOOST_VERSION < 103800
00139 
00147 #define CHASTE_CLASS_EXPORT_GUID(T, K, S)                                           \
00148 namespace                                                                           \
00149 {                                                                                   \
00150     ::boost::archive::detail::guid_initializer< T > const &                         \
00151         BOOST_PP_CAT(BOOST_PP_CAT(boost_serialization_guid_initializer_, __LINE__), S)               \
00152         = ::boost::serialization::singleton<                                        \
00153             ::boost::archive::detail::guid_initializer< T >                         \
00154           >::get_mutable_instance().export_guid(K);                                 \
00155 }
00156 
00162 #define CHASTE_CLASS_EXPORT_TEMPLATED(T, S)    \
00163     CHASTE_CLASS_EXPORT_GUID(                  \
00164         T,                                     \
00165         BOOST_PP_STRINGIZE(T), S               \
00166     )                                          \
00167 
00168 
00172 #define CHASTE_CLASS_EXPORT_INTERNAL(T)        \
00173    CHASTE_CLASS_EXPORT_TEMPLATED(T, T)
00174 
00175 
00176 // The interface changes yet again in Boost 1.41, and we need something in both .hpp and .cpp...
00177 #elif BOOST_VERSION >= 104100
00178 // .hpp file needs to use BOOST_CLASS_EXPORT_KEY
00179 
00185 #define CHASTE_CLASS_EXPORT_TEMPLATED(T, S)   \
00186    BOOST_CLASS_EXPORT_KEY(T)
00187 
00192 #define CHASTE_CLASS_EXPORT_INTERNAL(T)       \
00193    BOOST_CLASS_EXPORT_KEY(T)
00194 
00195 #else // BOOST_VERSION < 103600 || (BOOST_VERSION >= 103800 && BOOST_VERSION < 104100)
00196 //Do exactly as we did before (so that archives created with 1.33 don't have to be re-generated)
00197 
00203 #define CHASTE_CLASS_EXPORT_TEMPLATED(T, S)    \
00204    BOOST_CLASS_EXPORT(T)
00205 
00210 #define CHASTE_CLASS_EXPORT_INTERNAL(T)        \
00211    BOOST_CLASS_EXPORT(T)
00212 
00213 #endif // BOOST_VERSION >= 103600 && BOOST_VERSION < 103800
00214 
00215 template<class> struct pack;
00222 template<class T> struct pack<void (T)> {
00223     typedef T type; 
00224 };
00225 
00231 #define CHASTE_EXPORT_KEY_1(CLASS, P1) \
00232     BOOST_PP_CAT(CLASS, P1)
00233 
00240 #define CHASTE_EXPORT_KEY_2(CLASS, P1, P2) \
00241     BOOST_PP_CAT(BOOST_PP_CAT(CLASS, P1), P2)
00242 
00250 #define CHASTE_EXPORT_KEY_3(CLASS, P1, P2, P3) \
00251     BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(CLASS, P1), P2), P3)
00252 
00258 #define CHASTE_PACK_1(CLASS, P1) pack<void (CLASS< P1 >)>::type
00259 
00266 #define CHASTE_PACK_2(CLASS, P1, P2) pack<void (CLASS< P1,P2 >)>::type
00267 
00275 #define CHASTE_PACK_3(CLASS, P1, P2, P3) pack<void (CLASS< P1,P2,P3 >)>::type
00276 
00277 // End of include guard - code below here is executed in both .hpp and .cpp
00278 #endif // SERIALIZATIONEXPORTWRAPPER_HPP_
00279 
00280 
00281 // Since CHASTE_CLASS_EXPORT_TEMPLATED and CHASTE_CLASS_EXPORT_INTERNAL are re-defined for the .cpp file
00282 // in some Boost versions, the following macros will also need re-defining.
00283 
00284 #ifdef EXPORT_TEMPLATE_CLASS3_INTERNAL
00285 // Avoid re-definition when called from a .cpp file
00286 #undef EXPORT_TEMPLATE_CLASS3_INTERNAL
00287 #undef EXPORT_TEMPLATE_CLASS2_INTERNAL
00288 #undef EXPORT_TEMPLATE_CLASS1_INTERNAL
00289 #undef EXPORT_TEMPLATE_CLASS_ALL_DIMS_INTERNAL
00290 #undef EXPORT_TEMPLATE_CLASS_SAME_DIMS_INTERNAL
00291 #endif // EXPORT_TEMPLATE_CLASS3_INTERNAL
00292 
00293 // Macros for templated classes
00294 
00303 #define EXPORT_TEMPLATE_CLASS3_INTERNAL(CLASS, E, S, P) \
00304     CHASTE_CLASS_EXPORT_TEMPLATED( CHASTE_PACK_3(CLASS, E, S, P), CHASTE_EXPORT_KEY_3(CLASS, E, S, P) )
00305 
00313 #define EXPORT_TEMPLATE_CLASS2_INTERNAL(CLASS, E, S) \
00314     CHASTE_CLASS_EXPORT_TEMPLATED( CHASTE_PACK_2(CLASS, E, S), CHASTE_EXPORT_KEY_2(CLASS, E, S) )
00315 
00322 #define EXPORT_TEMPLATE_CLASS1_INTERNAL(CLASS, D) \
00323     CHASTE_CLASS_EXPORT_TEMPLATED( CHASTE_PACK_1(CLASS, D), CHASTE_EXPORT_KEY_1(CLASS, D) )
00324 
00331 #define EXPORT_TEMPLATE_CLASS_ALL_DIMS_INTERNAL(CLASS) \
00332     EXPORT_TEMPLATE_CLASS2(CLASS, 1, 1) \
00333     EXPORT_TEMPLATE_CLASS2(CLASS, 1, 2) \
00334     EXPORT_TEMPLATE_CLASS2(CLASS, 1, 3) \
00335     EXPORT_TEMPLATE_CLASS2(CLASS, 2, 2) \
00336     EXPORT_TEMPLATE_CLASS2(CLASS, 2, 3) \
00337     EXPORT_TEMPLATE_CLASS2(CLASS, 3, 3)
00338 
00345 #define EXPORT_TEMPLATE_CLASS_SAME_DIMS_INTERNAL(CLASS) \
00346     EXPORT_TEMPLATE_CLASS1(CLASS, 1) \
00347     EXPORT_TEMPLATE_CLASS1(CLASS, 2) \
00348     EXPORT_TEMPLATE_CLASS1(CLASS, 3)
00349 
00350 // Now define the macros that users actually call.
00351 // Again this goes outside the include guard, so it is seen by both .hpp and .cpp files.
00352 
00353 // However, we don't want to define things twice, so...
00354 #if !defined(CHASTE_CLASS_EXPORT) || defined(CHASTE_SERIALIZATION_CPP)
00355 #ifdef CHASTE_SERIALIZATION_CPP
00356 // Remove the definitions from when we were included via an .hpp file
00357 #undef CHASTE_CLASS_EXPORT
00358 #undef EXPORT_TEMPLATE_CLASS_SAME_DIMS
00359 #undef EXPORT_TEMPLATE_CLASS_ALL_DIMS
00360 #undef EXPORT_TEMPLATE_CLASS1
00361 #undef EXPORT_TEMPLATE_CLASS2
00362 #undef EXPORT_TEMPLATE_CLASS3
00363 #endif // CHASTE_SERIALIZATION_CPP
00364 
00365 #if (BOOST_VERSION < 103600  && ! defined(CHASTE_SERIALIZATION_CPP)) || \
00366     (BOOST_VERSION >= 103600 && defined(CHASTE_SERIALIZATION_CPP)) || \
00367     (BOOST_VERSION >= 104100)
00368 // Boost 1.34 and older - export goes in headers
00369 // Boost 1.36 and newer - export goes in .cpp
00370 // Boost 1.41 and newer - key goes in .hpp, implement goes in .cpp
00371 
00376 #define CHASTE_CLASS_EXPORT(T)                 CHASTE_CLASS_EXPORT_INTERNAL(T)
00377 
00382 #define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS) EXPORT_TEMPLATE_CLASS_SAME_DIMS_INTERNAL(CLASS)
00383 
00388 #define EXPORT_TEMPLATE_CLASS_ALL_DIMS(CLASS)  EXPORT_TEMPLATE_CLASS_ALL_DIMS_INTERNAL(CLASS)
00389 
00394 #define EXPORT_TEMPLATE_CLASS1(CLASS, D)       EXPORT_TEMPLATE_CLASS1_INTERNAL(CLASS, D)
00395 
00401 #define EXPORT_TEMPLATE_CLASS2(CLASS, E, S)    EXPORT_TEMPLATE_CLASS2_INTERNAL(CLASS, E, S)
00402 
00409 #define EXPORT_TEMPLATE_CLASS3(CLASS, E, S, P) EXPORT_TEMPLATE_CLASS3_INTERNAL(CLASS, E, S, P)
00410 
00411 #else
00412 
00417 #define CHASTE_CLASS_EXPORT(T)
00418 
00422 #define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
00423 
00427 #define EXPORT_TEMPLATE_CLASS_ALL_DIMS(CLASS)
00428 
00433 #define EXPORT_TEMPLATE_CLASS1(CLASS, D)
00434 
00440 #define EXPORT_TEMPLATE_CLASS2(CLASS, E, S)
00441 
00448 #define EXPORT_TEMPLATE_CLASS3(CLASS, E, S, P)
00449 
00450 #endif // Long if!
00451 #endif // !defined(CHASTE_CLASS_EXPORT) || defined(CHASTE_SERIALIZATION_CPP)
00452 
00453 #undef COVERAGE_IGNORE
Generated on Thu Dec 22 13:00:05 2011 for Chaste by  doxygen 1.6.3