IoRerootStreamItr Class Reference

#include <IoRerootStreamItr.h>

Inheritance diagram for IoRerootStreamItr:
IoDataStreamItr

List of all members.

Classes

struct  Cleaner

Public Member Functions

 IoRerootStreamItr (const char *sourceName="")
virtual ~IoRerootStreamItr ()
bool IsValid () const
const char * GetFormat () const
int LoadRecords (MomNavigator *mom)
int Increment (int n=1, MomNavigator *m=0)
int Decrement (int n=1, MomNavigator *m=0)
JobCResult GoTo (const VldContext &vld, MomNavigator *m=0)
int GoToEOF ()

Private Member Functions

bool IsOpenFile () const
JobCResult OpenFile ()
void CloseFile ()

Private Attributes

long int fIndex
long int fBOFIndex
long int fEOFIndex
bool fIsValid

Detailed Description

Definition at line 18 of file IoRerootStreamItr.h.


Constructor & Destructor Documentation

IoRerootStreamItr::IoRerootStreamItr ( const char *  sourceName = ""  ) 

Definition at line 18 of file IoRerootStreamItr.cxx.

References gMINFast, IoDataStreamItr::SetSourceName(), and IoRerootStreamItr::Cleaner::UseMe().

00018                                                            : fIndex(-1),
00019                            fBOFIndex(-1),fEOFIndex(-1),fIsValid(true)
00020 {
00021   // Need to setup the MINFAST environment to work with reroot data
00022   if (gMINFast == 0) {
00023     // Create a MINFAST object w/o the display
00024     gMINFast = new MINFast("gMinFast","MINFAST",kFALSE,"");
00025     static IoRerootStreamItr::Cleaner c; c.UseMe();
00026     assert(gMINFast);
00027   }
00028   this -> SetSourceName(sourceName);
00029 
00030 }

IoRerootStreamItr::~IoRerootStreamItr (  )  [virtual]

Definition at line 34 of file IoRerootStreamItr.cxx.

References CloseFile().

00035 {
00036   this->CloseFile();
00037 }


Member Function Documentation

void IoRerootStreamItr::CloseFile (  )  [private, virtual]

Reimplemented from IoDataStreamItr.

Definition at line 138 of file IoRerootStreamItr.cxx.

References IoDataStreamItr::SetSourceName().

Referenced by ~IoRerootStreamItr().

00138                                   {
00139   // Handled automatically by gMINFast
00140   this -> SetSourceName("");
00141   return;
00142 }

int IoRerootStreamItr::Decrement ( int  n = 1,
MomNavigator m = 0 
) [virtual]

Implements IoDataStreamItr.

Definition at line 73 of file IoRerootStreamItr.cxx.

References fBOFIndex, fIndex, IsOpenFile(), and LoadRecords().

00074 {
00075 //======================================================================
00076 // Back up n positions in the stream.
00077 //======================================================================
00078   if (!IsOpenFile() || n<=0) return 0;
00079 
00080   // Case where requested advance steps past start of file
00081   if ((fIndex - n) <= fBOFIndex) {
00082     int isave = fIndex;
00083     fIndex = fBOFIndex;
00084     if (m) this->LoadRecords(m);
00085     return (isave-fBOFIndex-1);
00086   }
00087 
00088   // Normal case
00089   fIndex -= n;
00090   if (m) this->LoadRecords(m);
00091   return n;
00092 }

const char* IoRerootStreamItr::GetFormat (  )  const [inline, virtual]

Implements IoDataStreamItr.

Definition at line 25 of file IoRerootStreamItr.h.

00025 { return "reroot"; }

JobCResult IoRerootStreamItr::GoTo ( const VldContext vld,
MomNavigator m = 0 
) [virtual]

Implements IoDataStreamItr.

Definition at line 96 of file IoRerootStreamItr.cxx.

References JobCResult::kWarning, Msg::kWarning, LoadRecords(), and MSG.

00097 {
00098 //======================================================================
00099 // Go to record set with specified validity context -- for reroot I
00100 // don't know what this means...
00101 //======================================================================
00102   MSG("Io",Msg::kWarning) << 
00103     "GoTo(" << vld << ") not supported for REROOT data.\n";
00104   if (m) this->LoadRecords(m);
00105   return JobCResult::kWarning;
00106 }

int IoRerootStreamItr::GoToEOF (  )  [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 110 of file IoRerootStreamItr.cxx.

References fEOFIndex, and fIndex.

00110 { fIndex = fEOFIndex; return 1;}

int IoRerootStreamItr::Increment ( int  n = 1,
MomNavigator m = 0 
) [virtual]

Implements IoDataStreamItr.

Definition at line 52 of file IoRerootStreamItr.cxx.

References fEOFIndex, fIndex, IsOpenFile(), and LoadRecords().

00053 {
00054 
00055   if (!IsOpenFile() || n<=0) return 0;
00056 
00057   // Case where requested advance steps past start of file
00058   if ((fIndex + n) >= fEOFIndex) {
00059     int isave = fIndex;
00060     fIndex = fEOFIndex;
00061     if (m) this->LoadRecords(m);
00062     return (fEOFIndex-isave-1);
00063   }
00064 
00065   // Normal case
00066   fIndex += n;
00067   if (m) this->LoadRecords(m);
00068   return n;
00069 }

bool IoRerootStreamItr::IsOpenFile (  )  const [private]

Definition at line 144 of file IoRerootStreamItr.cxx.

References MINFast::GetMINFile(), MINFile::Getnevts(), and gMINFast.

Referenced by Decrement(), Increment(), LoadRecords(), and OpenFile().

00144                                          {
00145   bool isOpen = true;
00146   if (gMINFast->GetMINFile()==0 || 
00147       gMINFast->GetMINFile()->Getnevts() ==0) isOpen = false;
00148   return isOpen;
00149 }

bool IoRerootStreamItr::IsValid (  )  const [inline, virtual]

Implements IoDataStreamItr.

Definition at line 24 of file IoRerootStreamItr.h.

References fIsValid.

00024 { return fIsValid; }

int IoRerootStreamItr::LoadRecords ( MomNavigator mom  )  [virtual]

Implements IoDataStreamItr.

Definition at line 41 of file IoRerootStreamItr.cxx.

References fEOFIndex, fIndex, MINFast::GetEvent(), gMINFast, IsOpenFile(), Msg::kDebug, and MSG.

Referenced by Decrement(), GoTo(), and Increment().

00042 {
00043   if (!IsOpenFile() || fIndex<0 || fIndex>=fEOFIndex) return 0;
00044   MSG("Io",Msg::kDebug) << "IoRerootStreamItr::LoadRecord at index " 
00045                         << fIndex << endl;
00046   if (gMINFast->GetEvent(fIndex)) return 1;
00047   return 0;
00048 }

JobCResult IoRerootStreamItr::OpenFile (  )  [private, virtual]

Reimplemented from IoDataStreamItr.

Definition at line 114 of file IoRerootStreamItr.cxx.

References fBOFIndex, fEOFIndex, fIndex, IoDataStreamItr::GetCurrentFile(), MINFast::GetMINFile(), MINFile::Getnevts(), gMINFast, IsOpenFile(), JobCResult::kAOK, JobCResult::kWarning, MINFast::OpenRerootFile(), and IoDataStreamItr::SetSourceName().

00115 {
00116 //======================================================================
00117 // Open the file attached to current file iterator
00118 //======================================================================
00119   std::string fullfilepathname = this -> GetCurrentFile();
00120   if ( fullfilepathname == "" ) return JobCResult::kWarning;
00121   this -> SetSourceName(fullfilepathname.c_str());
00122 
00123   gMINFast->OpenRerootFile(fullfilepathname.c_str());
00124   
00125   // Test if this is a valid file
00126   if ( !IsOpenFile() ) return JobCResult::kWarning;
00127   
00128   // Set up the indicies
00129   fBOFIndex = -1;
00130   fEOFIndex = gMINFast->GetMINFile()->Getnevts();
00131   fIndex    = fBOFIndex;
00132 
00133   return JobCResult::kAOK;
00134 }


Member Data Documentation

long int IoRerootStreamItr::fBOFIndex [private]

Definition at line 47 of file IoRerootStreamItr.h.

Referenced by Decrement(), and OpenFile().

long int IoRerootStreamItr::fEOFIndex [private]

Definition at line 48 of file IoRerootStreamItr.h.

Referenced by GoToEOF(), Increment(), LoadRecords(), and OpenFile().

long int IoRerootStreamItr::fIndex [private]

Definition at line 46 of file IoRerootStreamItr.h.

Referenced by Decrement(), GoToEOF(), Increment(), LoadRecords(), and OpenFile().

Definition at line 49 of file IoRerootStreamItr.h.

Referenced by IsValid().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1