Picon

serialization, many archives, cheap descrimination

Hello List,

I have several classes, each put into it's own binary archive.

How can I cheaply and efficiently determine the class type of a binary 
archive so that I know how
to restore it?

Thanks,
Vic
Robert Ramey | 12 May 18:29

Re: serialization, many archives, cheap descrimination

Hmmm - consider using variant which lists your classes and serializing the 
variant.  Serialization of variant is already in the package.

Robert Ramey

Victor Whiskey Yankee wrote:
> Hello List,
>
> I have several classes, each put into it's own binary archive.
>
> How can I cheaply and efficiently determine the class type of a binary
> archive so that I know how
> to restore it?
>
> Thanks,
> Vic 
Picon

Re: serialization, many archives, cheap descrimination

Robert Ramey wrote:
Hmmm - consider using variant which lists your classes and serializing the variant.
I assume you mean the boost variant. It looks promising but I wonder how that affects the size of the
archive, given that different objects in the "union"  will have drastically different sizes themselves?


Q: Are there any archive methods to tell you what's in the archive, like some sort of list? And then it wold
be cool to be able to tell the archive to restore a certain random object from the list (random access).


As an alternative to variant,  would the following strategy work?
    create 2 archives per object: one archive is the "header" with a key that tells me which type of object it is,
    and another archive that is the serialized object itself.
This strategy seems very inefficient.

Do you think using a more efficent method would be to use derived classes? Create one archive. Then, when
restoring the object, first restore it as a simple base class (with almost nothing in it but the key type), then
restore it again using that type info?

Thanks,
Vic


Robert Ramey Victor Whiskey Yankee wrote:
Hello List, I have several classes, each put into it's own binary archive. How can I cheaply and efficiently determine the class type of a binary archive so that I know how to restore it? Thanks, Vic
_______________________________________________ Boost-users mailing list Boost-users <at> lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
Boost-users <at> lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Andrew Holden | 12 May 20:29

Re: serialization, many archives, cheap descrimination

Whiskey Yankee wrote:
>
>Robert Ramey wrote: 
>
>>Hmmm - consider using variant which lists your classes and serializing the 
>>variant.
>
>I assume you mean the boost variant. It looks promising but I wonder how
>that affects the size of the archive, given that different objects in the
>"union" will have drastically different sizes themselves?

If I'm reading the header file correctly, a variant is serialized as an integer followed by the
serialization of whatever type it holds.  The serialization is not affected in any way by the other types
the variant might hold; only the one it is holding at the moment.

This seems like a pretty efficient way to serialize an arbitrary object.

Gmane