[xsd-users] Getting at the autopointers
Boris Kolpackov
boris at codesynthesis.com
Wed Nov 16 06:40:05 EST 2005
Giles,
COPE, Giles, FM <Giles.COPE at rbos.com> writes:
> Hi Boris, when our root object destructor gets called the whole tree is
> deleted. Presumably this is because it's following each autopointer and
> calling the destructor on what it owns.
That's right, each node in the document tree owns its sub-tree.
> We'd like to get to the autopointer to release it, so that we can put the
> objects into a cache and manage their lifecycle independently of the main
> document.
If I understood you correctly, you want to "detach" some sub-trees from
the complete document tree and manage them separately. The only way that
I can think of is by making a copy of the nodes that you are interested
in (a copy of all the "sub-nodes" will be made automatically). E.g.,
suppose you have the following schema:
<complexType name="Foo">
...
</complexType>
<complexType name="Bar">
<sequence>
<element name="foo" type="Foo"/>
...
</sequence>
</complexType>
Then you can do something like this:
Bar& b = ...
auto_ptr<Foo> f (new Foo (b.foo ())); // Make a copy.
cache.add (f.release ()); // Add to the cache.
hth,
-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20051116/080f2451/attachment.pgp
More information about the xsd-users
mailing list