13 #ifndef ROOT_StFileIter
14 #define ROOT_StFileIter
50 #ifndef ROOT_TIterator
51 #include "TIterator.h"
66 TDirectory *fDirectoryBackUp;
69 bool operator!=(
const TIterator&)
const{
return true;}
70 TIterator& operator=(
const TIterator&){
return *
this;}
73 TDirectory *fRootFile;
77 Int_t fCursorPosition;
81 TObject *ReadObj(
const TKey *key)
const;
82 void RestoreFileScope();
87 StFileIter(
const char *name, Option_t *option =
"",
88 const char *ftitle =
"", Int_t compress = 1,
95 Int_t CurrentCursorPosition()
const;
96 virtual const TFile *GetTFile()
const;
97 virtual const TDirectory *GetTDirectory()
const;
98 static TString MapName(
const char *name,
const char *localSystemKey = 0
99 ,
const char *mountedFileSystemKey = 0);
100 static const char *GetResourceName();
101 static const char *GetDefaultMapFileName();
102 static const char *GetLocalFileNameKey();
103 static const char *GetForeignFileSystemKey();
104 static void PurgeKeys(TList *listOfKeys);
105 virtual Bool_t IsOpen()
const;
106 virtual TObject *NextEventGet(UInt_t eventNumber=UInt_t(-1), UInt_t runNumber=UInt_t(-1),
const char *name=
"*");
107 virtual Int_t NextEventPut(TObject *obj, UInt_t eventNum, UInt_t runNumber,
const char *name=0);
108 TKey *NextEventKey(UInt_t eventNumber=UInt_t(-1), UInt_t runNumber=UInt_t(-1),
const char *name=
"*");
109 void SetCursorPosition(Int_t cursorPosition);
110 void SetCursorPosition(
const char *keyNameToFind);
111 Int_t GetObjlen()
const;
112 virtual Int_t TotalKeys()
const;
113 virtual TKey *SkipObjects(Int_t nSkip=1);
114 virtual TObject *GetObject()
const;
115 virtual Int_t GetDepth()
const;
117 TKey *GetCurrentKey()
const;
118 const char *GetKeyName()
const;
121 StFileIter &operator=(
const char *keyNameToFind);
127 TObject *operator*()
const;
128 operator const char *()
const;
129 operator const TFile *()
const;
130 operator const TDirectory *()
const;
131 operator int ()
const;
132 int operator==(
const char *name)
const;
133 int operator!=(
const char *name)
const;
137 virtual TObject *Next();
138 virtual TObject *Next(Int_t nSkip);
139 virtual void Reset();
140 virtual void Rewind();
141 TObject *operator()(Int_t nSkip);
142 TObject *operator()();
148 inline const char *StFileIter::GetResourceName() {
return "ForeignFileMap";}
150 inline const char *StFileIter::GetDefaultMapFileName() {
return "io.config";}
152 inline const char *StFileIter::GetLocalFileNameKey() {
return "LocalFileSystem";}
154 inline const char *StFileIter::GetForeignFileSystemKey(){
return "MountedFileSystem";}
157 inline Int_t StFileIter::CurrentCursorPosition()
const
160 return fNestedIterator ? fNestedIterator->CurrentCursorPosition() : fCursorPosition;
164 inline const TFile *StFileIter::GetTFile()
const {
return GetTDirectory()->GetFile(); }
166 inline const TDirectory *StFileIter::GetTDirectory()
const
167 {
return fNestedIterator ? fNestedIterator->GetTDirectory() : fRootFile; }
170 inline TObject *StFileIter::Next()
178 inline void StFileIter::Rewind()
184 inline void StFileIter::SetCursorPosition(Int_t cursorPosition)
189 fNestedIterator->SetCursorPosition(cursorPosition);
191 SkipObjects(cursorPosition - fCursorPosition);
195 inline StFileIter &StFileIter::operator=(
const char *keyNameToFind)
198 SetCursorPosition(keyNameToFind);
return *
this;}
201 inline StFileIter &StFileIter::operator=(Int_t cursorPosition)
204 SetCursorPosition(cursorPosition);
208 inline StFileIter::operator
const TDirectory *()
const
209 {
return GetTDirectory(); }
212 inline StFileIter::operator
const TFile *()
const
213 {
return GetTFile (); }
215 inline StFileIter &StFileIter::operator+=(Int_t shift)
216 { SkipObjects(shift);
return *
this;}
218 inline StFileIter &StFileIter::operator-=(Int_t shift)
219 {
return operator+=(-shift);}
222 { SkipObjects( 1);
return *
this;}
225 { SkipObjects(-1);
return *
this;}
227 inline TObject *StFileIter::operator*()
const
228 {
return GetObject();}
230 inline StFileIter::operator int ()
const
231 {
return CurrentCursorPosition(); }
233 inline StFileIter::operator
const char *()
const
239 inline int StFileIter::operator==(
const char *name)
const
240 {
return name ? !strcmp(name,GetKeyName()):0;}
243 inline int StFileIter::operator!=(
const char *name)
const
244 {
return !(operator==(name)); }
247 inline TObject *StFileIter::operator()(){
return Next(); }
249 inline TObject *StFileIter::operator()(Int_t nSkip){
return Next(nSkip);}
252 inline void StFileIter::SaveFileScope()
253 { fFileBackUp = gFile; fDirectoryBackUp = gDirectory; }
256 inline void StFileIter::RestoreFileScope()
258 gDirectory = fDirectoryBackUp; }