library: libTable
#include "TFileIter.h"

TFileIter


class description - header file - source file - inheritance tree (.pdf)

class TFileIter : public TListIter

Inheritance Chart:
TIterator
<-
TListIter
<-
TFileIter
    private:
virtual TIterator& operator=(const TIterator&) protected:
void Initialize() TKey* NextEventKey(UInt_t eventNumber = UInt_t(-1), UInt_t runNumber = UInt_t(-1), const char* name = "*") TObject* ReadObj(const TKey* key) const void RestoreFileScope() void SaveFileScope() public:
TFileIter(const char* name, Option_t* option = "", const char* ftitle = "", Int_t compress = 1, Int_t netopt = 0) TFileIter(TFile* file = 0) TFileIter(const TFileIter&) virtual ~TFileIter() static TClass* Class() Int_t CurrentCursorPosition() const TKey* GetCurrentKey() const static const char* GetDefaultMapFileName() static const char* GetForeignFileSystemKey() const char* GetKeyName() const static const char* GetLocalFileNameKey() virtual TObject* GetObject() const Int_t GetObjlen() const static const char* GetResourceName() virtual const TFile* GetTFile() const virtual TClass* IsA() const static TString MapName(const char* name, const char* localSystemKey = "0", const char* mountedFileSystemKey = "0") virtual TObject* Next() virtual TObject* Next(Int_t nSkip) 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") char* operator const char*() const TFile* operator const TFile*() const int operator int() const int operator!=(const char* name) const TObject* operator()(Int_t nSkip) TObject* operator()() TObject* operator*() const TFileIter& operator++() TFileIter& operator+=(Int_t shift) TFileIter& operator--() TFileIter& operator-=(Int_t shift) TFileIter& operator=(Int_t cursorPosition) TFileIter& operator=(const char* keyNameToFind) int operator==(const char* name) const virtual void Reset() virtual void Rewind() void SetCursorPosition(Int_t cursorPosition) void SetCursorPosition(const char* keyNameToFind) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual TObject* SkipObjects(Int_t nSkip = 1) virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b) virtual Int_t TotalKeys() const

Data Members

    private:
TFile* fFileBackUp ! temporary data-members TDirectory* fDirectoryBackUp ! to save/restore TFile/TDirectory global scope protected:
TFile* fRootFile Tfile to be iterated over TString fEventName current key name UInt_t fRunNumber current "run number" UInt_t fEventNumber current "event number" Int_t fCursorPosition the position of the current key in the sorted TKey list Bool_t fOwnTFile Bit whether this classs creates TFile on its own to delete

