|
Boost Users : |
Subject: Re: [Boost-users] [serialization] how to serialize boost::function
From: Robert Ramey (ramey_at_[hidden])
Date: 2009-09-15 17:14:09
Why don't you just derived all the functors from a common base
and serialize a base class pointer? You wouldn't have to do anything
special since polymorphic pointers are already addressed.
Robert Ramey
Chard wrote:
> "Igor R" <boost.lists_at_[hidden]> wrote in message
> news:cfe0a3cf0909150846l4290d47yd03b8ea7f33e0b53_at_mail.gmail.com...
>>
>> Ok, thank you. So the way to go is to make "manual" function
>> objects...
>
> We have a system that serializes boost::function - they are used as
> factory objects that are sent through sockets (via asio).
>
> We only support serializing boost::function with functors, but the
> mechanism works well. Fortunately, boost::function has the target<>
> method that can be used to get access to the original type.
>
> As touched upon by an earlier post, we have to look up the types from
> some kind of registry that associates the boost::function (the
> signature) with the type (the functor) that can be assigned into it. This
> means we have to register each association, but this is similar
> to registering polymorphic class types (i.e. archive.register_type<>).
>
> It may be possible to generalize the mechanism, but it would probably
> require a new export macro that can associate the types, e.g. a
> BOOST_FUNCTION_EXPORT(signature, func_name, type, type_name) to go
> along with BOOST_CLASS_EXPORT.
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