#ifndef ROOT_TFileIter
#define ROOT_TFileIter
#ifndef ROOT_TString
#include "TString.h"
#endif
#ifndef ROOT_TIterator
#include "TIterator.h"
#endif
#ifndef ROOT_TList
#include "TList.h"
#endif
#ifndef ROOT_TFile
#include "TFile.h"
#endif
class TFileIter : public TListIter {
private:
TFile *fFileBackUp;
TDirectory *fDirectoryBackUp;
TFileIter *fNestedIterator;
virtual TIterator &operator=(const TIterator &) { return *this; }
virtual bool operator!=(const TIterator &it) const { return TListIter::operator!=(it);}
protected:
TDirectory *fRootFile;
TString fEventName;
UInt_t fRunNumber;
UInt_t fEventNumber;
Int_t fCursorPosition;
Bool_t fOwnTFile;
void Initialize();
TObject *ReadObj(const TKey *key) const;
void RestoreFileScope();
void SaveFileScope();
TKey *NextEventKey(UInt_t eventNumber=UInt_t(-1), UInt_t runNumber=UInt_t(-1), const char *name="*");
public:
TFileIter(const char *name, Option_t *option = "",
const char *ftitle = "", Int_t compress = 1,
Int_t netopt = 0);
TFileIter(TFile *file=0);
TFileIter(TDirectory *directory);
TFileIter(const TFileIter &);
virtual ~TFileIter();
Int_t CurrentCursorPosition() const;
virtual const TFile *GetTFile() const;
virtual const TDirectory *GetTDirectory() const;
static TString MapName(const char *name, const char *localSystemKey = 0
, const char *mountedFileSystemKey = 0);
static const char *GetResourceName();
static const char *GetDefaultMapFileName();
static const char *GetLocalFileNameKey();
static const char *GetForeignFileSystemKey();
static void PurgeKeys(TList *listOfKeys);
virtual Bool_t IsOpen() const;
virtual TObject *NextEventGet(UInt_t eventNumber=UInt_t(-1), UInt_t runNumber=UInt_t(-1), const char *name="*");
virtual Int_t NextEventPut(TObject *obj, UInt_t eventNum, UInt_t runNumber, const char *name=0);
void SetCursorPosition(Int_t cursorPosition);
void SetCursorPosition(const char *keyNameToFind);
Int_t GetObjlen() const;
virtual Int_t TotalKeys() const;
virtual TKey *SkipObjects(Int_t nSkip=1);
virtual TObject *GetObject() const;
virtual Int_t GetDepth() const;
TKey *GetCurrentKey() const;
const char *GetKeyName() const;
TFileIter &operator=(Int_t cursorPosition);
TFileIter &operator=(const char *keyNameToFind);
TFileIter &operator+=(Int_t shift);
TFileIter &operator-=(Int_t shift);
TFileIter &operator++();
TFileIter &operator--();
TObject *operator*() const;
operator const char *() const;
operator const TFile *() const;
operator const TDirectory *() const;
operator int () const;
int operator==(const char *name) const;
int operator!=(const char *name) const;
public:
virtual TObject *Next();
virtual TObject *Next(Int_t nSkip);
virtual void Reset();
virtual void Rewind();
TObject *operator()(Int_t nSkip);
TObject *operator()();
ClassDef(TFileIter,0)
};
inline const char *TFileIter::GetResourceName() {return "ForeignFileMap";}
inline const char *TFileIter::GetDefaultMapFileName() {return "io.config";}
inline const char *TFileIter::GetLocalFileNameKey() {return "LocalFileSystem";}
inline const char *TFileIter::GetForeignFileSystemKey(){return "MountedFileSystem";}
inline Int_t TFileIter::CurrentCursorPosition() const
{
return fNestedIterator ? fNestedIterator->CurrentCursorPosition() : fCursorPosition;
}
inline const TFile *TFileIter::GetTFile() const { return GetTDirectory()->GetFile(); }
inline const TDirectory *TFileIter::GetTDirectory() const
{ return fNestedIterator ? fNestedIterator->GetTDirectory() : fRootFile; }
inline TObject *TFileIter::Next()
{
return Next(1);
}
inline void TFileIter::Rewind()
{
Reset();
}
inline void TFileIter::SetCursorPosition(Int_t cursorPosition)
{
if (fNestedIterator)
fNestedIterator->SetCursorPosition(cursorPosition);
else
SkipObjects(cursorPosition - fCursorPosition);
}
inline TFileIter &TFileIter::operator=(const char *keyNameToFind)
{
SetCursorPosition(keyNameToFind); return *this;}
inline TFileIter &TFileIter::operator=(Int_t cursorPosition)
{
SetCursorPosition(cursorPosition);
return *this;
}
inline TFileIter::operator const TDirectory *() const
{ return GetTDirectory(); }
inline TFileIter::operator const TFile *() const
{ return GetTFile (); }
inline TFileIter &TFileIter::operator+=(Int_t shift)
{ SkipObjects(shift); return *this;}
inline TFileIter &TFileIter::operator-=(Int_t shift)
{ return operator+=(-shift);}
inline TFileIter &TFileIter::operator++()
{ SkipObjects( 1); return *this;}
inline TFileIter &TFileIter::operator--()
{ SkipObjects(-1); return *this;}
inline TObject *TFileIter::operator*() const
{ return GetObject();}
inline TFileIter::operator int () const
{ return CurrentCursorPosition(); }
inline TFileIter::operator const char *() const
{
return GetKeyName();
}
inline int TFileIter::operator==(const char *name) const
{ return name ? !strcmp(name,GetKeyName()):0;}
inline int TFileIter::operator!=(const char *name) const
{ return !(operator==(name)); }
inline TObject *TFileIter::operator()(){ return Next(); }
inline TObject *TFileIter::operator()(Int_t nSkip){ return Next(nSkip);}
inline void TFileIter::SaveFileScope()
{ fFileBackUp = gFile; fDirectoryBackUp = gDirectory; }
inline void TFileIter::RestoreFileScope()
{ gFile = fFileBackUp; gDirectory = fDirectoryBackUp; }
#endif