CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
FileStartRecord Class Reference

#include <RawFileUtil.h>

Public Member Functions

 FileStartRecord ()
 
const file_start_recordgetRecord () const
 
void dump (std::ostream &os=std::cout) const
 
void setFileNumber (uint32_t fn)
 

Friends

raw_ifstreamoperator>> (raw_ifstream &is, FileStartRecord &record)
 
raw_ofstreamoperator<< (raw_ofstream &os, FileStartRecord &record)
 

Detailed Description

Definition at line 39 of file RawFileUtil.h.

Constructor & Destructor Documentation

◆ FileStartRecord()

FileStartRecord::FileStartRecord ( )

Definition at line 232 of file RawFileUtil.cxx.

233{
234 m_record.marker = 0x1234aaaa;
235 m_record.record_size = 8;
236 // following members are not meaningful @ offline
237 m_record.version = 0;
238 m_record.file_number = 0;
239 m_record.date = 0;
240 m_record.time = 0;
241 m_record.sizeLimit_dataBlocks = 0;
242 m_record.sizeLimit_MB = 0;
243}
uint32_t file_number
Definition RawFileUtil.h:32
uint32_t sizeLimit_MB
Definition RawFileUtil.h:36
uint32_t sizeLimit_dataBlocks
Definition RawFileUtil.h:35
uint32_t record_size
Definition RawFileUtil.h:30

Member Function Documentation

◆ dump()

void FileStartRecord::dump ( std::ostream & os = std::cout) const

Definition at line 291 of file RawFileUtil.cxx.

291 {
292 os << "[RawFile] FileStartRecord:" << std::endl << std::hex
293 << "[RawFile] \tmarker : 0x" << m_record.marker << std::endl
294 << "[RawFile] \trecord_size : 0x" << m_record.record_size << std::endl
295 << "[RawFile] \tversion : 0x" << m_record.version << std::endl
296 << "[RawFile] \tfile_number : 0x" << m_record.file_number << std::endl
297 << "[RawFile] \tdate : 0x" << m_record.date << std::endl
298 << "[RawFile] \ttime : 0x" << m_record.time << std::endl
299 << "[RawFile] \tsizeLimit_dataBlocks : 0x" << m_record.sizeLimit_dataBlocks << std::endl
300 << "[RawFile] \tsizeLimit_MB : 0x" << m_record.sizeLimit_MB
301 << std::dec << std::endl;
302}

◆ getRecord()

const file_start_record & FileStartRecord::getRecord ( ) const
inline

Definition at line 46 of file RawFileUtil.h.

46{ return m_record; }

◆ setFileNumber()

void FileStartRecord::setFileNumber ( uint32_t fn)
inline

Definition at line 49 of file RawFileUtil.h.

49{ m_record.file_number = fn; }

Friends And Related Symbol Documentation

◆ operator<<

raw_ofstream & operator<< ( raw_ofstream & os,
FileStartRecord & record )
friend

Definition at line 175 of file RawFileUtil.cxx.

175 {
176 // write data block
177 if (os.write((char*)(&record.m_record), sizeof(file_start_record)).fail()) {
178 std::cerr << "[RawFile] Error occurred while writing file" << std::endl;
179 throw FailedToWrite("FileStartRecord");
180 }
181
182 return os;
183}

◆ operator>>

raw_ifstream & operator>> ( raw_ifstream & is,
FileStartRecord & record )
friend

Definition at line 7 of file RawFileUtil.cxx.

7 {
8 // read data block
9 if (is.read((char*)(&record.m_record), sizeof(file_start_record)).fail()) {
10 //std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
11 throw BadInputStream("FileStartRecord");
12 }
13
14 // data validation checks
15 if (record.m_record.marker != 0x1234aaaa) {
16 //std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
17 throw WrongMarker(0x1234aaaa, record.m_record.marker);
18 }
19
20 if (record.m_record.record_size != 8) {
21 //std::cerr << "[RawFile] Get an unexpected record size" << std::endl;
22 throw UnexpectedRecordSize("FileStartRecord", 8, record.m_record.record_size);
23 }
24
25 return is;
26}

The documentation for this class was generated from the following files: