]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #ifndef BOOST_SERIALIZATION_EPHEMERAL_HPP |
2 | #define BOOST_SERIALIZATION_EPHEMERAL_HPP | |
3 | ||
4 | // MS compatible compilers support | |
7c673cae FG |
5 | #if defined(_MSC_VER) |
6 | # pragma once | |
7 | #endif | |
8 | ||
9 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 | |
10 | // ephemeral_object.hpp: interface for serialization system. | |
11 | ||
12 | // (C) Copyright 2007 Matthias Troyer. | |
13 | // Use, modification and distribution is subject to the Boost Software | |
14 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
15 | // http://www.boost.org/LICENSE_1_0.txt) | |
16 | ||
17 | // See http://www.boost.org for updates, documentation, and revision history. | |
18 | ||
19 | #include <utility> | |
20 | ||
21 | #include <boost/config.hpp> | |
22 | #include <boost/detail/workaround.hpp> | |
23 | ||
24 | #include <boost/mpl/integral_c.hpp> | |
25 | #include <boost/mpl/integral_c_tag.hpp> | |
26 | ||
27 | #include <boost/serialization/level.hpp> | |
28 | #include <boost/serialization/tracking.hpp> | |
29 | #include <boost/serialization/split_member.hpp> | |
30 | #include <boost/serialization/base_object.hpp> | |
31 | #include <boost/serialization/traits.hpp> | |
32 | #include <boost/serialization/wrapper.hpp> | |
33 | ||
34 | namespace boost { | |
35 | namespace serialization { | |
36 | ||
37 | template<class T> | |
38 | struct ephemeral_object : | |
39 | public wrapper_traits<ephemeral_object<T> > | |
40 | { | |
41 | explicit ephemeral_object(T& t) : | |
42 | val(t) | |
43 | {} | |
44 | ||
45 | T & value() const { | |
46 | return val; | |
47 | } | |
48 | ||
49 | const T & const_value() const { | |
50 | return val; | |
51 | } | |
52 | ||
53 | template<class Archive> | |
54 | void serialize(Archive &ar, const unsigned int) const | |
55 | { | |
56 | ar & val; | |
57 | } | |
58 | ||
59 | private: | |
60 | T & val; | |
61 | }; | |
62 | ||
63 | template<class T> | |
64 | inline | |
65 | const ephemeral_object<T> ephemeral(const char * name, T & t){ | |
66 | return ephemeral_object<T>(name, t); | |
67 | } | |
68 | ||
69 | } // seralization | |
70 | } // boost | |
71 | ||
72 | #endif // BOOST_SERIALIZATION_EPHEMERAL_HPP |