00001 // 00002 // TMidasFile.h. 00003 // 00004 00005 #ifndef TMIDASFILE_H 00006 #define TMIDASFILE_H 00007 00008 #include <string> 00009 00010 class TMidasEvent; 00011 00012 /// Reader for MIDAS .mid files 00013 00014 class TMidasFile 00015 { 00016 public: 00017 TMidasFile(); ///< default constructor 00018 ~TMidasFile(); ///< destructor 00019 00020 bool Open(const char* filename); ///< Open input file 00021 bool OutOpen(const char* filename); ///< Open output file 00022 00023 void Close(); ///< Close input file 00024 void OutClose(); ///< Close output file 00025 00026 bool Read(TMidasEvent *event); ///< Read one event from the file 00027 bool Write(TMidasEvent *event); ///< Write one event to the output file 00028 00029 const char* GetFilename() const { return fFilename.c_str(); } ///< Get the name of this file 00030 int GetLastErrno() const { return fLastErrno; } ///< Get error value for the last file error 00031 const char* GetLastError() const { return fLastError.c_str(); } ///< Get error text for the last file error 00032 00033 protected: 00034 00035 std::string fFilename; ///< name of the currently open file 00036 std::string fOutFilename; ///< name of the currently open file 00037 00038 int fLastErrno; ///< errno from the last operation 00039 std::string fLastError; ///< error string from last errno 00040 00041 bool fDoByteSwap; ///< "true" if file has to be byteswapped 00042 00043 int fFile; ///< open input file descriptor 00044 void* fGzFile; ///< zlib compressed input file reader 00045 void* fPoFile; ///< popen() input file reader 00046 int fOutFile; ///< open output file descriptor 00047 void* fOutGzFile; ///< zlib compressed output file reader 00048 }; 00049 00050 #endif // TMidasFile.h