BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
FileEndRecord Class Reference

#include <RawFileUtil.h>

Public Member Functions

 FileEndRecord ()
 
const file_end_recordgetRecord () const
 
void dump (std::ostream &os=std::cout) const
 
void setEventsInFile (uint32_t file_nevt)
 
void setDataInFile (uint32_t file_size)
 
void setEventsInRun (uint32_t run_nevt)
 
void setDataInRun (uint32_t run_size)
 
void setStatus (uint32_t status)
 

Friends

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

Detailed Description

Definition at line 158 of file RawFileUtil.h.

Constructor & Destructor Documentation

◆ FileEndRecord()

FileEndRecord::FileEndRecord ( )

Definition at line 276 of file RawFileUtil.cxx.

277{
278 m_record.marker = 0x1234dddd;
279 m_record.record_size = 10;
280 // following members are not meaningful @ offline
281 m_record.date = 0;
282 m_record.time = 0;
283 //m_record.events_in_file; //set manually
284 m_record.data_in_file = 0;
285 m_record.events_in_run = 0;
286 m_record.data_in_run = 0;
287 m_record.status = 1;
288 m_record.end_marker = 0x1234eeee;
289}
uint32_t end_marker
Definition: RawFileUtil.h:155
uint32_t status
Definition: RawFileUtil.h:154
uint32_t data_in_run
Definition: RawFileUtil.h:153
uint32_t record_size
Definition: RawFileUtil.h:147
uint32_t data_in_file
Definition: RawFileUtil.h:151
uint32_t marker
Definition: RawFileUtil.h:146
uint32_t events_in_run
Definition: RawFileUtil.h:152

Member Function Documentation

◆ dump()

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

Definition at line 337 of file RawFileUtil.cxx.

337 {
338 os << "[RawFile] FileEndRecord:" << std::endl << std::hex
339 << "[RawFile] \tmarker : 0x" << m_record.marker << std::endl
340 << "[RawFile] \trecord_size : 0x" << m_record.record_size << std::endl
341 << "[RawFile] \tdate : 0x" << m_record.date << std::endl
342 << "[RawFile] \ttime : 0x" << m_record.time << std::endl
343 << "[RawFile] \tevents_in_file : 0x" << m_record.events_in_file << std::endl
344 << "[RawFile] \tdata_in_file : 0x" << m_record.data_in_file << std::endl
345 << "[RawFile] \tevents_in_run : 0x" << m_record.events_in_run << std::endl
346 << "[RawFile] \tdata_in_run : 0x" << m_record.data_in_run << std::endl
347 << "[RawFile] \tstatus : 0x" << m_record.status << std::endl
348 << "[RawFile] \tend_marker : 0x" << m_record.end_marker
349 << std::dec << std::endl;
350}
uint32_t events_in_file
Definition: RawFileUtil.h:150

◆ getRecord()

const file_end_record & FileEndRecord::getRecord ( ) const
inline

Definition at line 166 of file RawFileUtil.h.

166{ return m_record; }

◆ setDataInFile()

void FileEndRecord::setDataInFile ( uint32_t  file_size)
inline

Definition at line 170 of file RawFileUtil.h.

170{ m_record.data_in_file = file_size; }

◆ setDataInRun()

void FileEndRecord::setDataInRun ( uint32_t  run_size)
inline

Definition at line 172 of file RawFileUtil.h.

172{ m_record.data_in_run = run_size; }

◆ setEventsInFile()

void FileEndRecord::setEventsInFile ( uint32_t  file_nevt)
inline

Definition at line 169 of file RawFileUtil.h.

169{ m_record.events_in_file = file_nevt; }

Referenced by raw_ofstream::close().

◆ setEventsInRun()

void FileEndRecord::setEventsInRun ( uint32_t  run_nevt)
inline

Definition at line 171 of file RawFileUtil.h.

171{ m_record.events_in_run = run_nevt; }

◆ setStatus()

void FileEndRecord::setStatus ( uint32_t  status)
inline

Definition at line 173 of file RawFileUtil.h.

173{ m_record.status = status; }

Friends And Related Function Documentation

◆ makeEndRecord

raw_ifstream & makeEndRecord ( DataSeparatorRecord sep,
raw_ifstream is,
FileEndRecord record 
)
friend

Definition at line 146 of file RawFileUtil.cxx.

146 {
147 // copy file_end_record data that already read by data_separator_record
148 memcpy((void*)&record.m_record, (const void*)&(sep.getRecord()), sizeof(data_separator_record));
149 // read data block
150 if (is.read((char*)(&record.m_record.events_in_file), (
151 sizeof(file_end_record) - sizeof(data_separator_record)
152 )).fail()) {
153 //std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
154 throw BadInputStream("FileEndRecord");
155 }
156
157 // data validation checks
158 if (record.m_record.marker != 0x1234dddd) {
159 //std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
160 throw WrongMarker(0x1234dddd, record.m_record.marker);
161 }
162 if (record.m_record.end_marker != 0x1234eeee) {
163 //std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
164 throw WrongMarker(0x1234eeee, record.m_record.end_marker);
165 }
166
167 if (record.m_record.record_size != 10) {
168 //std::cerr << "[RawFile] Get an unexpected record size" << std::endl;
169 throw UnexpectedRecordSize("FileEndRecord", 10, record.m_record.record_size);
170 }
171
172 return is;
173}
const data_separator_record & getRecord() const
Definition: RawFileUtil.h:132

◆ operator<<

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

Definition at line 222 of file RawFileUtil.cxx.

222 {
223 // write data block
224 if (os.write((char*)(&record.m_record), sizeof(file_end_record)).fail()) {
225 std::cerr << "[RawFile] Error occurred while writing file" << std::endl;
226 throw FailedToWrite("FileEndRecord");
227 }
228
229 return os;
230}

◆ operator>>

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

Definition at line 121 of file RawFileUtil.cxx.

121 {
122 // read data block
123 if (is.read((char*)(&record.m_record), sizeof(file_end_record)).fail()) {
124 //std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
125 throw BadInputStream("FileEndRecord");
126 }
127
128 // data validation checks
129 if (record.m_record.marker != 0x1234dddd) {
130 //std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
131 throw WrongMarker(0x1234dddd, record.m_record.marker);
132 }
133 if (record.m_record.end_marker != 0x1234eeee) {
134 //std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
135 throw WrongMarker(0x1234eeee, record.m_record.end_marker);
136 }
137
138 if (record.m_record.record_size != 10) {
139 //std::cerr << "[RawFile] Get an unexpected record size" << std::endl;
140 throw UnexpectedRecordSize("FileEndRecord", 10, record.m_record.record_size);
141 }
142
143 return is;
144}

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