Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2006-05-30 23:47:43


I still don't understand why you want to do this - but no matter.

If you don't want the standard pointer serialization - you could
just not invoke ar << pci . Just do what ever you want to do
instead. or make your own wrapper - see serialization wrappers
that would be used like

ar << my_wrapper(pci) when every you want your special
code invoked. This wrapper could be used to apply your
special behavior to any pointer type desired.

Archives handle all pointers with the same code. Many you
want to make your own archive class - via derivation from
one of the existing ones - which handles you're special
case of a particular type of pointer before it gets passed
to the standard serialization code.

Finally, if you want to make your own pointer serialization
just derive from the desired archive class and implement
your own code for
template<class T>
save(const * T){
....
}

(assuming your compiler supports correct partial function
template ordering)

So you have lots of options.

Robert Ramey

Bryan Donlan wrote:
> On 5/30/06, Robert Ramey <ramey_at_[hidden]> wrote:
>> Rather than what you have below - just try
>>
>> BOOST_SERIALIZATION_SPLIT_FREE(creaturesImage);
>>
>> By default - pointers to primitive types aren't serializable. I'm
>> not sure why you used the BOOST_CLASS_IMP.. below but it
>> would seem to me in appropriate in your case. If you do this
>> you will be able to do;
>>
>> const creaturesImage *pci;
>> ...
>> ar << pci;
>>
>> ...
>> creaturesImage *new_pci;
>> ar >> new_pci
>>
>> assert(*pci == *new_pci);
>>
>> In fact, given the size of your application, making a little program
>> like the above to test your serialization code separately, is
>> probably a good idea anyway.
>>
>> Good Luck
>>
>> Robert Ramey
>
> I should clarify a bit - creaturesImage /is/ a class. But I want to
> override the /pointer/ serialization, rather than the class
> serialization. As such, it doesn't matter if the representations of
> the pointers are unchanged between two runs of the program; rather, it
> matters that the class not be serialized by boost, as these classes
> are rather heavy in terms of memory-mappings and other external
> resources (hence using a global cache to share them).


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