RawCorsikaFile.h
Go to the documentation of this file.
1 #ifndef _io_Corsika_RawFile_h_
2 #define _io_Corsika_RawFile_h_
3 
4 #include <io/CorsikaBlock.h>
5 #include <string>
6 #include <fstream>
7 
8 
9 namespace io {
10 
11  namespace Corsika {
12 
30  class RawFile {
31  public:
32  typedef unsigned long int PositionType;
33 
34  static const unsigned int kBlocksInDiskBlock = 21;
35 
37  //static const unsigned int kPaddingBeginning = 4;
39  //static const unsigned int kPaddingEnd = 4;
40 
42  private:
44  //char fPaddingBeginning[kPaddingBeginning];
45  public:
47  private:
49  //char fPaddingEnd[kPaddingEnd];
50  };
51 
53  private:
55  //char fPaddingBeginning[kPaddingBeginning];
56  public:
58  private:
60  //char fPaddingEnd[kPaddingEnd];
61  };
62 
63  RawFile() { }
64 
66  RawFile(const std::string& name);
67 
68  bool Open(const std::string& name, const bool noException = false);
69 
71  void Close();
72 
74  bool GetNextBlock(Block& block);
75 
78 
81 
83  void SeekTo(const PositionType position, const bool reset = false);
84 
86  bool IsOpen() const;
87 
88  private:
90  bool ReadDiskBlock(const bool thinned);
91 
92  mutable std::ifstream fDiskStream;
93  int fPaddingSize = 4;
95 
98 
99  unsigned int fIndexInDiskBlock = 0;
100  bool fBlockBufferValid = false;
101 
102  };
103 
104  }
105 }
106 
107 
108 #endif
PositionType fCurrentBlockNumber
static const unsigned int kBlocksInDiskBlock
Padding bytes at the beginning of a raw block.
void Close()
Close file (no-op for closed file).
ThinnedDiskBlock fDiskThinnBlockBuffer
BlockUnthinned fBlock[kBlocksInDiskBlock]
initial padding - works also for size 0
Raw disk file.
bool GetNextBlock(Block &block)
Read one block and advance.
unsigned int fIndexInDiskBlock
bool IsOpen() const
Check if the file is open.
Block fBlock[kBlocksInDiskBlock]
initial padding - works also for size 0
bool GetNextBlockUnthinned(BlockUnthinned &block)
Read one block and advance.
void SeekTo(const PositionType position, const bool reset=false)
Seek to a given block, the next block will be thePosition.
std::ifstream fDiskStream
bool ReadDiskBlock(const bool thinned)
Read the block at the current position from disk.
PositionType GetNextPosition() const
Number of the block read by the next call to GetNextBlock.
bool Open(const std::string &name, const bool noException=false)
UnthinnedDiskBlock fDiskUnthinnBlockBuffer
unsigned long int PositionType

, generated on Tue Sep 26 2023.