|
Boost Users : |
Subject: [Boost-users] [serialization] tracking objects
From: Matthias Brantner (matthias.brantner_at_[hidden])
Date: 2011-10-28 19:51:02
Hello,
I have n objects sharing common (sub)objects in a pool (i.e. via pointers).
I would like to save (serialize) these n objects separately. Each result
should contain one copy of the shared object and can be used stand alone.
However, when loading (deserializing) multiple of those n objects, I would
like to recreate the original state, i.e. subobjects previously pooled are
again shared and contained in the pool.
For example, object O1 contains a pointer to object P1. Object
O2 also contains a pointer to object P1. O1 and O2 are separately serialized
and each serialization will contain a copy of P1. After deserializing,
the deserialized versions of O1 and O2 should both contain pointers
to the same object P1.
My current idea is to deserialize P1 (in the process of deserializing O1
or O2) by implementing the load function for P1's class. In this function,
I would like to check if an object equal to P1 already exists in the pool.
If it exists, I would like to return a pointer to the existing object. Otherwise,
I would like to insert it into the pool and return the newly created object.
However, I have not found a way to return a pointer that was not created
by boost.
Is there such a way or is there a better way to do what I'm trying
to do?
Thanks in advance.
Best regards
Matthias
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