17 #include "TDirectory.h"
37 virtual Bool_t
GetObject(TObject* &obj, Bool_t &owner)
const
39 TClass* cl = gROOT->GetClass(
fKey->GetClassName());
40 if ((cl!=0) && !cl->IsLoaded()) {
48 obj =
fKey->ReadObj();
49 if (obj==0)
return kFALSE;
51 if (obj->InheritsFrom(TH1::Class()) || obj->InheritsFrom(TTree::Class())) owner = kFALSE;
else
52 if (obj->InheritsFrom(TCanvas::Class())) {
fDir->Add(obj); owner = kFALSE; }
57 {
return fKey->GetName(); }
60 {
return fKey->GetClassName(); }
82 fReadRight(readright),
88 fIter = fDir->GetListOfKeys()->MakeIterator();
94 if (fIter!=0)
delete fIter;
99 Bool_t donext = kTRUE;
103 fCurrent = fIter->Next();
108 fIter = fDir->GetList()->MakeIterator();
117 TKey* key = fDir->FindKey(fCurrent->GetName());
119 if (strcmp(fCurrent->ClassName(), key->GetClassName())==0) donext = kTRUE;
126 if (cl==0)
return kFALSE;
127 return cl->InheritsFrom(TDirectory::Class()) ||
128 cl->InheritsFrom(TTree::Class()) ||
129 cl->InheritsFrom(TCanvas::Class()) ||
130 cl->InheritsFrom(THStack::Class());
137 TKey* key = (TKey*) fCurrent;
138 TObject* obj = fDir->FindObject(key->GetName());
139 if (obj) cl = obj->IsA();
143 cl = fCurrent->IsA();
151 TObject* obj = fIsKeyIter ? fDir->Get(fCurrent->GetName()) : fCurrent;
153 if (obj==0)
return 0;
155 if (obj->InheritsFrom(TTree::Class()))
158 if (obj->InheritsFrom(TCanvas::Class()))
161 if (obj->InheritsFrom(THStack::Class()))
164 TDirectory* subdir =
dynamic_cast<TDirectory*
> (obj);
170 if (!fIsKeyIter)
return fCurrent->GetName();
171 TKey* key = (TKey*) fCurrent;
173 fNameBuf.Form(
"%s;%d",key->GetName(),(int) key->GetCycle());
174 return fNameBuf.Data();
179 return fCurrent->GetTitle();
187 TKey* key = (TKey*) fCurrent;
189 sz = key->GetNbytes();
190 TObject* obj = fDir->FindObject(key->GetName());
193 cl = fCurrent->IsA();
196 bool isdir = (cl!=0) && cl->InheritsFrom(TDirectory::Class());
197 return isdir ? 0 : sz;
204 if (fIsKeyIter && fReadRight) {
205 TKey* key = (TKey*) fCurrent;
207 if (cl==0) cl = gROOT->GetClass(key->GetClassName(), kTRUE, kTRUE);
216 return fIsKeyIter ? ((TKey*) fCurrent)->GetClassName() : fCurrent->ClassName();
238 SetDir(dir, readright, owner);
268 return fDir!=0 ?
fDir->ClassName() : 0;
273 return fDir!=0 ?
fDir->GetTitle() : 0;
278 TFile* f =
dynamic_cast<TFile*
> (
fDir);
284 if (dir==0)
return 0;
288 TDirectory* curdir = dir;
289 const char* curname = name;
291 while ((curdir!=0) && (curname!=0)) {
292 const char* slash = strchr(curname,
'/');
299 partname.Append(curname, slash - curname);
301 if (*curname==0) curname = 0;
305 Short_t cyclebuf(9999);
306 TDirectory::DecodeNameCycle(partname.Data(), namebuf, cyclebuf,
sizeof(namebuf));
308 TObject* obj = curdir->GetList()->FindObject(namebuf);
310 TKey* key = curdir->GetKey(namebuf, cyclebuf);
311 if (key==0)
return 0;
314 obj = curdir->Get(partname.Data());
315 if (obj && obj->InheritsFrom(TCanvas::Class())) curdir->Add(obj);
316 if (obj && browser_slot)
320 if (obj==0)
return 0;
322 TTree* tr =
dynamic_cast<TTree*
> (obj);
326 TCanvas* canv =
dynamic_cast<TCanvas*
> (obj);
330 THStack* hs =
dynamic_cast<THStack*
> (obj);
334 curdir =
dynamic_cast<TDirectory*
>(obj);
350 const char* filename = 0;
351 if ((
fDir!=0) &&
fDir->InheritsFrom(TFile::Class()))
352 filename =
fDir->GetName();
354 slot->
SetPar(
"DirProxy::FileName", filename);
355 slot->
SetPar(
"DirProxy::gROOT", (
fDir==gROOT) ?
"true" : 0);
363 const char* filename = slot->
GetPar(
"DirProxy::FileName");
364 const char* groot = slot->
GetPar(
"DirProxy::gROOT");
367 TFile* f = TFile::Open(filename);
368 if (f!=0)
SetDir(f, kTRUE, kTRUE);
371 SetDir(gROOT, kFALSE, kFALSE);
376 if ((filepath==0) || (
fDir==0))
return kFALSE;
378 TFile* f =
dynamic_cast<TFile*
> (
fDir);
379 if (f==0)
return kFALSE;
381 if (f->ReOpen(
"UPDATE")<0)
return kFALSE;
383 TString foldername, objname;
386 TDirectory* objdir = f;
388 if (foldername.Length()>0) {
389 objdir =
dynamic_cast<TDirectory*
> (f->Get(foldername));
394 TDirectory::DecodeNameCycle(objname.Data(), namebuf, cyclebuf,
sizeof(namebuf));
398 objdir->Delete(objname.Data());
399 objdir->WriteTObject(obj, namebuf,
"Overwrite");
409 return dynamic_cast<TFile*
>(
fDir)!=0;
virtual TGo4LevelIter * subiterator()
static TClass * GetClass(const char *classname, Bool_t load=kFALSE)
TGo4KeyAccess(TDirectory *dir, TKey *key)
virtual Int_t GetObjectSizeInfo()
virtual Bool_t CanGetObject() const
static TGo4LevelIter * ProduceIter(TTree *tree)
virtual void ReadData(TGo4Slot *slot, TDirectory *dir)
virtual Bool_t GetObject(TObject *&obj, Bool_t &owner) const
static TGo4LevelIter * ProduceIter(THStack *canv)
static TGo4Access * CreateAccess(TCanvas *canv, const char *name)
const char * GetPar(const char *name) const
virtual const char * GetContainedClassName()
static Long_t DefineObjectSize(TObject *obj)
static TGo4LevelIter * ProduceIter(TCanvas *canv)
static TGo4LevelIter * ProduceIter(TDirectory *dir, Bool_t readright)
virtual Int_t GetObjectKind()
virtual const char * info()
virtual Bool_t isfolder()
Bool_t UpdateObjectInFile(const char *filepath, TObject *obj)
const char * GetFileName() const
virtual const char * GetObjectClassName() const
virtual const char * name()
static TGo4Access * CreateAccess(THStack *canv, const char *name)
virtual const char * GetObjectName() const
static void ProduceFolderAndName(const char *fullname, TString &foldername, TString &objectname)
void ForwardEvent(TGo4Slot *source, Int_t id, void *param=0)
virtual ~TGo4DirLevelIter()
virtual Int_t GetObjectSizeInfo()
static TGo4Access * CreateAccess(TTree *tree, const char *name)
TGo4DirLevelIter(TDirectory *dir, Bool_t readright)
void SetDir(TDirectory *dir, Bool_t readright, Bool_t owner)
Bool_t IsContainerClass(TClass *cl)
void SetPar(const char *name, const char *value)
virtual const char * GetContainedObjectInfo()
virtual const char * GetClassName()
virtual void WriteData(TGo4Slot *slot, TDirectory *dir, Bool_t onlyobjs)
static TGo4Access * CreateAccess(TDirectory *dir, Bool_t readright, const char *name, TGo4Slot *browser_slot=0)