mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 19:37:14 +02:00
renamed serialize_node_pointer as serialize_tracked_address (editorial)
This commit is contained in:
@ -114,7 +114,7 @@ to normal separate chaining implementations.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <boost/unordered/detail/prime_fmod.hpp>
|
#include <boost/unordered/detail/prime_fmod.hpp>
|
||||||
#include <boost/unordered/detail/serialize_node_pointer.hpp>
|
#include <boost/unordered/detail/serialize_tracked_address.hpp>
|
||||||
|
|
||||||
#include <boost/core/addressof.hpp>
|
#include <boost/core/addressof.hpp>
|
||||||
#include <boost/core/allocator_access.hpp>
|
#include <boost/core/allocator_access.hpp>
|
||||||
@ -295,8 +295,8 @@ namespace boost {
|
|||||||
Archive& ar, grouped_bucket_iterator const& x)
|
Archive& ar, grouped_bucket_iterator const& x)
|
||||||
{
|
{
|
||||||
// requires: not at end() position
|
// requires: not at end() position
|
||||||
track_node_pointer(ar, x.p);
|
track_address(ar, x.p);
|
||||||
track_node_pointer(ar, x.pbg);
|
track_address(ar, x.pbg);
|
||||||
}
|
}
|
||||||
|
|
||||||
friend class boost::serialization::access;
|
friend class boost::serialization::access;
|
||||||
@ -305,8 +305,8 @@ namespace boost {
|
|||||||
void serialize(Archive& ar,unsigned int)
|
void serialize(Archive& ar,unsigned int)
|
||||||
{
|
{
|
||||||
// requires: not at end() position
|
// requires: not at end() position
|
||||||
serialize_node_pointer(ar, p);
|
serialize_tracked_address(ar, p);
|
||||||
serialize_node_pointer(ar, pbg);
|
serialize_tracked_address(ar, pbg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#include <boost/config/workaround.hpp>
|
#include <boost/config/workaround.hpp>
|
||||||
#include <boost/core/serialization.hpp>
|
#include <boost/core/serialization.hpp>
|
||||||
#include <boost/unordered/detail/foa/core.hpp>
|
#include <boost/unordered/detail/foa/core.hpp>
|
||||||
#include <boost/unordered/detail/serialize_node_pointer.hpp>
|
#include <boost/unordered/detail/serialize_tracked_address.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -201,8 +201,8 @@ private:
|
|||||||
friend void serialization_track(Archive& ar,const table_iterator& x)
|
friend void serialization_track(Archive& ar,const table_iterator& x)
|
||||||
{
|
{
|
||||||
if(x.p){
|
if(x.p){
|
||||||
track_node_pointer(ar,x.pc);
|
track_address(ar,x.pc);
|
||||||
track_node_pointer(ar,x.p);
|
track_address(ar,x.p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,8 +212,8 @@ private:
|
|||||||
void serialize(Archive& ar,unsigned int)
|
void serialize(Archive& ar,unsigned int)
|
||||||
{
|
{
|
||||||
if(!p)pc=nullptr;
|
if(!p)pc=nullptr;
|
||||||
serialize_node_pointer(ar,pc);
|
serialize_tracked_address(ar,pc);
|
||||||
serialize_node_pointer(ar,p);
|
serialize_tracked_address(ar,p);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *pc=nullptr;
|
unsigned char *pc=nullptr;
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
#include <boost/type_traits/make_void.hpp>
|
#include <boost/type_traits/make_void.hpp>
|
||||||
#include <boost/type_traits/remove_const.hpp>
|
#include <boost/type_traits/remove_const.hpp>
|
||||||
#include <boost/unordered/detail/fca.hpp>
|
#include <boost/unordered/detail/fca.hpp>
|
||||||
#include <boost/unordered/detail/serialize_node_pointer.hpp>
|
#include <boost/unordered/detail/serialize_tracked_address.hpp>
|
||||||
#include <boost/unordered/detail/type_traits.hpp>
|
#include <boost/unordered/detail/type_traits.hpp>
|
||||||
#include <boost/unordered/detail/fwd.hpp>
|
#include <boost/unordered/detail/fwd.hpp>
|
||||||
#include <boost/utility/addressof.hpp>
|
#include <boost/utility/addressof.hpp>
|
||||||
@ -1710,7 +1710,7 @@ namespace boost {
|
|||||||
friend void serialization_track(Archive& ar, const iterator& x)
|
friend void serialization_track(Archive& ar, const iterator& x)
|
||||||
{
|
{
|
||||||
if(x.p){
|
if(x.p){
|
||||||
track_node_pointer(ar, x.p);
|
track_address(ar, x.p);
|
||||||
serialization_track(ar, x.itb);
|
serialization_track(ar, x.itb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1721,7 +1721,7 @@ namespace boost {
|
|||||||
void serialize(Archive& ar,unsigned int)
|
void serialize(Archive& ar,unsigned int)
|
||||||
{
|
{
|
||||||
if(!p) itb = bucket_iterator();
|
if(!p) itb = bucket_iterator();
|
||||||
serialize_node_pointer(ar, p);
|
serialize_tracked_address(ar, p);
|
||||||
ar & core::make_nvp("bucket_iterator", itb);
|
ar & core::make_nvp("bucket_iterator", itb);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1819,7 +1819,7 @@ namespace boost {
|
|||||||
friend void serialization_track(Archive& ar, const c_iterator& x)
|
friend void serialization_track(Archive& ar, const c_iterator& x)
|
||||||
{
|
{
|
||||||
if(x.p){
|
if(x.p){
|
||||||
track_node_pointer(ar, x.p);
|
track_address(ar, x.p);
|
||||||
serialization_track(ar, x.itb);
|
serialization_track(ar, x.itb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1830,7 +1830,7 @@ namespace boost {
|
|||||||
void serialize(Archive& ar,unsigned int)
|
void serialize(Archive& ar,unsigned int)
|
||||||
{
|
{
|
||||||
if(!p) itb = bucket_iterator();
|
if(!p) itb = bucket_iterator();
|
||||||
serialize_node_pointer(ar, p);
|
serialize_tracked_address(ar, p);
|
||||||
ar & core::make_nvp("bucket_iterator", itb);
|
ar & core::make_nvp("bucket_iterator", itb);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -29,12 +29,12 @@ namespace detail{
|
|||||||
* through the following protocol:
|
* through the following protocol:
|
||||||
* - At saving time, for each iterator it in [x.begin(),x.end()),
|
* - At saving time, for each iterator it in [x.begin(),x.end()),
|
||||||
* serialization_track(ar,it) is ADL-called to instruct the archive to
|
* serialization_track(ar,it) is ADL-called to instruct the archive to
|
||||||
* track the addresses of the iterator's associated node(s) via
|
* track the positions internally pointed to by the iterator via
|
||||||
* track_node_pointer().
|
* track_address().
|
||||||
* - At loading time, these addresses are mapped to those of the equivalent
|
* - At loading time, these addresses are mapped to those of the equivalent
|
||||||
* reconstructed nodes using again serialization_track(ar,it).
|
* reconstructed positions using again serialization_track(ar,it).
|
||||||
* - Serializing an iterator reduces to serializing pointers to previously
|
* - Serializing an iterator reduces to serializing pointers to previously
|
||||||
* tracked nodes via serialize_node_pointer().
|
* tracked addresses via serialize_address().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename Iterator>
|
template<typename Iterator>
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
* See https://www.boost.org/libs/unordered for library home page.
|
* See https://www.boost.org/libs/unordered for library home page.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BOOST_UNORDERED_DETAIL_SERIALIZE_NODE_POINTER_HPP
|
#ifndef BOOST_UNORDERED_DETAIL_SERIALIZE_TRACKED_ADDRESS_HPP
|
||||||
#define BOOST_UNORDERED_DETAIL_SERIALIZE_NODE_POINTER_HPP
|
#define BOOST_UNORDERED_DETAIL_SERIALIZE_TRACKED_ADDRESS_HPP
|
||||||
|
|
||||||
#include <boost/core/pointer_traits.hpp>
|
#include <boost/core/pointer_traits.hpp>
|
||||||
#include <boost/core/serialization.hpp>
|
#include <boost/core/serialization.hpp>
|
||||||
@ -20,19 +20,19 @@ namespace boost{
|
|||||||
namespace unordered{
|
namespace unordered{
|
||||||
namespace detail{
|
namespace detail{
|
||||||
|
|
||||||
/* Node pointer serialization to support iterator serialization as described
|
/* Tracked address serialization to support iterator serialization as described
|
||||||
* in serialize_container.hpp. The underlying technique is to reinterpret_cast
|
* in serialize_container.hpp. The underlying technique is to reinterpret_cast
|
||||||
* Node pointers to serialization_tracker<Node> pointers, which, when
|
* T pointers to serialization_tracker<T> pointers, which, when dereferenced
|
||||||
* dereferenced and serialized, do not emit any serialization payload to the
|
* and serialized, do not emit any serialization payload to the
|
||||||
* archive, but activate object tracking on the relevant addresses for later
|
* archive, but activate object tracking on the relevant addresses for later
|
||||||
* use with serialize_node_pointer().
|
* use with serialize_tracked_address().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename Node>
|
template<typename T>
|
||||||
struct serialization_tracker
|
struct serialization_tracker
|
||||||
{
|
{
|
||||||
/* An attempt to construct a serialization_tracker means a stray address
|
/* An attempt to construct a serialization_tracker means a stray address
|
||||||
* in the archive, that is, one without a previously tracked node.
|
* in the archive, that is, one without a previously tracked address.
|
||||||
*/
|
*/
|
||||||
serialization_tracker(){throw_exception(bad_archive_exception());}
|
serialization_tracker(){throw_exception(bad_archive_exception());}
|
||||||
|
|
||||||
@ -40,60 +40,58 @@ struct serialization_tracker
|
|||||||
void serialize(Archive&,unsigned int){} /* no data emitted */
|
void serialize(Archive&,unsigned int){} /* no data emitted */
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Archive,typename NodePtr>
|
template<typename Archive,typename Ptr>
|
||||||
void track_node_pointer(Archive& ar,NodePtr p)
|
void track_address(Archive& ar,Ptr p)
|
||||||
{
|
{
|
||||||
typedef typename boost::pointer_traits<NodePtr> ptr_traits;
|
typedef typename boost::pointer_traits<Ptr> ptr_traits;
|
||||||
typedef typename boost::remove_const<
|
typedef typename boost::remove_const<
|
||||||
typename ptr_traits::element_type>::type node_type;
|
typename ptr_traits::element_type>::type element_type;
|
||||||
|
|
||||||
if(p){
|
if(p){
|
||||||
ar&core::make_nvp(
|
ar&core::make_nvp(
|
||||||
"node",
|
"address",
|
||||||
*reinterpret_cast<serialization_tracker<node_type>*>(
|
*reinterpret_cast<serialization_tracker<element_type>*>(
|
||||||
const_cast<node_type*>(
|
const_cast<element_type*>(
|
||||||
boost::to_address(p))));
|
boost::to_address(p))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Archive,typename NodePtr>
|
template<typename Archive,typename Ptr>
|
||||||
void serialize_node_pointer(
|
void serialize_tracked_address(Archive& ar,Ptr& p,boost::true_type /* save */)
|
||||||
Archive& ar,NodePtr& p,boost::true_type /* save */)
|
|
||||||
{
|
{
|
||||||
typedef typename boost::pointer_traits<NodePtr> ptr_traits;
|
typedef typename boost::pointer_traits<Ptr> ptr_traits;
|
||||||
typedef typename boost::remove_const<
|
typedef typename boost::remove_const<
|
||||||
typename ptr_traits::element_type>::type node_type;
|
typename ptr_traits::element_type>::type element_type;
|
||||||
typedef serialization_tracker<node_type> tracker;
|
typedef serialization_tracker<element_type> tracker;
|
||||||
|
|
||||||
tracker* pt=
|
tracker* pt=
|
||||||
const_cast<tracker*>(
|
const_cast<tracker*>(
|
||||||
reinterpret_cast<const tracker*>(
|
reinterpret_cast<const tracker*>(
|
||||||
const_cast<const node_type*>(
|
const_cast<const element_type*>(
|
||||||
boost::to_address(p))));
|
boost::to_address(p))));
|
||||||
ar<<core::make_nvp("pointer",pt);
|
ar<<core::make_nvp("pointer",pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Archive,typename NodePtr>
|
template<typename Archive,typename Ptr>
|
||||||
void serialize_node_pointer(
|
void serialize_tracked_address(Archive& ar,Ptr& p,boost::false_type /* load */)
|
||||||
Archive& ar,NodePtr& p,boost::false_type /* load */)
|
|
||||||
{
|
{
|
||||||
typedef typename boost::pointer_traits<NodePtr> ptr_traits;
|
typedef typename boost::pointer_traits<Ptr> ptr_traits;
|
||||||
typedef typename boost::remove_const<
|
typedef typename boost::remove_const<
|
||||||
typename ptr_traits::element_type>::type node_type;
|
typename ptr_traits::element_type>::type element_type;
|
||||||
typedef serialization_tracker<node_type> tracker;
|
typedef serialization_tracker<element_type> tracker;
|
||||||
|
|
||||||
tracker* pt;
|
tracker* pt;
|
||||||
ar>>core::make_nvp("pointer",pt);
|
ar>>core::make_nvp("pointer",pt);
|
||||||
node_type* pn=const_cast<node_type*>(
|
element_type* pn=const_cast<element_type*>(
|
||||||
reinterpret_cast<const node_type*>(
|
reinterpret_cast<const element_type*>(
|
||||||
const_cast<const tracker*>(pt)));
|
const_cast<const tracker*>(pt)));
|
||||||
p=pn?ptr_traits::pointer_to(*pn):0;
|
p=pn?ptr_traits::pointer_to(*pn):0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Archive,typename NodePtr>
|
template<typename Archive,typename Ptr>
|
||||||
void serialize_node_pointer(Archive& ar,NodePtr& p)
|
void serialize_tracked_address(Archive& ar,Ptr& p)
|
||||||
{
|
{
|
||||||
serialize_node_pointer(
|
serialize_tracked_address(
|
||||||
ar,p,
|
ar,p,
|
||||||
boost::integral_constant<bool,Archive::is_saving::value>());
|
boost::integral_constant<bool,Archive::is_saving::value>());
|
||||||
}
|
}
|
Reference in New Issue
Block a user