source: trunk/Mars/mcorsika/MCorsikaFormat.h@ 9893

Last change on this file since 9893 was 9893, checked in by rohlfs, 14 years ago
bug fix in comparing the fRunePos with position 0
File size: 2.1 KB
Line 
1#ifndef MARS_MDataFormat
2#define MARS_MDataFormat
3
4
5#ifndef ROOT_Rtypes
6#include <Rtypes.h>
7#endif
8
9
10#include <iosfwd>
11
12#include "MLog.h"
13
14
15class MCorsikaFormat
16{
17protected:
18 MLog * fLog;
19 std::istream * fIn;
20
21 std::streampos fPrevPos; // file position before previous read
22 std::streampos fPos;
23
24public:
25 MCorsikaFormat(MLog * log, std::istream * in)
26 : fIn(in) {fLog = log; }
27 virtual ~MCorsikaFormat();
28
29 virtual Bool_t SeekNextBlock(const char * id, unsigned short type) = 0;
30 virtual void UnreadLastHeader() = 0;
31
32 virtual Bool_t ReadData(Int_t numValues, Float_t * buffer,
33 Int_t minSeekValues = 272);
34 virtual void UnreadLastData();
35
36 virtual Bool_t SeekEvtEnd() = 0;
37 virtual void StorePos();
38 virtual void ResetPos();
39
40 virtual Bool_t GetNextEvent(Float_t ** buffer, Bool_t & readError) = 0;
41 virtual Bool_t IsEventioFormat() = 0;
42
43 virtual Bool_t Eof() {return fIn->eof();}
44
45
46 std::streampos GetCurrPos() {return fIn->tellg();}
47};
48
49
50class MCorsikaFormatRaw : public MCorsikaFormat
51{
52private:
53
54public:
55 MCorsikaFormatRaw(MLog * log, std::istream * in)
56 : MCorsikaFormat(log, in) {}
57
58 Bool_t SeekNextBlock(const char * id, unsigned short type);
59 void UnreadLastHeader();
60
61 Bool_t SeekEvtEnd();
62
63 Bool_t GetNextEvent(Float_t ** buffer, Bool_t & readError);
64 Bool_t IsEventioFormat() {return kFALSE;}
65};
66
67
68class MCorsikaFormatEventIO : public MCorsikaFormat
69{
70private:
71 std::streampos fRunePos; // file position of the RUNE block
72
73public:
74 MCorsikaFormatEventIO(MLog * log, std::istream * in)
75 : MCorsikaFormat(log, in) {fRunePos = std::streampos(0);}
76
77 Bool_t SeekNextBlock(const char * id, unsigned short type);
78 void UnreadLastHeader();
79
80 Bool_t SeekEvtEnd();
81
82 Bool_t GetNextEvent(Float_t ** buffer, Bool_t & readError);
83 Bool_t IsEventioFormat() {return kTRUE;}
84
85private:
86 Bool_t NextTopLevelBlock(Int_t & length, Bool_t & readError);
87 Bool_t NextEventBlock(Int_t & length, Bool_t & readError);
88
89};
90
91
92MCorsikaFormat * CorsikaFormatFactory(MLog * log, const char * fileName);
93
94
95#endif
96
Note: See TracBrowser for help on using the repository browser.