BOSS 7.0.1
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)
 
 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)
 
raw_ifstreamoperator>> (raw_ifstream &is, DataSeparatorRecord &record)
 
raw_ofstreamoperator<< (raw_ofstream &os, DataSeparatorRecord &record)
 

Detailed Description

Constructor & Destructor Documentation

◆ DataSeparatorRecord() [1/2]

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}

◆ DataSeparatorRecord() [2/2]

DataSeparatorRecord::DataSeparatorRecord ( )

Member Function Documentation

◆ dump() [1/2]

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}

◆ dump() [2/2]

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

◆ getRecord() [1/2]

const data_separator_record & DataSeparatorRecord::getRecord ( ) const
inline

Definition at line 132 of file Event/RawFile/RawFile-00-00-10/RawFile/RawFileUtil.h.

132{ return m_record; }

Referenced by RawFileReader::nextEvent().

◆ getRecord() [2/2]

const data_separator_record & DataSeparatorRecord::getRecord ( ) const
inline

Definition at line 132 of file InstallArea/include/RawFile/RawFile/RawFileUtil.h.

132{ return m_record; }

◆ setDataBlockNumber() [1/2]

void DataSeparatorRecord::setDataBlockNumber ( uint32_t  dn)
inline

Definition at line 135 of file Event/RawFile/RawFile-00-00-10/RawFile/RawFileUtil.h.

135{ m_record.data_block_number = dn; }

Referenced by raw_ofstream::write_event().

◆ setDataBlockNumber() [2/2]

void DataSeparatorRecord::setDataBlockNumber ( uint32_t  dn)
inline

Definition at line 135 of file InstallArea/include/RawFile/RawFile/RawFileUtil.h.

135{ m_record.data_block_number = dn; }

◆ setDataBlockSize() [1/2]

void DataSeparatorRecord::setDataBlockSize ( uint32_t  ds)
inline

Definition at line 136 of file Event/RawFile/RawFile-00-00-10/RawFile/RawFileUtil.h.

136{ m_record.data_block_size = ds; }

Referenced by raw_ofstream::write_event().

◆ setDataBlockSize() [2/2]

void DataSeparatorRecord::setDataBlockSize ( uint32_t  ds)
inline

Definition at line 136 of file InstallArea/include/RawFile/RawFile/RawFileUtil.h.

136{ m_record.data_block_size = ds; }

Friends And Related Function Documentation

◆ operator<< [1/2]

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<< [2/2]

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>> [1/2]

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}

◆ operator>> [2/2]

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}

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