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

Revision 857, 2.1 KB checked in by igarcia, 19 years ago (diff)
Line 
1/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2// pointer_iserializer.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 <cassert>
12
13#include <boost/config.hpp> // msvc 6.0 needs this for warning suppression
14
15#include <boost/archive/detail/basic_serializer_map.hpp>
16#include <boost/archive/detail/archive_pointer_iserializer.hpp>
17
18namespace boost {
19namespace archive {
20namespace detail {
21
22template<class Archive>
23basic_serializer_map *
24iserializer_map(){
25    static bool deleted = false;
26    static basic_serializer_map map(deleted);
27    return deleted ? NULL : & map;
28}
29
30template<class Archive>
31BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
32archive_pointer_iserializer<Archive>::archive_pointer_iserializer(
33    const boost::serialization::extended_type_info & eti
34) :
35    basic_pointer_iserializer(eti)
36{
37    basic_serializer_map *mp = iserializer_map<Archive>();
38    assert(NULL != mp);
39    mp->insert(this);
40}
41
42template<class Archive>
43BOOST_ARCHIVE_OR_WARCHIVE_DECL(const basic_pointer_iserializer *)
44archive_pointer_iserializer<Archive>::find(
45    const boost::serialization::extended_type_info & eti
46){
47    basic_serializer_map *mp = iserializer_map<Archive>();
48    assert(NULL != mp);
49    return static_cast<const basic_pointer_iserializer *>(mp->tfind(eti));
50}
51
52template<class Archive>
53BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
54archive_pointer_iserializer<Archive>::~archive_pointer_iserializer(){
55    // note: we need to check that the map still exists as we can't depend
56    // on static variables being constructed in a specific sequence
57    basic_serializer_map *mp = iserializer_map<Archive>();
58    if(NULL == mp)
59        return;
60    mp->erase(this);
61}
62
63} // namespace detail
64} // namespace archive
65} // namespace boost
Note: See TracBrowser for help on using the repository browser.