|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r54798 - in trunk/boost/archive: detail impl
From: ramey_at_[hidden]
Date: 2009-07-08 12:30:39
Author: ramey
Date: 2009-07-08 12:30:38 EDT (Wed, 08 Jul 2009)
New Revision: 54798
URL: http://svn.boost.org/trac/boost/changeset/54798
Log:
fixed archive_pointer_?serializer
Text files modified:
trunk/boost/archive/detail/archive_pointer_iserializer.hpp | 3 +
trunk/boost/archive/detail/archive_pointer_oserializer.hpp | 2 +
trunk/boost/archive/detail/iserializer.hpp | 9 +++---
trunk/boost/archive/impl/archive_pointer_iserializer.ipp | 51 +++++++++++----------------------------
trunk/boost/archive/impl/archive_pointer_oserializer.ipp | 49 ++++++++++---------------------------
5 files changed, 38 insertions(+), 76 deletions(-)
Modified: trunk/boost/archive/detail/archive_pointer_iserializer.hpp
==============================================================================
--- trunk/boost/archive/detail/archive_pointer_iserializer.hpp (original)
+++ trunk/boost/archive/detail/archive_pointer_iserializer.hpp 2009-07-08 12:30:38 EDT (Wed, 08 Jul 2009)
@@ -23,7 +23,7 @@
#include <boost/archive/detail/basic_serializer.hpp>
#include <boost/archive/detail/basic_pointer_iserializer.hpp>
-
+#include <boost/archive/detail/basic_serializer_map.hpp>
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
namespace boost {
@@ -40,6 +40,7 @@
template<class Archive>
class archive_pointer_iserializer :
public basic_pointer_iserializer {
+ static basic_serializer_map m_map;
protected:
explicit BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
archive_pointer_iserializer(
Modified: trunk/boost/archive/detail/archive_pointer_oserializer.hpp
==============================================================================
--- trunk/boost/archive/detail/archive_pointer_oserializer.hpp (original)
+++ trunk/boost/archive/detail/archive_pointer_oserializer.hpp 2009-07-08 12:30:38 EDT (Wed, 08 Jul 2009)
@@ -20,6 +20,7 @@
#include <boost/config.hpp>
#include <boost/archive/detail/basic_serializer.hpp>
#include <boost/archive/detail/basic_pointer_oserializer.hpp>
+#include <boost/archive/detail/basic_serializer_map.hpp>
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
@@ -35,6 +36,7 @@
template<class Archive>
class archive_pointer_oserializer :
public basic_pointer_oserializer {
+ static basic_serializer_map m_map;
protected:
explicit BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
archive_pointer_oserializer(
Modified: trunk/boost/archive/detail/iserializer.hpp
==============================================================================
--- trunk/boost/archive/detail/iserializer.hpp (original)
+++ trunk/boost/archive/detail/iserializer.hpp 2009-07-08 12:30:38 EDT (Wed, 08 Jul 2009)
@@ -118,15 +118,15 @@
virtual void destroy(/*const*/ void *address) const {
boost::serialization::access::destroy(static_cast<T *>(address));
}
- // private constructor to inhibit any existence other than the
- // static one
-public:
+protected:
+ // protected constructor since it's always created by singleton
explicit iserializer() :
basic_iserializer(
boost::serialization::type_info_implementation<T>::type
::get_const_instance()
)
{}
+public:
virtual BOOST_DLLEXPORT void load_object_data(
basic_iarchive & ar,
void *x,
@@ -188,7 +188,8 @@
void * & x,
const unsigned int file_version
) const BOOST_USED;
-public:
+protected:
+ // this should alway be a singleton so make the constructor protected
pointer_iserializer();
};
Modified: trunk/boost/archive/impl/archive_pointer_iserializer.ipp
==============================================================================
--- trunk/boost/archive/impl/archive_pointer_iserializer.ipp (original)
+++ trunk/boost/archive/impl/archive_pointer_iserializer.ipp 2009-07-08 12:30:38 EDT (Wed, 08 Jul 2009)
@@ -26,12 +26,8 @@
namespace archive {
namespace detail {
-namespace { // anon
- template<class Archive>
- class iserializer_map : public basic_serializer_map
- {
- };
-}
+template<class Archive>
+basic_serializer_map archive_pointer_iserializer<Archive>::m_map;
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
@@ -42,12 +38,11 @@
{
// only insert the first one. Assumes that DLLS are unloaded in
// the reverse sequence
- //std::pair<BOOST_DEDUCED_TYPENAME iserializer_map<Archive>::iterator, bool> result;
- iserializer_map<Archive> & map
- = serialization::singleton<iserializer_map<Archive> >::get_mutable_instance();
- iserializer_map<Archive>::iterator result = map.find(this);
- if(result == map.end())
- map.insert(this);
+ // std::pair<
+ // BOOST_DEDUCED_TYPENAME basic_serializer_map<Archive>::iterator,
+ // bool
+ // > result =
+ m_map.insert(this);
}
template<class Archive>
@@ -56,36 +51,20 @@
const boost::serialization::extended_type_info & eti
){
const basic_serializer_arg bs(eti);
- BOOST_DEDUCED_TYPENAME iserializer_map<Archive>::const_iterator it;
- it = boost::serialization::singleton<
- iserializer_map<Archive>
- >::get_const_instance().find(& bs);
- assert(
- it
- !=
- boost::serialization::singleton<
- iserializer_map<Archive>
- >::get_const_instance().end()
- );
+ basic_serializer_map::const_iterator it;
+ it = m_map.find(& bs);
+ assert(it != m_map.end());
return static_cast<const basic_pointer_iserializer *>(*it);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
archive_pointer_iserializer<Archive>::~archive_pointer_iserializer(){
- // note: we need to check that the map still exists as we can't depend
- // on static variables being constructed in a specific sequence
- if(serialization::singleton<
- iserializer_map<Archive>
- >::is_destroyed()
- )
- return;
-
- iserializer_map<Archive> & map
- = serialization::singleton<iserializer_map<Archive> >::get_mutable_instance();
- iserializer_map<Archive>::iterator result = map.find(this);
- if(result == map.end())
- map.erase(this);
+ basic_serializer_map::iterator it;
+ it = m_map.find(this);
+ assert(it != m_map.end());
+ if(*it == static_cast<const basic_serializer *>(this))
+ m_map.erase(it);
}
} // namespace detail
Modified: trunk/boost/archive/impl/archive_pointer_oserializer.ipp
==============================================================================
--- trunk/boost/archive/impl/archive_pointer_oserializer.ipp (original)
+++ trunk/boost/archive/impl/archive_pointer_oserializer.ipp 2009-07-08 12:30:38 EDT (Wed, 08 Jul 2009)
@@ -21,12 +21,8 @@
namespace archive {
namespace detail {
-namespace { // anon
- template<class Archive>
- class oserializer_map : public basic_serializer_map
- {
- };
-}
+template<class Archive>
+basic_serializer_map archive_pointer_oserializer<Archive>::m_map;
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
@@ -37,12 +33,11 @@
{
// only insert the first one. Assumes that DLLS are unloaded in
// the reverse sequence
- //std::pair<BOOST_DEDUCED_TYPENAME oserializer_map<Archive>::iterator, bool> result;
- oserializer_map<Archive> & map
- = serialization::singleton<oserializer_map<Archive> >::get_mutable_instance();
- oserializer_map<Archive>::iterator result = map.find(this);
- if(result == map.end())
- map.insert(this);
+ //std::pair<
+ // BOOST_DEDUCED_TYPENAME oserializer_map<Archive>::iterator,
+ // bool
+ // > result =
+ m_map.insert(this);
}
template<class Archive>
@@ -52,35 +47,19 @@
){
const basic_serializer_arg bs(eti);
basic_serializer_map::const_iterator it;
- it = boost::serialization::singleton<
- oserializer_map<Archive>
- >::get_const_instance().find(& bs);
- assert(
- it
- !=
- boost::serialization::singleton<
- oserializer_map<Archive>
- >::get_const_instance().end()
- );
+ it = m_map.find(& bs);
+ assert(it != m_map.end());
return static_cast<const basic_pointer_oserializer *>(*it);
}
template<class Archive>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
archive_pointer_oserializer<Archive>::~archive_pointer_oserializer(){
- // note: we need to check that the map still exists as we can't depend
- // on static variables being constructed in a specific sequence
- if(serialization::singleton<
- oserializer_map<Archive>
- >::is_destroyed()
- )
- return;
-
- oserializer_map<Archive> & map
- = serialization::singleton<oserializer_map<Archive> >::get_mutable_instance();
- oserializer_map<Archive>::iterator result = map.find(this);
- if(result == map.end())
- map.erase(this);
+ basic_serializer_map::iterator it;
+ it = m_map.find(this);
+ assert(it != m_map.end());
+ if(*it == static_cast<const basic_serializer *>(this))
+ m_map.erase(it);
}
} // namespace detail
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk