mem_serialized_struct.hpp
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2010, LABUST, UNIZG-FER
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the LABUST nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 /*********************************************************************
00035  * Author: Đula Nađ
00036  *   Date: 20.10.2010.
00037  *********************************************************************/
00038 #ifndef MEM_SERIALIZED_STRUCT_HPP_
00039 #define MEM_SERIALIZED_STRUCT_HPP_
00040 #include <labust/preprocessor/class_adaptor.hpp>
00041 #include <boost/serialization/level.hpp>
00042 #include <boost/preprocessor/seq/for_each.hpp>
00043 
00044 #define PP_LABUST_ADD_TO_BOOST_ARCHIVE(R, ATTRIBUTE_TUPEL_SIZE, ATTRIBUTE) \
00045         ar &  object.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPEL_SIZE,1,ATTRIBUTE);
00046 
00047 #define PP_LABUST_MAKE_INLINE_BOOST_SERIALIZATOR(NAME, ATTRIBUTES) \
00048         namespace boost { namespace serialization{\\
00049         template<class Archive>\
00050   inline void serialize(Archive & ar, NAME & g, const unsigned int version) \
00051   {\
00052     BOOST_PP_SEQ_FOR_EACH_R(1, PP_LABUST_ADD_TO_BOOST_ARCHIVE, object, STRUCT_SEQ)\
00053   }}}\
00054 
00055 #define PP_LABUST_MAKE_BOOST_SERIALIZATOR(NAME, ATTRIBUTES) \
00056         namespace boost { \
00057   namespace serialization { \
00058         template<class Archive>\
00059   void serialize(Archive & ar, NAME & object, const unsigned int version) \
00060   {\
00061                 PP_LABUST_MACRO_ON_ATTRIBUTES(PP_LABUST_ADD_TO_BOOST_ARCHIVE,ATTRIBUTES)\
00062   }}}
00063 
00064 #define PP_LABUST_MAKE_INLINE_BOOST_SERIALIZATOR_CLEAN(NAME, ATTRIBUTES) \
00065         PP_LABUST_MAKE_INLINE_BOOST_SERIALIZATOR(NAME, ATTRIBUTES) \
00066         BOOST_CLASS_IMPLEMENTATION(NAME, boost::serialization::object_serializable)
00067 
00068 #define PP_LABUST_MAKE_BOOST_SERIALIZATOR_CLEAN(NAME, ATTRIBUTES) \
00069         PP_LABUST_MAKE_BOOST_SERIALIZATOR(NAME, ATTRIBUTES) \
00070         BOOST_CLASS_IMPLEMENTATION(NAME, boost::serialization::object_serializable)
00071 
00072 #define PP_LABUST_DEFINE_BOOST_SERIALIZED_STRUCT(NAMESPACE_SEQ, NAME, ATTRIBUTES)\
00073                 PP_LABUST_NAMESPACE_DEFINITIONS_BEGIN((0)NAMESPACE_SEQ)\
00074                 struct NAME\
00075                 {\
00076                         PP_LABUST_MACRO_ON_ATTRIBUTES(PP_LABUST_ATTRIBUTE_EXPAND,ATTRIBUTES)\
00077                 };\
00078                 PP_LABUST_NAMESPACE_DEFINITIONS_END((0)NAMESPACE_SEQ)\
00079                 PP_LABUST_MAKE_BOOST_SERIALIZATOR(PP_LABUST_NAMESPACE_DEFINITIONS_ENUM((0)NAMESPACE_SEQ)NAME,ATTRIBUTES)
00080 
00081 #define PP_LABUST_DEFINE_BOOST_SERIALIZED_STRUCT_CLEAN(NAMESPACE_SEQ, NAME, ATTRIBUTES)\
00082         PP_LABUST_DEFINE_BOOST_SERIALIZED_STRUCT(NAMESPACE_SEQ, NAME, ATTRIBUTES)\
00083         BOOST_CLASS_IMPLEMENTATION(PP_LABUST_NAMESPACE_DEFINITIONS_ENUM((0)NAMESPACE_SEQ)NAME, boost::serialization::object_serializable)
00084 
00085 
00086 /* MEM_SERIALIZED_STRUCT_HPP_ */
00087 #endif


snippets
Author(s): Gyula Nagy
autogenerated on Fri Aug 28 2015 11:22:33