Class Description

                                                                       
 Class to iterate (read / write ) the events written to TFile.         
 The event is supposed to assign an unique ID in form of               
                                                                       
  TKey <event Id> ::= eventName "." run_number "." event_number        
                                                                       
 and stored as the TKey name of the object written                     
                                                                       
        ///////        //////////      ////////        ///////     

 void TestFileIter(){
 // This macros tests the various methods of TFileIter class.
   gSystem->Load("libTable");

   //First create simple ROOT file
   TDataSet *ds = new TDataSet("event");
   TObject *nextObject = 0;
   TRandom run;
   TRandom event;
   {
     TFileIter outSet("test.root","RECREATE");
     UInt_t totalEvent = 10;
     UInt_t runNumber  = 20010301;
     Int_t i=0;
     Int_t j=0;
     for (;j < 10;j++) {
       for (i = 1;i<totalEvent;i++) {
         outSet.NextEventPut(ds,UInt_t(i),UInt_t(runNumber+j+10*run.Rndm()-5));
       }
     }
   }
   printf(" ----------------------> TFile has been created <--------------------\n");
   TFile *f = new TFile("test.root");
   TFileIter readObj(f);
   // the number of the object available directly from "MyDataSet.root"
   Int_t size = readObj.TotalKeys();
   printf(" The total number of the objects: %d\n",size);

   //-----------------------------------------------------------------------
   // Loop over all objects, read them in to memory one by one

   printf(" -- > Loop over all objects, read them in to memory one by one < -- \n");
   for( readObj = 0; int(readObj) < size; ++readObj){
       nextObject = *readObj;
       printf(" %d bytes of the object \"%s\" of class \"%s\" written with TKey \"%s\"  has been read from file\n"
                ,readObj.GetObjlen()
                ,nextObject->GetName()
                ,nextObject->IsA()->GetName()
                ,(const char *)readObj
             );
       delete nextObject;
  }
 //-----------------------------------------------------------------------
 //  Now loop over all objects in inverse order
  printf(" -- > Now loop over all objects in inverse order < -- \n");
  for( readObj = size-1; (int)readObj >= 0; --readObj)
  {
       nextObject = *readObj;
       if (nextObject) {
          printf(" Object \"%s\" of class \"%s\" written with TKey \"%s\"  has been read from file\n"
                 ,nextObject->GetName()
                 , nextObject->IsA()->GetName()
                 ,(const char *)readObj
                );
         delete nextObject;
      } else {
        printf("Error reading file by index\n");
      }
  }
 //-----------------------------------------------------------------------
 // Loop over the objects starting from the object with the key name "event.02.01"
   printf(" -- > Loop over the objects starting from the object with the key name \"event.02.01\" < -- \n");
   for( readObj = "event.02.01"; (const char *)readObj != 0; ++readObj){
       nextObject = *readObj;
       printf(" Object \"%s\" of class \"%s\" written with Tkey \"%s\"  has been read from file\n"
               , nextObject->GetName()
               , nextObject->IsA()->GetName()
               , (const char *)readObj
             );
       delete nextObject;
   }

   printf(" -- > Loop over the objects starting from the 86-th object" < -- \n");
   for( readObj = (const char *)(readObj = 86); (const char *)readObj != 0; ++readObj){
       nextObject = *readObj;
       printf(" Object \"%s\" of class \"%s\" written with Tkey \"%s\"  has been read from file\n"
               , nextObject->GetName()
               , nextObject->IsA()->GetName()
               , (const char *)readObj
             );
       delete nextObject;
   }

 }
-----------------------------------------------------------------------

TFileIter(TFile *file)
to be documented
TFileIter(const char *name, Option_t *option, const char *ftitle , Int_t compress, Int_t /*netopt*/)
{
 Open ROOT TFile by the name provided;
 This TFile is to be deleted by the TFileIter alone
if (name && name[0]) {
fOwnTFile = kTRUE;
 Map a special file system to rfio
   /hpss/in2p3.fr/group/atlas/cppm/data/genz
   #setenv HPSSIN bnlhpss:/home/atlasgen/evgen
 #example for castor:   /castor/cern.ch/user/p/paniccia/evgen
fRootFile = TFile::Open(MapName(name),option,ftitle,compress);
Initialize();
}
}

__________________________________________________________________________
TFileIter::TFileIter(const TFileIter &dst) : TListIter()
,fRootFile(dst.fRootFile)
,fEventName(dst.fEventName), fRunNumber(dst.fRunNumber)
,fEventNumber(dst.fRunNumber),
fCursorPosition(-1),  fOwnTFile(dst.fOwnTFile)
{
 Copy stor can be used with the "read only" files only.
~TFileIter()
to be documented
void Initialize()
to be documented
TKey * GetCurrentKey()
 return the pointer to the current TKey
const char * GetKeyName()
 return the name of the current TKey
TObject * GetObject()
 read the object from TFile defined by the current TKey

 ATTENTION:  memory leak danger !!!
 ---------
 This method does create a new object and it is the end-user
 code responsibility to take care about the object returned
 to avoid memeory leak.

Int_t GetObjlen()
 Returns the uncompressed length of the current object
Int_t TotalKeys()
 The total number of the TKey keys in this current TFile
 Usually this means the total number of different objects
 thos can be read separately with one "read" operation
TObject * Next(Int_t nSkip)
 return the pointer to the object defined by next TKey
 This method is not recommended. It was done for the sake
 of the compatibility with TListIter
void Reset()
 Reset the status of the iterator
void SetCursorPosition(const char *keyNameToFind)
 Find the key by the name provided
TObject * SkipObjects(Int_t nSkip)
 Returns the pointer to the nSkip object from the current one
 nSkip = 0; the state of the iterator is not changed

 nSkip > 0; iterator skips nSkip objects in the container.
            the direction of the iteration is
            sign(nSkip)*kIterForward

TKey * NextEventKey(UInt_t eventNumber, UInt_t runNumber, const char *name)
TObject * NextEventGet(UInt_t eventNumber, UInt_t runNumber, const char *name)
 reads, creates and returns the object by TKey name that matches
 the "name" ."runNumber" ." eventNumber" schema
 Attention: This method does create a new TObject and it is the user
 code responsibility to take care (delete) this object to avoid
 memory leak.
TObject * ReadObj(const TKey *key)
to be documented
Int_t NextEventPut(TObject *obj, UInt_t eventNum, UInt_t runNumber , const char *name)
 Create a special TKey name with obj provided and write it out.
TString MapName(const char *name, const char *localSystemKey,const char *mountedFileSystemKey)
 --------------------------------------------------------------------------------------
 MapName(const char *name, const char *localSystemKey,const char *mountedFileSystemKey)
 --------------------------------------------------------------------------------------
 Substitute the logical name with the real one if any
 1. add a line into system.rootrc or ~/.rootrc or ./.rootrc

  TFileIter.ForeignFileMap  mapFile // the name of the file
 to map the local name
 to the global file service

  If this line is omitted then TFileIter class seeks for
  the default mapping file in the current directory "io.config"
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
void RestoreFileScope()
void SaveFileScope()
TFileIter(const char *name, Option_t *option = "", const char *ftitle = "", Int_t compress = 1, Int_t netopt = 0)
Int_t CurrentCursorPosition()
 --- draft !!!     virtual Int_t Copy(TFile *destFile);
void SetCursorPosition(Int_t cursorPosition)
int operator==(const char *name)
int operator!=(const char *name)
void Rewind()
return Next(1)
 Make 1 step over the file objects and returns its pointer
 or 0, if there is no object left in the container

Author: Valery Fine(fine@bnl.gov) 01/03/2001
Last update: root/table:$Name: $:$Id: TFileIter.cxx,v 1.6 2006/05/21 18:05:26 brun Exp $
Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *


ROOT page - Class index - Class Hierarchy - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.