|
Boost : |
From: George van den Driessche (grebe_at_[hidden])
Date: 2004-11-12 14:25:33
> Message: 4
> Date: Fri, 12 Nov 2004 07:34:27 -0500
> From: "Neal D. Becker" <ndbecker2_at_[hidden]>
> Subject: [boost] Re: Generalised reflection
> To: boost_at_[hidden]
> Message-ID: <cn2akj$qij$1_at_[hidden]>
> Content-Type: text/plain; charset=us-ascii
>
> George van den Driessche wrote:
>
> [...]
> > Yes. Now imagine that I've got some helper functions for use with
> > Boost.Python's pickling suite. But I want to use them with a C++
> > serialisation library. I'm going to have to factor a bunch of code out
of
> > those helper functions so that I can invoke them without using
> > boost::python::tuple, and then write wrappers to use the factored-out
code
> > with the Boost.Python pickling suite. Instead, I want to write just the
> > C++ serialisation code, and have that automatically wrapped up for use
> > with Boost.Python pickling. It's a similar separation of layers.
> >
>
> Incidentally, I wrote about sharing boost c++ serialization with
> boost.python pickling, and posted code demonstrating this. Nobody seemed
> very interested.
I think it's this post:
http://tinyurl.com/6dbhb
that you're referring to. In which case, I missed it, but yes, you're on the
same topic.
One of the things that I noticed about serialisation code is that there's
generally a symmetry between the reading and writing routines. So rather
than write "this is how I load an X, and this is how I save one" I'd want to
write "these are the things in X that need to be saved" and let some
templates figure out what the corresponding routines are. And then it was
this desire to serialise things automatically by specifying properties that
led me on to think about a common architecture for language binding and
serialisation. Maybe in the end you'd get declarations like:
/// Properties for serialisation
boost::properties< my_t, "my_t", boost::serialisation >
.def( "my_int", &my_t::my_int, &my_t::set_my_int )
// After serialisation format version 4,
// my_float no longer needed to be serialised
.def( "my_float", &my_t::my_float, &my_t::set_my_float,
boost::serialisation::in_format_version_range<>( 0, 4 ) )
;
/// Properties for scripting
boost::properties< my_t, "my_t", boost::langbinding >
// Use serialisation properties to implement pickling.
.def_pickle( default_pickle_suite< my_t >() )
.def( "my_int", &my_t::my_int, &my_t::set_my_int,
boost::langbinding::return_internal_reference<>() )
// We don't want to bind my_float, for whatever reason.
;
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk