// -*- mode: c++ -*- // // $Id: BrIOModule.h,v 1.5 2001/12/14 15:35:55 cholm Exp $ // /////////////////////////////////////////////////////////////////////// // // // BrIOModule // // // // BRAHMS Analysis Module Class // // // // A standard IO should be derived from // // this base class. This ensure that the general framewor // // is capable of accessing these in a common and general // // The methods (member functions) consists of a general set // // all modules; but the user if free to add specific ones for // // specific needs. // // The initial version is derived from the ROOT base classes, // // the class share many traits with the BrModule Class but has // // a different set of member functions. // // // // Author : Flemming Videbaek // // Created: 3/17/98 // // Version: 1.0 // // // // // /////////////////////////////////////////////////////////////////////// #ifndef BRAT_BrIOModule #define BRAT_BrIOModule #ifndef ROOT_TObjArray #include "TObjArray.h" #endif #ifndef ROOT_TStopwatch #include "TStopwatch.h" #endif #ifndef BRAT_BrModule #include "BrModule.h" #endif #ifndef BRAT_BrEvent #include "BrEvent.h" #endif #define BR_IO_JOB_BIT 1 #define BR_IO_RUN_BIT 2 #define BR_IO_READ_BIT 3 #define BR_IO_WRITE_BIT 4 #define BR_IO_RECREATE_BIT 5 #define BR_IO_UPDATE_BIT 6 #define BR_IO_EVENT_BIT 7 class BrIOModule : public BrModule { public: // File modes static const UInt_t kBrJobFile; //! For files that's opened @ job-lvl static const UInt_t kBrRunFile; //! For files that's opened @ run-lvl static const UInt_t kBrEventFile; //! For files that's opened @ event-lvl static const UInt_t kBrReadFile; //! For read-only files static const UInt_t kBrWriteFile; //! For write-only (new) files static const UInt_t kBrRecreateFile; //! For write-only (overwrite) files static const UInt_t kBrUpdateFile; //! For write-only (append) files // CTORs and DTOR BrIOModule(); BrIOModule(const Char_t *name, const Char_t *title); virtual ~BrIOModule(); // Abstract methods to be overloaded virtual Bool_t Open(const Char_t*, const Option_t* option=0) = 0; virtual Bool_t Close() = 0; virtual void Event(BrEvent* event) = 0; // Regular module methods virtual void Init(); virtual void Begin(); virtual void Event(BrEventNode* input, BrEventNode* output); virtual void End(); virtual void Finish(); virtual void Print(Option_t* option="B") const; //*MENU* // Setup methods virtual void SetIOMode(UInt_t mode = kBrJobFile | kBrRecreateFile); virtual void AddFile(const Char_t* filename); virtual void AddFileSet(TObjArray* fileSet); virtual void AddFileSet(const Char_t* dirname, const Char_t* regexp); // Information methods virtual UInt_t GetIOMode() const { return fIOMode; } Int_t GetIOStatus() const { return fIOStatus; } Int_t GetBytesRead() const { return fNumBytesRead; } Int_t GetBytesWritten() const { return fNumBytesWritten; } const Char_t* GetFileName() const { return fFileName; } Int_t GetNoFiles() const { return fNoFiles; } Int_t GetNoFilesRead() const { return fNoFilesRead; } // Bool_t Eof() const { return fEof; } Bool_t IsEof() const { return fEof; } // Bool_t Error() const { return fError; } Bool_t IsError() const { return fError; } protected: virtual void OpenNext(); UInt_t fIOMode; //! Mode of this module TString fFileName; //! Current InputFileName Int_t fIOStatus; //! Status of Module Action Bool_t fError; //! Error - result of transaction Bool_t fEof; //! EndOfFile / EndOfData indicator Bool_t fNewFile; //! NewFile Long_t fNumBytesWritten; //! Number of bytes written Long_t fNumBytesRead; //! Number of bytes read Int_t fDebugLevel; //! Level for amount of debug information // output during execution of the module entries. The application // programmer should use the member functions DebugLevel() for // decision to output information Int_t fVerbose; //! Option flag TObjArray fFileList; //! List of File (sets) to read/write. Int_t fNoFiles; //! Number of files to read. Int_t fNoFilesRead; //! Number of files opened so far. TIter* fNextSet; //! Iterator for file set list TIter* fNextFile; //! Iteraror for file list public: ClassDef(BrIOModule,0) // BRAHMS IO Module definitions }; #endif // $Log: BrIOModule.h,v $ // Revision 1.5 2001/12/14 15:35:55 cholm // Introduced the concept of file sets. This allows a tighter coupling // between DAQ runs and sequences to Run and Job levels in BRAT. It's // documented in 'The Guide' ass well as in the class documentation. // Basically I added the methods // AddFileSet(const TObjArray*) // AddfileSet(const Char_t*, const Char_t*) // and redefined the methods // Init, Begin, Event, End, FInish, and AddFile. // // Revision 1.4 2001/08/21 16:08:32 cholm // Made ctor take const char*'s // // Revision 1.3 2001/06/25 14:57:19 cholm // Preliminary work on better file handling // // Revision 1.2 2001/06/22 11:11:12 cholm // Decrememted version nubmer to 0, since this class should not be // persistent. // // Revision 1.1.1.1 2001/06/21 14:55:04 hagel // Initial revision of brat2 // // Revision 1.18 2001/03/12 18:46:19 cholm // Fixed a few mistakes. Added a hack to histogram module, to make // sure it's file is closed as the very last thing in Finish. // // Revision 1.17 2001/03/07 12:15:23 cholm // * Defined standard BrModule methods in BrIOModule. // * Add the (simple) class BrHistIOModule. // * BrAppOptionManager and BrAppOption classes changed to not use // BrExceptions. // * Added the method Int_t BrMainModule::Main() to do EVERYTHING. // * Made the method BrModule::Info() const obsolete in favour of // BrModule::Print(Option_t* option="B") const. Impact on other classes. // // Revision 1.16 2001/01/23 16:31:51 cholm // Hack to make rootcint (CINT) ignore variadic arguments in BrException // classes. // // Revision 1.15 2001/01/22 19:57:27 cholm // Corrected const-ness of BrAppOption::Compare for old ROOT versions. // Fixed BrModule::Streamer to work with new ROOT. Changed the avaliable // module status values to kStop, kFailure, kAbort, and updated // BrModuleContainer and BrModule accordingly. Also renamed BrIOModule::fStatus // to BrIOModule::fIOStatus. // // Revision 1.14 2000/06/28 09:03:00 hagel // Added const to various char's in BrEventIO + BrIOMOdule // // Revision 1.13 2000/06/15 14:17:00 alv // Made more of the Get-methods const member functions // // Revision 1.12 2000/06/03 22:19:36 videbaek // Changed a constt char-> char // // Revision 1.11 2000/06/03 18:17:03 videbaek // Changed inheritance of BrIOModule. Added utility to BrDataObject.. See Update message for more info // // Revision 1.10 2000/04/06 20:17:11 cholm // Added the classes BrAppOption, BrAppOptionManager, and // BrDetectorList. The first two are for command line processing, // the third for easy detector list, can be used for many purposes // // Revision 1.9 1999/10/22 18:32:54 videbaek // Added code for getting bytes read written properly. // Now all in base Class BrIOModule // // Revision 1.8 1999/01/21 23:23:19 hagel // 1. Changed convention for checking includes. Current convention is: // BRAT_Br...... eg BRAT_BrModule ala ROOT. // 2. Added CVS logs to .h files that didn't have them. // 3. Moved checking of include definition to first line for easier reading // 4. Put checks before all includes in the include files as per BRAT specifications // 5. Added BrGeantHeader to Geant Makefile // 6. All changes have been checked to compile on NT ala Cygnus // // Revision 1.7 1999/01/15 15:32:13 videbaek // Updates to volume files. // Added member histon to BrModule, and member function HistOn(). // Added BrMath as standard math library. // // Revision 1.6 1998/12/01 21:20:09 videbaek // Added refs in Detector volume to deal with BrVector3D // rather than only float* references. // // Revision 1.5 1998/09/16 20:03:07 alv // Removed unused Name in definition of Open. // //