00001 #ifndef __ENDFIO_H
00002 #define __ENDFIO_H
00003
00004 #include <stdio.h>
00005 #include <string.h>
00006
00007 #include <TObject.h>
00008
00009 #include "NdbDefs.h"
00010
00011
00012 enum {
00013 TENDF_READ=1,
00014 TENDF_WRITE=2
00015 };
00016
00017 #define TENDF_NEXT_NUMBER -1
00018 #define TENDF_MAXREC 100
00019
00020
00021 enum {
00022 SEND=1,
00023 FEND=2,
00024 MEND=3,
00025 TEND=4
00026 };
00027
00028 class NdbEndfIO : public TObject
00029 {
00030
00031
00032
00033
00034 protected:
00035 FILE *f;
00036 Int_t mode;
00037 Int_t iMAT;
00038 Int_t iMF;
00039 Int_t iMT;
00040 Int_t lineNum;
00041
00042 Long_t matStart;
00043
00044 Long_t mfStart;
00045 Long_t mtStart;
00046
00047 Int_t lineLen;
00048 char lineTxt[TENDF_MAXREC];
00049 Int_t lastNumPos;
00050 static char _str[TENDF_MAXREC];
00051
00052 public:
00053 NdbEndfIO() { f=NULL; }
00054 virtual ~NdbEndfIO()
00055 { if (f) fclose(f); }
00056
00057 NdbEndfIO( char *filename, Int_t mode);
00058
00059 NdbEndfIO( NdbEndfIO *endf ) {
00060 f = endf->f;
00061 mode = endf->mode;
00062 iMAT = endf->iMAT;
00063 iMF = endf->iMF;
00064 iMF = endf->iMT;
00065 matStart= endf->matStart;
00066 mfStart = endf->mfStart;
00067 mtStart = endf->mtStart;
00068 lineNum = endf->lineNum;
00069 lineLen = endf->lineLen;
00070 strcpy(lineTxt, endf->lineTxt);
00071 }
00072
00073
00074
00075 inline Int_t LineNumber() const { return lineNum; }
00076 inline char *Line() { return lineTxt; }
00077 inline Int_t MAT() const { return iMAT; }
00078 inline Int_t MF() const { return iMF; }
00079 inline Int_t MT() const { return iMT; }
00080
00081
00082 inline Bool_t IsOpen() { return (f!=NULL); }
00083
00084
00085 inline Bool_t Eof() { return feof(f); }
00086
00087
00088 inline Bool_t EOMT() { return (iMT==0); }
00089
00090
00091 inline Bool_t EOMF() { return (iMF==0); }
00092
00093
00094 inline Bool_t EOMAT() { return (iMAT==0); }
00095
00096
00097 Bool_t FindMAT( Int_t mat, Bool_t rewind=FALSE );
00098
00099
00100 Bool_t FindMATMF( Int_t mat, Int_t mf, Bool_t rewind=FALSE );
00101
00102
00103 Bool_t FindMATMFMT( Int_t mat, Int_t mf, Int_t mt,
00104 Bool_t rewind=FALSE );
00105
00106
00107 Bool_t FindMFMT(Int_t mf, Int_t mt);
00108
00109
00110 Bool_t RewindMAT() { return fseek(f, matStart, SEEK_SET); }
00111
00112
00113 Bool_t RewindMF() { return fseek(f, mfStart, SEEK_SET); }
00114
00115
00116 Bool_t RewindMT() { return fseek(f, mtStart, SEEK_SET); }
00117
00118
00119 Bool_t ReadLine();
00120
00121
00122 Int_t ReadInt(Bool_t *error, Int_t pos=TENDF_NEXT_NUMBER);
00123
00124 Float_t ReadReal(Bool_t *error, Int_t pos=TENDF_NEXT_NUMBER);
00125
00126
00127 char* Substr(Int_t start, Int_t length);
00128
00129 protected:
00130 Bool_t NextNumber(Int_t pos=TENDF_NEXT_NUMBER);
00131 Int_t SubReadInt(Int_t start, Int_t length);
00132 Float_t SubReadReal(Int_t start, Int_t length);
00133
00134
00135 ClassDef(NdbEndfIO,1)
00136
00137 };
00138
00139 #endif