Changeset 54798


Ignore:
Timestamp:
Jul 8, 2009, 4:30:38 PM (9 years ago)
Author:
Robert Ramey
Message:

fixed archive_pointer_?serializer

Location:
trunk/boost/archive
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/boost/archive/detail/archive_pointer_iserializer.hpp

    r51980 r54798  
    2424#include <boost/archive/detail/basic_serializer.hpp>
    2525#include <boost/archive/detail/basic_pointer_iserializer.hpp>
    26 
     26#include <boost/archive/detail/basic_serializer_map.hpp>
    2727#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
    2828
     
    4141class archive_pointer_iserializer :
    4242    public basic_pointer_iserializer {
     43    static basic_serializer_map m_map;
    4344protected:
    4445    explicit BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
  • trunk/boost/archive/detail/archive_pointer_oserializer.hpp

    r43694 r54798  
    2121#include <boost/archive/detail/basic_serializer.hpp>
    2222#include <boost/archive/detail/basic_pointer_oserializer.hpp>
     23#include <boost/archive/detail/basic_serializer_map.hpp>
    2324
    2425#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
     
    3637class archive_pointer_oserializer :
    3738    public basic_pointer_oserializer {
     39    static basic_serializer_map m_map;
    3840protected:
    3941    explicit BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
  • trunk/boost/archive/detail/iserializer.hpp

    r52713 r54798  
    119119        boost::serialization::access::destroy(static_cast<T *>(address));
    120120    }
    121     // private constructor to inhibit any existence other than the
    122     // static one
    123 public:
     121protected:
     122    // protected constructor since it's always created by singleton
    124123    explicit iserializer() :
    125124        basic_iserializer(
     
    128127        )
    129128    {}
     129public:
    130130    virtual BOOST_DLLEXPORT void load_object_data(
    131131        basic_iarchive & ar,
     
    189189        const unsigned int file_version
    190190    ) const BOOST_USED;
    191 public:
     191protected:
     192    // this should alway be a singleton so make the constructor protected
    192193    pointer_iserializer();
    193194};
  • trunk/boost/archive/impl/archive_pointer_iserializer.ipp

    r54783 r54798  
    2727namespace detail {
    2828
    29 namespace { // anon
    30     template<class Archive>
    31     class iserializer_map : public basic_serializer_map
    32     {
    33     };
    34 }
     29template<class Archive>
     30basic_serializer_map archive_pointer_iserializer<Archive>::m_map;
    3531
    3632template<class Archive>
     
    4339    // only insert the first one.  Assumes that DLLS are unloaded in
    4440    // the reverse sequence
    45     //std::pair<BOOST_DEDUCED_TYPENAME  iserializer_map<Archive>::iterator, bool> result;
    46     iserializer_map<Archive> & map
    47         = serialization::singleton<iserializer_map<Archive> >::get_mutable_instance();
    48     iserializer_map<Archive>::iterator result = map.find(this);
    49     if(result == map.end())
    50         map.insert(this);
     41    // std::pair<
     42    //    BOOST_DEDUCED_TYPENAME basic_serializer_map<Archive>::iterator,
     43    //    bool
     44    // > result =
     45    m_map.insert(this);
    5146}
    5247
     
    5752){
    5853    const basic_serializer_arg bs(eti);
    59     BOOST_DEDUCED_TYPENAME iserializer_map<Archive>::const_iterator it;
    60     it = boost::serialization::singleton<
    61             iserializer_map<Archive>
    62          >::get_const_instance().find(& bs);
    63     assert(
    64         it
    65         !=
    66         boost::serialization::singleton<
    67                 iserializer_map<Archive>
    68             >::get_const_instance().end()
    69     );
     54    basic_serializer_map::const_iterator it;
     55    it = m_map.find(& bs);
     56    assert(it != m_map.end());
    7057    return static_cast<const basic_pointer_iserializer *>(*it);
    7158}
     
    7461BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
    7562archive_pointer_iserializer<Archive>::~archive_pointer_iserializer(){
    76     // note: we need to check that the map still exists as we can't depend
    77     // on static variables being constructed in a specific sequence
    78     if(serialization::singleton<
    79             iserializer_map<Archive>
    80         >::is_destroyed()
    81     )
    82         return;
    83        
    84     iserializer_map<Archive> & map
    85         = serialization::singleton<iserializer_map<Archive> >::get_mutable_instance();
    86     iserializer_map<Archive>::iterator result = map.find(this);
    87     if(result == map.end())
    88         map.erase(this);
     63    basic_serializer_map::iterator it;
     64    it = m_map.find(this);
     65    assert(it != m_map.end());
     66    if(*it == static_cast<const basic_serializer *>(this))
     67        m_map.erase(it);
    8968}
    9069
  • trunk/boost/archive/impl/archive_pointer_oserializer.ipp

    r54783 r54798  
    2222namespace detail {
    2323
    24 namespace { // anon
    25     template<class Archive>
    26     class oserializer_map : public basic_serializer_map
    27     {
    28     };
    29 }
     24template<class Archive>
     25basic_serializer_map archive_pointer_oserializer<Archive>::m_map;
    3026
    3127template<class Archive>
     
    3834    // only insert the first one.  Assumes that DLLS are unloaded in
    3935    // the reverse sequence
    40     //std::pair<BOOST_DEDUCED_TYPENAME  oserializer_map<Archive>::iterator, bool> result;
    41     oserializer_map<Archive> & map
    42         = serialization::singleton<oserializer_map<Archive> >::get_mutable_instance();
    43     oserializer_map<Archive>::iterator result = map.find(this);
    44     if(result == map.end())
    45         map.insert(this);
     36    //std::pair<
     37    //    BOOST_DEDUCED_TYPENAME  oserializer_map<Archive>::iterator,
     38    //    bool
     39    // > result =
     40    m_map.insert(this);
    4641}
    4742
     
    5348    const basic_serializer_arg bs(eti);
    5449    basic_serializer_map::const_iterator it;
    55     it =  boost::serialization::singleton<
    56             oserializer_map<Archive>
    57         >::get_const_instance().find(& bs);
    58     assert(
    59         it
    60         !=
    61         boost::serialization::singleton<
    62                 oserializer_map<Archive>
    63             >::get_const_instance().end()
    64     );
     50    it =  m_map.find(& bs);
     51    assert(it != m_map.end());
    6552    return static_cast<const basic_pointer_oserializer *>(*it);
    6653}
     
    6956BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
    7057archive_pointer_oserializer<Archive>::~archive_pointer_oserializer(){
    71     // note: we need to check that the map still exists as we can't depend
    72     // on static variables being constructed in a specific sequence
    73     if(serialization::singleton<
    74             oserializer_map<Archive>
    75         >::is_destroyed()
    76     )
    77         return;
    78        
    79     oserializer_map<Archive> & map
    80         = serialization::singleton<oserializer_map<Archive> >::get_mutable_instance();
    81     oserializer_map<Archive>::iterator result = map.find(this);
    82     if(result == map.end())
    83         map.erase(this);
     58    basic_serializer_map::iterator it;
     59    it = m_map.find(this);
     60    assert(it != m_map.end());
     61    if(*it == static_cast<const basic_serializer *>(this))
     62        m_map.erase(it);
    8463}
    8564
Note: See TracChangeset for help on using the changeset viewer.