Boost logo

Boost Users :

Subject: [Boost-users] [Serialization] Why not allowing reset_object_address on object serialized throw a pointer ?
From: Alain KOCELNIAK (alain_at_[hidden])
Date: 2010-07-16 09:53:16


This issue has already been discussed but was never addressed :
http://lists.boost.org/boost-users/2008/11/42417.php
https://svn.boost.org/trac/boost/ticket/4044
 
I don't understand why objects loaded as pointer can't be relocated :
 
- These objects are stored in basic_iarchive_impl::object_id_vector as the
others, so, technically speaking, we can change their "address"
 
- There is situations where it is mandatory : for example when data, sharing
some objects, are serialized / dispatched in separate archives
  => without relocating service at loading, sharing of object is not
possible.
 
 
For the moment, I workaround the limitation with a hack in the method
basic_iarchive_impl::reset_object_address :
 
I remove the "safeguard" which checks that the method is applied on a
tracked object and immediately after
the concerned object is read :
 
================================================
for(i = moveable_objects_recent; i < moveable_objects_end; ++i){
  if(old_address == object_id_vector[i].address)
     break;
}
for(; i < moveable_objects_end; ++i){
================================================
 
is replaced by
 
=================================================
for(i = 0; i < object_id_vector.size(); ++i){
=================================================
 
 
I think that the limit can be properly removed by handling in
"basic_iarchive_impl::load_pointer" the "moveable_objects_..." variables
as it is done in "basic_iarchive_impl::load_object"
 
As objects created by the serialization system are marked with
"loaded_as_pointer" = true
(this data is used by basic_iarchive_impl::delete_created_pointers) I think
this data should be set to false by "reset_object_address".
 
Is there other implication ?
 
 
Alain.
 
 



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net