BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
DataSeparatorRecord Class Reference

#include <RawFileUtil.h>

Public Member Functions

 DataSeparatorRecord ()
 
const data_separator_recordgetRecord () const
 
void dump (std::ostream &os=std::cout) const
 
void setDataBlockNumber (uint32_t dn)
 
void setDataBlockSize (uint32_t ds)
 

Friends

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

Detailed Description

Definition at line 125 of file RawFileUtil.h.

Constructor & Destructor Documentation

◆ DataSeparatorRecord()

DataSeparatorRecord::DataSeparatorRecord ( )

Definition at line 268 of file RawFileUtil.cxx.

269{
270 m_record.marker = 0x1234cccc;
271 m_record.record_size = 4;
272 //m_record.data_block_number; //set manually
273 //m_record.data_block_size; //set manually
274}

Member Function Documentation

◆ dump()

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

Definition at line 328 of file RawFileUtil.cxx.

328 {
329 os << "[RawFile] DataSeparatorRecord:" << std::endl << std::hex
330 << "[RawFile] \tmarker : 0x" << m_record.marker << std::endl
331 << "[RawFile] \trecord_size : 0x" << m_record.record_size << std::endl
332 << "[RawFile] \tdata_block_number : 0x" << m_record.data_block_number << std::endl
333 << "[RawFile] \tdata_block_size : 0x" << m_record.data_block_size
334 << std::dec << std::endl;
335}
uint32_t data_block_number
Definition: RawFileUtil.h:121

◆ getRecord()

const data_separator_record & DataSeparatorRecord::getRecord ( ) const
inline

Definition at line 132 of file RawFileUtil.h.

132{ return m_record; }

Referenced by RawFileReader::nextEvent().

◆ setDataBlockNumber()

void DataSeparatorRecord::setDataBlockNumber ( uint32_t  dn)
inline

Definition at line 135 of file RawFileUtil.h.

135{ m_record.data_block_number = dn; }

Referenced by raw_ofstream::write_event().

◆ setDataBlockSize()

void DataSeparatorRecord::setDataBlockSize ( uint32_t  ds)
inline

Definition at line 136 of file RawFileUtil.h.

136{ m_record.data_block_size = ds; }

Referenced by raw_ofstream::write_event().

Friends And Related Function Documentation

◆ operator<<

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

Definition at line 212 of file RawFileUtil.cxx.

212 {
213 // write data block
214 if (os.write((char*)(&record.m_record), sizeof(data_separator_record)).fail()) {
215 std::cerr << "[RawFile] Error occurred while writing file" << std::endl;
216 throw FailedToWrite("DataSeparatorRecord");
217 }
218
219 return os;
220}

◆ operator>>

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

Definition at line 96 of file RawFileUtil.cxx.

96 {
97 // read data block
98 if (is.read((char*)(&record.m_record), sizeof(data_separator_record)).fail()) {
99 //std::cerr << "[RawFile] Error occurred while reading file" << std::endl;
100 throw BadInputStream("DataSeparatorRecord");
101 //throw ReachEndOfFile();
102 }
103
104 // data validation checks
105 if (record.m_record.marker != 0x1234cccc) {
106 if (record.m_record.marker == 0x1234dddd) {
107 throw ReachEndOfFile(is.currentFile().c_str());
108 }
109 //std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
110 throw WrongMarker(0x1234cccc, record.m_record.marker);
111 }
112
113 if (record.m_record.record_size != 4) {
114 //std::cerr << "[RawFile] Get an unexpected record size" << std::endl;
115 throw UnexpectedRecordSize("DataSeparatorRecord", 4, record.m_record.record_size);
116 }
117
118 return is;
119}
std::string currentFile() const
Definition: raw_ifstream.h:29

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