Boost logo

Boost Users :

Subject: Re: [Boost-users] Using boost::serialization in real-time withoutallocating memory
From: Stefan Strasser (strasser_at_[hidden])
Date: 2009-09-18 14:08:34


Am Friday 18 September 2009 17:18:56 schrieb Peter Soetens:
> On Fri, Sep 18, 2009 at 14:30, Peter Soetens <peter.soetens_at_[hidden]>
wrote:
> > On Thu, Sep 17, 2009 at 18:33, Robert Ramey <ramey_at_[hidden]> wrote:
> >> Peter Soetens wrote:
> >>> I might do what you suggest or look for another serialization
> >>> solution.
> >>
> >> Given the limited scope of what you want to do, it wouldn't be THAT hard
> >> to make your own archive.  Take a look at "trivial_archive" in the
> >> documentation and build from that.
> >
> > Encouraged by your and Stefan's suggestions, I've spent another day at
> > looking what the possibilities are.
> >
> > 1. I first created my own binary_?archive classes which inherited from
> > common_?archive. This resulted in pulling in the library with the
> > 'behind the scenes type tracking'. It seems, inheriting from common is
> > not an option for me if I want 'zero-allocation' serialization.
> > Correct ? (I also tested the demo_fast_archive.cpp extended with
> > no_header, but that one also allocated).
> >
> > 2. I then tried to work further on Stefan's code snippet. It works,
> > but indeed only for 'primitive_type's. I *think* I need functionality
> > upto the 'object_serializable' if I want std::vector<T> as well. Since
> > Stefan's operator& consumes every T, I'll need one operator& for each
> > primitive type, and then an operator& that tries to save/load using
> > free functions of the not primitive type.
> >
> > 3. It looks that I'll have to implement the Archive concept from
> > scratch or at least based on Stefan's code and the
> > load_binary/save_binary code from binary_?archive.
>
> I'm got so far that I 'hacked' an allocation free output and output
> archive, and output works like a charm. But for the input side, I
> can't seem to get the ADL to work for serializing the nvt<T> case.

line 68: boost::serialization::load(*this, t, version);

don't you mean archive::load? I'm not aware of a serialization::load function.

however, this is not an ADL lookup, as it has a namespace specifier.
something like this should do the trick:

namespace boost{ namespace archive{
void tinyarchive_load_adl(...){
  load(...);
}
} }

boost::archive::tinyarchive_load_adl(...);

I'm not sure if the call is required to originate within the archive namespace
in this case (I think it does, because none of the arguments is in that
namespace) but in any way, an ADL call needs to be without a namespace
specifier.


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