Boost logo

Boost :

From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2007-10-08 19:34:01

Hi Jeremy,

----- Mensaje original -----
De: Jeremy Maitin-Shepard <jbms_at_[hidden]>
Fecha: Lunes, Octubre 8, 2007 10:15 pm
Asunto: Re: [boost] [serialization] Proposal for an extension API to
theArchive concept
Para: boost_at_[hidden]

> I think there is a significant issue with your proposed extension
> mechanism: an archive can only contain a single extension object
> at a time. Consequently, if two types require different extension
> objects, they cannot both be serialized using the same archive.
> In particular, if say flyweight requires some special extension
> and shared_ptr requires its own special extension object, it won't
> possible to serialize both using the same archive. It seems,
> that in practice there would have to be a single standardized
> object,which is either in use or not in use for a particular archive.

My proposal allows for any type to register and use its own
helper object: note that the proposed extension interface:


is *not* meant to be public; quoting from :
"These expressions are reserved for the internal usage of
Boost.Serialization and thus must not be called by user code."
It is then Boost.Serialization that adjoins its own extension
object to an Archive and publicizes a helper API based upon
this internal object:

  template<typename Archive>
  void insert_helper(
    Archive& ar,
    const extended_type_info* eti,
    shared_ptr<void> & sph)
    // get the extension object or create a new one if this
    // is the first time

    shared_ptr<void> ext_obj=ar.get_extension_obj();
      ext_obj.reset(new extension);
    extension& ext=*ext_obj;

    // forward to the extension object

So, each distinct T can register its separate helper
object more or less like this:

  serialization::extended_type_info* eti=
    serialization::type_info_implementation<helper<T> >::
  shared_ptr<void> sph;

Did I make myself clearer now?

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo

Boost list run by bdawes at, gregod at, cpdaniel at, john at