Boost logo

Boost Users :

Subject: Re: [Boost-users] [Serialization] Serialization of function pointers
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2009-11-12 17:30:05


On Thu, Nov 12, 2009 at 1:00 PM, Robert Ramey <ramey_at_[hidden]> wrote:
> It can be done.  I've wanted to add a "case study" to the documentation but
> never have gotten around to it.
>
> Basically here is the procedure.
>
> a) Use a function object rather than a function pointer.  This should be
> easy to do.
> b) derive your function object from a common base class make your function
> a virtual member of this class
> c) make sure that the common base class has at least one virtual function.
> This makes it a polymorphic base class.
> d) include a variable which is a pointer to the common base class - that
> is a polymorphic pointer.
> e) Assign a new function object of the desired derived type to the
> polymorphic
> pointer.
> f) Save the polymorphic pointer as you would any other polymorphic pointer.
> g) Some other time and/or place, load the polymorphic pointer as you would
> any other polymorphic pointer.
> h) You can now call your original function through the pointer to it's base
> class

Arguably, with this technique you're not serializing a function pointer. :)

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


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