Re: [libxml++] Re: [Libxmlplusplus-general] Node ownership



On Thu, 2003-02-06 at 21:11, Stefan Seefeld wrote:
> Murray Cumming wrote:
> 
> >>1) you suggest an additional member: 'owned_by_libxml', which isn't
> >>    necessary as you can determine by inspecting the _impl whether it
> >>    is linked into a tree.
> > 
> > 
> > Yes, that might work, but I'd prefer not to access libxml's private
> > structures.
> 
> what is a private structure ?

You said "by inspecting the _impl". I assumed that you meant inspecting
by accessing the private structure.

>  I agree that we have to be very cautious
> to only use things part of the public API. I probably should ask DV
> which members of the various structs he considers public and which not.
> 
> >>2) you need an accessible destructor, so you can delete the node
> >>    explicitely, after having checked that you are allowed to
> >>
> >>    if (!node->is_owned_by_libxml()) delete node;
> >>
> >>    or equivalent. That doesn't look very nice.
> > 
> > 
> > Or just assume that you know what you are doing. The existence of an
> > is_owned_by_libxml() method wouldn't force you to use it.
> 
> Yes, but even then I'd prefer to be able to just throw
> 'invalid_argument' or something, instead of watching the application
> crash.

As an application developer you may do that if you like.

> But being able to use the delete operator would be very hacky, because
> it implies a circular dependency that you'd need to break out explicitely:
> 
> Node::~Node()
> {
>    if (_impl)
>    {
>      _impl->private = 0; // make sure this destructor isn't called twice
>      xmlFreeNode(_impl);
>    }
> }

Maybe. We deal with similar, but more complex, things successfully in
gtkmm. I don't think it's a problem.

-- 
Murray Cumming
murray usa net
www.murrayc.com





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]