Re: [ROOT] Deletion of objects in TFolder

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Jan 04 2002 - 11:28:29 MET


Hi Christian,


On Tue, 1 Jan 2002, cstrato@EUnet.at wrote:

> Dear Rooters, Happy New Year!
> 
> I have the following questions:
> 
> 1, When I delete TFolder, are then the objects in TFolder also deleted?
> Although TFolder can set “SetOwner()”, looking at the source code I do
> not find any use of the variable “fIsOwner”. Is this feature currently
> not implemented?  (root version 3.02.06)

TFolder::SetOwner was inactive. Now implemented in the development
version.
I have added the following comments in the class description:
// When a folder is deleted, its reference from the parent folder and
// possible other folders is deleted.
//
// If a folder has been declared the owner of its objects/folders via
// TFolder::SetOwner, then the contained objects are deleted when the
// folder is deleted. By default, a folder does not own its contained
objects.
// NOTE that folder ownership can be set
//   - via TFolder::SetOwner
//   - or via TCollection::SetOwner on the collection specified to
TFolder::AddFolder

> 
> 2, It is not quite clear to me when to use “Remove()” and when to use
>  “RecursiveRemove()”?

Do not use RecursiveRemove yourself. This function is automatically
called by the TObject destructor to clean all containers that may
reference the deleted object.

> 
> 3, When TFolder and its objects are permanently stored in TFile, can
> I apply the same methods Recursive/Remove to delete the objects from
> TFile?

No. TFolder has no connection with TFile. It is only a containers
for objects in memory. From a TFolder, however, it is possible
to create a TTree automatically.

Rene Brun

> 
> Thank you an advance
> 
> Best regards
> Christian
> ----------------------------------
> C.h.r.i.s.t.i.a.n  S.t.r.a.t.o.w.a
> V.i.e.n.n.a,  A.u.s.t.r.i.a
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:37 MET