Boost logo

Boost Users :

From: troy d. straszheim (troy_at_[hidden])
Date: 2008-08-09 13:56:16


Hey,

Here's an autoregistering serializable any, I think it qualifies as hacky
and suboptimal. Of course the typeid(T).name() strings aren't portable,
and the implementation gets a little intimate with the
mechanics of registration, but it works... You could make this less
intrusive, I suppose, but without the venerable

   #define private public

technique (still one of my all time favorite hacks)
I don't think you're going to get it completely nonintrusive.

-t

Robert Ramey wrote:
> I don't know if this helps, but you might want to take a look at the
> implementation of serialization
> of variant.
>
> Robert Ramey
>
> Sebastian.Karlsson_at_[hidden] wrote:
>>> Hi,
>>>
>>> I'm in the process of trying to get boost::any serializable, and it's
>>> quite tricky, especially considered my very limited experience with
>>> boost::serialize. I googled around and found an old discussion on
>>> this very list, and while interesting no resolution seemed to be
>>> found which satisfied all the criteria for being commited boost.
>>> However, since I'm not as picky with data portability, the solution
>>> hinted at in: http://lists.boost.org/boost-users/2005/09/14266.php
>>> seems very interesting. The only problem is that I can't see how it
>>> would be implemented to solve this problem.
>>>
>>> It needs to be within the definition of the class to be able for the
>>> typename to be in scoop, but since the macro seems to expand to a
>>> definition to be placed in the boost namespace I can't seem to get it
>>> to play nice.
>>>
>>> Any solution which lets me automagicaly serialize boost::any which
>>> contains serializable types, even if intrusive, would be extremely
>>> welcomed.
>> Okay, not much action there. I'll try to paraphrase myself. Is there
>> any work being done on trying to solve the underlying problem? I know
>> there's other use cases where one usually inherits from a base class
>> when doing template classes to be able to store pointers. I'd think it
>> would be possible to solve this with making serialize virtual, but
>> then you'd have to specialize it for every archive, and well, down
>> that road lies mostly ruin.
>>
>> I'd love to fix this myself, and I do in fact have a couple tricks
>> going which at least is better than virtual. Basically having a static
>> member which one initialize through a function call which registers
>> the type. The only problem is that the serialization library isn't
>> really for the faint of heart, there's a lot of trickery pokery. And I
>> have no experience with either mpi or template meta programming, so
>> it's sadly kind of a large task to tackle for me.
>>
>> Sorry for being a nuisance but I really want to use boost::serialize,
>> and this is a total deal breaker for me. I understand that it's a hard
>> problem, and I understand that there's most likely no ideal solution
>> found. I'm looking for something which while sub optimal, is as good
>> as it currently gets, and is better than making serialize virtual and
>> having to specialize it for all possible archive types.
>>
>> // Sebastian Karlsson
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users




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