Hi Christian,
On Fri, 4 Jan 2002, cstrato@EUnet.at wrote:
> Dear Rene;
>
> When trying to create a complicated directory hierarchy in TFile, I came
>
> across the following questions:
>
> 1, Constructor: Sorrowly, mkdir() cannot be used to check if a directory
>
> exists already, since "Error("TDirectory","Directory %s exists
> already",name);"
> in the constructor does not set "gDirectoy = 0;". I suppose this is a
> feature to allow namecycles, but then I would suggest to change "Error"
> to "Warning"?
>
You can check if name (object or directory) is already in the current dir
with gDirectory->FindObject(name).
> 2, RecursiveRemove(): Is it ok to call RecursiveRemove(), when I want to
>
> delete a TObject, or does this have side effects? (I need to pass a
> TObject and not a namecycle.)
Why do you want to call RecursiveRemove? This function is automatically
by the TObject destructor when object->TestBit(kMustCleanup) is true.
The kMustCleanup bit is automatically set for objects added to TPad
and TFolder. You can set this bit yourself object->SetBit(kMustCleanup)
if you want this object to be automatically removed from all containers
referencing it when the object is deleted.
You can add a container to teh list of containers to be cleaned via
gROOT->GetListOfCleanups()->Add(mycollection);
>
> 3, Write(): Is there a reason why the variable "name" is not used in
> method
> Write(name = 0,..)? It would be great if I could use dir->Write(MyName)
> to
> write a single object to TFile.
You better use object->Write();
or object->Write(name);
This will write object into the current directory. By default, if you do
not specify a name, the object name is used. If you specify the parameter
name, this will be the name of the key.
> > 4, FindObjectAny(): How can I
find an object in TFile containing a > complicated
> hierarchy of TDirectories? It would be great to have a recursive method
> analogous to "TFolder::FindObjectAny()".
I will implement FindObjectAny. This was not implemented because in case
of a complex directory structure, this call will force reading all
directory keys in memory. But, I agree that there are more advantages
than disadvantages in implementing FindObjectAny.
>
> 5, EncodeNameCycle(): Since every TObject can be stored in TFile, would
> it
> be possible to move the methods Encode/DecodeNameCycle() to TObject?
Why do you need this ?
See object->Write
>
> 6, Shortcut/Alias: A nice feature of TFolder is that one folder can be
> added to different folders. It would be great if this could also be done
>
> with TDirectory, e.g. as shortcut or alias as known from other file
> systems.
> Sorrowly, creating a reference TRef does not help, since TBrowser is not
>
> able to recognize it as alias to TDirectory.
Unix-like links are not implemented in TDirectory. This could be added
to the current TKey or a new class TKeyLink implemented.
Rene Brun.
>
> Thank you for your help.
>
> 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