Raw disk file. More...
#include "Corsika/RawCorsikaFile.h"
Classes | |
class | ThinnedDiskBlock |
Padding bytes at the beginning of a raw block. More... | |
class | UnthinnedDiskBlock |
Public Types | |
typedef unsigned long int | PositionType |
Public Member Functions | |
void | Close () |
Close file (no-op for closed file). More... | |
bool | GetNextBlock (Block &block) |
Read one block and advance. More... | |
bool | GetNextBlockUnthinned (BlockUnthinned &block) |
Read one block and advance. More... | |
PositionType | GetNextPosition () const |
Number of the block read by the next call to GetNextBlock. More... | |
bool | IsOpen () const |
Check if the file is open. More... | |
bool | Open (const std::string &name, const bool noException=false) |
RawFile () | |
RawFile (const std::string &name) | |
Construct and open file. More... | |
void | SeekTo (const PositionType position, const bool reset=false) |
Seek to a given block, the next block will be thePosition. More... | |
Static Public Attributes | |
static const unsigned int | kBlocksInDiskBlock = 21 |
Private Member Functions | |
bool | ReadDiskBlock (const bool thinned) |
Read the block at the current position from disk. More... | |
Private Attributes | |
bool | fBlockBufferValid = false |
PositionType | fCurrentBlockNumber = 0 |
std::ifstream | fDiskStream |
ThinnedDiskBlock | fDiskThinnBlockBuffer |
UnthinnedDiskBlock | fDiskUnthinnBlockBuffer |
unsigned int | fIndexInDiskBlock = 0 |
int | fPaddingSize = 4 |
Raw disk file.
This class provides block-wise read access to a Corsika ground particles file on disk. Simple random access is supported.
This class handles the grouping of individual blocks into a disk block with padding. It doesn't provide tools for unpacking the individual particles from a block.
Definition at line 30 of file RawCorsikaFile.h.
typedef unsigned long int io::Corsika::RawFile::PositionType |
Definition at line 32 of file RawCorsikaFile.h.
|
inline |
Definition at line 63 of file RawCorsikaFile.h.
RawFile::RawFile | ( | const std::string & | name | ) |
Construct and open file.
Definition at line 15 of file RawCorsikaFile.cc.
References ERROR, and fDiskStream.
void RawFile::Close | ( | ) |
Close file (no-op for closed file).
Definition at line 89 of file RawCorsikaFile.cc.
References fDiskStream.
Referenced by testRawFile::testClose(), and testRawFile::testOpenCloseOpen().
bool RawFile::GetNextBlock | ( | Block & | block | ) |
Read one block and advance.
Definition at line 97 of file RawCorsikaFile.cc.
References io::Corsika::RawFile::ThinnedDiskBlock::fBlock, fBlockBufferValid, fCurrentBlockNumber, fDiskThinnBlockBuffer, fIndexInDiskBlock, kBlocksInDiskBlock, and ReadDiskBlock().
Referenced by io::CorsikaShowerFileParticleIterator::GetOneParticleRecord(), io::CorsikaShowerFile::Read(), io::CorsikaShowerFile::ScanGroundFile(), testRawFile::testRandomAccess(), testRawFile::testReadHeader(), and testRawFile::testReadToTrailer().
bool RawFile::GetNextBlockUnthinned | ( | BlockUnthinned & | block | ) |
Read one block and advance.
Definition at line 116 of file RawCorsikaFile.cc.
References io::Corsika::RawFile::UnthinnedDiskBlock::fBlock, fBlockBufferValid, fCurrentBlockNumber, fDiskUnthinnBlockBuffer, fIndexInDiskBlock, kBlocksInDiskBlock, and ReadDiskBlock().
Referenced by io::CorsikaShowerFileParticleIterator::GetOneParticleRecordUnthinned(), io::CorsikaShowerFile::Read(), and io::CorsikaShowerFile::ScanGroundFile().
RawFile::PositionType RawFile::GetNextPosition | ( | ) | const |
Number of the block read by the next call to GetNextBlock.
Definition at line 166 of file RawCorsikaFile.cc.
References fCurrentBlockNumber, fIndexInDiskBlock, and kBlocksInDiskBlock.
Referenced by io::CorsikaShowerFile::ScanGroundFile(), and testRawFile::testRandomAccess().
bool RawFile::IsOpen | ( | ) | const |
Check if the file is open.
Definition at line 188 of file RawCorsikaFile.cc.
References fDiskStream.
Referenced by io::CorsikaShowerFile::Read(), and testRawFile::testOpen().
bool RawFile::Open | ( | const std::string & | name, |
const bool | noException = false |
||
) |
Definition at line 27 of file RawCorsikaFile.cc.
References ERROR, fBlockBufferValid, fCurrentBlockNumber, fDiskStream, fIndexInDiskBlock, and fPaddingSize.
Referenced by io::CorsikaShowerFile::ScanGroundFile(), testRawFile::testClose(), testRawFile::testOpen(), testRawFile::testOpenCloseOpen(), testRawFile::testOpenThrowNonExistent(), testRawFile::testOpenThrowReOpen(), testRawFile::testRandomAccess(), testRawFile::testReadHeader(), and testRawFile::testReadToTrailer().
|
private |
Read the block at the current position from disk.
Definition at line 136 of file RawCorsikaFile.cc.
References fBlockBufferValid, fCurrentBlockNumber, fDiskStream, fDiskThinnBlockBuffer, fDiskUnthinnBlockBuffer, and fPaddingSize.
Referenced by GetNextBlock(), and GetNextBlockUnthinned().
void RawFile::SeekTo | ( | const PositionType | position, |
const bool | reset = false |
||
) |
Seek to a given block, the next block will be thePosition.
Definition at line 174 of file RawCorsikaFile.cc.
References fBlockBufferValid, fCurrentBlockNumber, fIndexInDiskBlock, and kBlocksInDiskBlock.
Referenced by io::CorsikaShowerFileParticleIterator::GetOneParticleRecord(), io::CorsikaShowerFileParticleIterator::GetOneParticleRecordUnthinned(), io::CorsikaShowerFile::Read(), io::CorsikaShowerFile::ScanGroundFile(), and testRawFile::testRandomAccess().
|
private |
Definition at line 100 of file RawCorsikaFile.h.
Referenced by GetNextBlock(), GetNextBlockUnthinned(), Open(), ReadDiskBlock(), and SeekTo().
|
private |
Definition at line 94 of file RawCorsikaFile.h.
Referenced by GetNextBlock(), GetNextBlockUnthinned(), GetNextPosition(), Open(), ReadDiskBlock(), and SeekTo().
|
mutableprivate |
Definition at line 92 of file RawCorsikaFile.h.
Referenced by Close(), IsOpen(), Open(), RawFile(), and ReadDiskBlock().
|
private |
Definition at line 97 of file RawCorsikaFile.h.
Referenced by GetNextBlock(), and ReadDiskBlock().
|
private |
Definition at line 96 of file RawCorsikaFile.h.
Referenced by GetNextBlockUnthinned(), and ReadDiskBlock().
|
private |
Definition at line 99 of file RawCorsikaFile.h.
Referenced by GetNextBlock(), GetNextBlockUnthinned(), GetNextPosition(), Open(), and SeekTo().
|
private |
Definition at line 93 of file RawCorsikaFile.h.
Referenced by Open(), and ReadDiskBlock().
|
static |
Definition at line 34 of file RawCorsikaFile.h.
Referenced by GetNextBlock(), GetNextBlockUnthinned(), GetNextPosition(), and SeekTo().