Re: [ROOT] TNode::SetParent()

From: Valeri Fine (fine@bnl.gov)
Date: Wed Aug 29 2001 - 19:33:18 MEST


It seemsto me  the feature you are asking about had been 
implemented  with TVolume class.
http://root.cern.ch/root/htmldoc/TVolume.html

Hope this helps,
-----
Dr.Valeri Fine
STAR/US Atlas                                    E-mail: fine@bnl.gov
Brookhaven National Lab                   Phone: +1 631 344 7806
Upton, NY 11973-5000                       FAX:     +1 631 344 4206
USA



----- Original Message ----- 
From: "Robert Hatcher" <rhatcher@SLAC.stanford.edu>
To: <roottalk@pcroot.cern.ch>
Sent: Tuesday, August 28, 2001 9:01 PM
Subject: [ROOT] TNode::SetParent()


> Hi,
>   Currently in TNode.h there is the declaration & definition for the
> method to change a TNode's parent, e.g.:
> 
>    virtual void        SetParent(TNode *parent) {fParent=parent;}
> 
> But this does only half the work necessary.  The parent losing the
> custody battle is never informed and continues to think they have
> this child.  I think the right code is:
> 
> void TNode::SetParent(TNode *parent)
> {
>    // set the pointer to the parent, keep parents informed about who they have
> 
>    if (fParent)   fParent->GetListOfNodes()->Remove(this);
>    else         gGeometry->GetListOfNodes()->Remove(this);
> 
>    fParent = parent;
> 
>    if (fParent) {
>       fParent->BuildListOfNodes(); // new parent might not have list
>       fParent->GetListOfNodes()->Add(this);
>    }
>    else gGeometry->GetListOfNodes()->Add(this);
> }
> 
> Could this be the distributed definition?  There are times when
> building a geometry it's easier to build a "containee" node before
> one builds the "container" node and then after the fact make
> the right adjustments.
> 
> Thanks,
> -robert
> 
> Robert W. Hatcher   |  rhatcher@slac.stanford.edu
> Research Associate  |  650.926.3171  [FAX 4001 or 3587]
> Stanford University |  PO Box 4349, MS #63, Stanford CA 94309
> 
> 



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:58 MET