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