source: NonGTP/Boost/boost/archive/impl/archive_pointer_oserializer.ipp @ 857

Revision 857, 2.1 KB checked in by igarcia, 18 years ago (diff)
Line 
1/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2// archive_pointer_oserializer.ipp:
3
4// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
5// Use, modification and distribution is subject to the Boost Software
6// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8
9//  See http://www.boost.org for updates, documentation, and revision history.
10
11#include <boost/config.hpp> // msvc 6.0 needs this for warning suppression
12
13#include <boost/archive/detail/archive_pointer_oserializer.hpp>
14#include <boost/archive/detail/basic_serializer_map.hpp>
15
16namespace boost {
17namespace archive {
18namespace detail {
19
20template<class Archive>
21basic_serializer_map *
22oserializer_map(){
23    static bool deleted = false;
24    static basic_serializer_map map(deleted);
25    return deleted ? NULL : & map;
26}
27
28template<class Archive>
29BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
30archive_pointer_oserializer<Archive>::archive_pointer_oserializer(
31    const boost::serialization::extended_type_info & eti
32) :
33    basic_pointer_oserializer(eti)
34{
35    basic_serializer_map *mp = oserializer_map<Archive>();
36    assert(NULL != mp);
37    mp->insert(this);
38}
39
40template<class Archive>
41BOOST_ARCHIVE_OR_WARCHIVE_DECL(const basic_pointer_oserializer *)
42archive_pointer_oserializer<Archive>::find(
43    const boost::serialization::extended_type_info & eti
44){
45    basic_serializer_map *mp = oserializer_map<Archive>();
46    assert(NULL != mp);
47    return static_cast<const basic_pointer_oserializer *>(mp->tfind(eti));
48}
49
50template<class Archive>
51BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
52archive_pointer_oserializer<Archive>::~archive_pointer_oserializer(){
53    // note: we need to check that the map still exists as we can't depend
54    // on static variables being constructed in a specific sequence
55    basic_serializer_map *mp = oserializer_map<Archive>();
56    if(NULL == mp)
57        return;
58    mp->erase(this);
59}
60
61} // namespace detail
62} // namespace archive
63} // namespace boost
Note: See TracBrowser for help on using the repository browser.