Equalizer
1.2.1
|
00001 00002 /* Copyright (c) 2012, Daniel Nachbaur <danielnachbaur@googlemail.com> 00003 * 2012, Stefan Eilemann <eile@eyescale.ch> 00004 * 00005 * This library is free software; you can redistribute it and/or modify it under 00006 * the terms of the GNU Lesser General Public License version 2.1 as published 00007 * by the Free Software Foundation. 00008 * 00009 * This library is distributed in the hope that it will be useful, but WITHOUT 00010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00011 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00012 * details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public License 00015 * along with this library; if not, write to the Free Software Foundation, Inc., 00016 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00017 */ 00018 00019 #ifndef CO_DATAOSTREAMARCHIVE_H 00020 #define CO_DATAOSTREAMARCHIVE_H 00021 00022 #include <co/defines.h> 00023 #ifdef CO_USE_BOOST_SERIALIZATION 00024 00025 #include <co/api.h> 00026 #include <co/dataOStream.h> 00027 00028 #include <boost/archive/basic_binary_oarchive.hpp> 00029 #include <boost/archive/detail/register_archive.hpp> 00030 00031 namespace co 00032 { 00034 class DataOStreamArchive 00035 : public boost::archive::basic_binary_oarchive< DataOStreamArchive > 00036 { 00037 typedef boost::archive::basic_binary_oarchive<DataOStreamArchive> Super; 00038 00039 public: 00041 CO_API DataOStreamArchive( DataOStream& stream ); 00042 00044 CO_API void save_binary( void* data, std::size_t size ); 00045 00046 private: 00047 friend class boost::archive::save_access; 00048 00049 template<class T> 00050 void save( T& t ) 00051 { 00052 _stream << t; 00053 } 00054 00055 DataOStream& _stream; 00056 }; 00057 } 00058 00059 BOOST_SERIALIZATION_REGISTER_ARCHIVE(co::DataOStreamArchive) 00060 00061 #endif //CO_USE_BOOST_SERIALIZATION 00062 #endif //CO_DATAOSTREAMARCHIVE_H