BOSS 8.0.0
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)
 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)
 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)
std::ofstream & operator<< (std::ofstream &os, FileEndRecord &record)
raw_ifstreamoperator>> (raw_ifstream &is, FileEndRecord &record)
raw_ifstreammakeEndRecord (DataSeparatorRecord &sep, raw_ifstream &is, FileEndRecord &record)
std::ofstream & operator<< (std::ofstream &os, FileEndRecord &record)
raw_ifstreamoperator>> (raw_ifstream &is, FileEndRecord &record)
raw_ifstreammakeEndRecord (DataSeparatorRecord &sep, raw_ifstream &is, FileEndRecord &record)
std::ofstream & operator<< (std::ofstream &os, FileEndRecord &record)

Detailed Description

Definition at line 158 of file Event/RawFile/include/RawFile/RawFileUtil.h.

Constructor & Destructor Documentation

◆ FileEndRecord() [1/3]

FileEndRecord::FileEndRecord ( )

Definition at line 301 of file RawFileUtil.cxx.

301 {
302 m_record.marker = 0x1234dddd;
303 m_record.record_size = 10;
304 // following members are not meaningful @ offline
305 m_record.date = 0;
306 m_record.time = 0;
307 // m_record.events_in_file; //set manually
308 m_record.data_in_file = 0;
309 m_record.events_in_run = 0;
310 m_record.data_in_run = 0;
311 m_record.status = 1;
312 m_record.end_marker = 0x1234eeee;
313}

Referenced by makeEndRecord, operator<<, and operator>>.

◆ FileEndRecord() [2/3]

FileEndRecord::FileEndRecord ( )

◆ FileEndRecord() [3/3]

FileEndRecord::FileEndRecord ( )

Member Function Documentation

◆ dump() [1/3]

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

Definition at line 360 of file RawFileUtil.cxx.

360 {
361 os << "[RawFile] FileEndRecord:" << std::endl
362 << std::hex << "[RawFile] \tmarker : 0x" << m_record.marker << std::endl
363 << "[RawFile] \trecord_size : 0x" << m_record.record_size << std::endl
364 << "[RawFile] \tdate : 0x" << m_record.date << std::endl
365 << "[RawFile] \ttime : 0x" << m_record.time << std::endl
366 << "[RawFile] \tevents_in_file : 0x" << m_record.events_in_file << std::endl
367 << "[RawFile] \tdata_in_file : 0x" << m_record.data_in_file << std::endl
368 << "[RawFile] \tevents_in_run : 0x" << m_record.events_in_run << std::endl
369 << "[RawFile] \tdata_in_run : 0x" << m_record.data_in_run << std::endl
370 << "[RawFile] \tstatus : 0x" << m_record.status << std::endl
371 << "[RawFile] \tend_marker : 0x" << m_record.end_marker << std::dec
372 << std::endl;
373}

◆ dump() [2/3]

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

◆ dump() [3/3]

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

◆ getRecord() [1/3]

const file_end_record & FileEndRecord::getRecord ( ) const
inline

Definition at line 167 of file Event/RawFile/include/RawFile/RawFileUtil.h.

167{ return m_record; }

◆ getRecord() [2/3]

const file_end_record & FileEndRecord::getRecord ( ) const
inline

Definition at line 167 of file InstallArea/x86_64-el9-gcc13-dbg/include/RawFile/RawFileUtil.h.

167{ return m_record; }

◆ getRecord() [3/3]

const file_end_record & FileEndRecord::getRecord ( ) const
inline

Definition at line 167 of file InstallArea/x86_64-el9-gcc13-opt/include/RawFile/RawFileUtil.h.

167{ return m_record; }

◆ setDataInFile() [1/3]

void FileEndRecord::setDataInFile ( uint32_t file_size)
inline

Definition at line 171 of file Event/RawFile/include/RawFile/RawFileUtil.h.

171{ m_record.data_in_file = file_size; }

◆ setDataInFile() [2/3]

void FileEndRecord::setDataInFile ( uint32_t file_size)
inline

Definition at line 171 of file InstallArea/x86_64-el9-gcc13-dbg/include/RawFile/RawFileUtil.h.

171{ m_record.data_in_file = file_size; }

◆ setDataInFile() [3/3]

void FileEndRecord::setDataInFile ( uint32_t file_size)
inline

Definition at line 171 of file InstallArea/x86_64-el9-gcc13-opt/include/RawFile/RawFileUtil.h.

171{ m_record.data_in_file = file_size; }

◆ setDataInRun() [1/3]

void FileEndRecord::setDataInRun ( uint32_t run_size)
inline

Definition at line 173 of file Event/RawFile/include/RawFile/RawFileUtil.h.

173{ m_record.data_in_run = run_size; }

◆ setDataInRun() [2/3]

void FileEndRecord::setDataInRun ( uint32_t run_size)
inline

Definition at line 173 of file InstallArea/x86_64-el9-gcc13-dbg/include/RawFile/RawFileUtil.h.

173{ m_record.data_in_run = run_size; }

◆ setDataInRun() [3/3]

void FileEndRecord::setDataInRun ( uint32_t run_size)
inline

Definition at line 173 of file InstallArea/x86_64-el9-gcc13-opt/include/RawFile/RawFileUtil.h.

173{ m_record.data_in_run = run_size; }

◆ setEventsInFile() [1/3]

void FileEndRecord::setEventsInFile ( uint32_t file_nevt)
inline

Definition at line 170 of file Event/RawFile/include/RawFile/RawFileUtil.h.

170{ m_record.events_in_file = file_nevt; }

◆ setEventsInFile() [2/3]

void FileEndRecord::setEventsInFile ( uint32_t file_nevt)
inline

Definition at line 170 of file InstallArea/x86_64-el9-gcc13-dbg/include/RawFile/RawFileUtil.h.

170{ m_record.events_in_file = file_nevt; }

◆ setEventsInFile() [3/3]

void FileEndRecord::setEventsInFile ( uint32_t file_nevt)
inline

Definition at line 170 of file InstallArea/x86_64-el9-gcc13-opt/include/RawFile/RawFileUtil.h.

170{ m_record.events_in_file = file_nevt; }

◆ setEventsInRun() [1/3]

void FileEndRecord::setEventsInRun ( uint32_t run_nevt)
inline

Definition at line 172 of file Event/RawFile/include/RawFile/RawFileUtil.h.

172{ m_record.events_in_run = run_nevt; }

◆ setEventsInRun() [2/3]

void FileEndRecord::setEventsInRun ( uint32_t run_nevt)
inline

Definition at line 172 of file InstallArea/x86_64-el9-gcc13-dbg/include/RawFile/RawFileUtil.h.

172{ m_record.events_in_run = run_nevt; }

◆ setEventsInRun() [3/3]

void FileEndRecord::setEventsInRun ( uint32_t run_nevt)
inline

Definition at line 172 of file InstallArea/x86_64-el9-gcc13-opt/include/RawFile/RawFileUtil.h.

172{ m_record.events_in_run = run_nevt; }

◆ setStatus() [1/3]

void FileEndRecord::setStatus ( uint32_t status)
inline

Definition at line 174 of file Event/RawFile/include/RawFile/RawFileUtil.h.

174{ m_record.status = status; }

◆ setStatus() [2/3]

void FileEndRecord::setStatus ( uint32_t status)
inline

Definition at line 174 of file InstallArea/x86_64-el9-gcc13-dbg/include/RawFile/RawFileUtil.h.

174{ m_record.status = status; }

◆ setStatus() [3/3]

void FileEndRecord::setStatus ( uint32_t status)
inline

Definition at line 174 of file InstallArea/x86_64-el9-gcc13-opt/include/RawFile/RawFileUtil.h.

174{ m_record.status = status; }

◆ makeEndRecord [1/3]

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

Definition at line 164 of file RawFileUtil.cxx.

165 {
166 // copy file_end_record data that already read by data_separator_record
167 memcpy( (void*)&record.m_record, (const void*)&( sep.getRecord() ),
168 sizeof( data_separator_record ) );
169 // read data block
170 if ( is.read( (char*)( &record.m_record.events_in_file ),
171 ( sizeof( file_end_record ) - sizeof( data_separator_record ) ) )
172 .fail() )
173 {
174 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
175 throw BadInputStream( "FileEndRecord" );
176 }
177
178 // data validation checks
179 if ( record.m_record.marker != 0x1234dddd )
180 {
181 // std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
182 throw WrongMarker( 0x1234dddd, record.m_record.marker );
183 }
184 if ( record.m_record.end_marker != 0x1234eeee )
185 {
186 // std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
187 throw WrongMarker( 0x1234eeee, record.m_record.end_marker );
188 }
189
190 if ( record.m_record.record_size != 10 )
191 {
192 // std::cerr << "[RawFile] Get an unexpected record size" << std::endl;
193 throw UnexpectedRecordSize( "FileEndRecord", 10, record.m_record.record_size );
194 }
195
196 return is;
197}
const data_separator_record & getRecord() const

◆ makeEndRecord [2/3]

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

Definition at line 164 of file RawFileUtil.cxx.

165 {
166 // copy file_end_record data that already read by data_separator_record
167 memcpy( (void*)&record.m_record, (const void*)&( sep.getRecord() ),
168 sizeof( data_separator_record ) );
169 // read data block
170 if ( is.read( (char*)( &record.m_record.events_in_file ),
171 ( sizeof( file_end_record ) - sizeof( data_separator_record ) ) )
172 .fail() )
173 {
174 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
175 throw BadInputStream( "FileEndRecord" );
176 }
177
178 // data validation checks
179 if ( record.m_record.marker != 0x1234dddd )
180 {
181 // std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
182 throw WrongMarker( 0x1234dddd, record.m_record.marker );
183 }
184 if ( record.m_record.end_marker != 0x1234eeee )
185 {
186 // std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
187 throw WrongMarker( 0x1234eeee, record.m_record.end_marker );
188 }
189
190 if ( record.m_record.record_size != 10 )
191 {
192 // std::cerr << "[RawFile] Get an unexpected record size" << std::endl;
193 throw UnexpectedRecordSize( "FileEndRecord", 10, record.m_record.record_size );
194 }
195
196 return is;
197}

◆ makeEndRecord [3/3]

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

Definition at line 164 of file RawFileUtil.cxx.

165 {
166 // copy file_end_record data that already read by data_separator_record
167 memcpy( (void*)&record.m_record, (const void*)&( sep.getRecord() ),
168 sizeof( data_separator_record ) );
169 // read data block
170 if ( is.read( (char*)( &record.m_record.events_in_file ),
171 ( sizeof( file_end_record ) - sizeof( data_separator_record ) ) )
172 .fail() )
173 {
174 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
175 throw BadInputStream( "FileEndRecord" );
176 }
177
178 // data validation checks
179 if ( record.m_record.marker != 0x1234dddd )
180 {
181 // std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
182 throw WrongMarker( 0x1234dddd, record.m_record.marker );
183 }
184 if ( record.m_record.end_marker != 0x1234eeee )
185 {
186 // std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
187 throw WrongMarker( 0x1234eeee, record.m_record.end_marker );
188 }
189
190 if ( record.m_record.record_size != 10 )
191 {
192 // std::cerr << "[RawFile] Get an unexpected record size" << std::endl;
193 throw UnexpectedRecordSize( "FileEndRecord", 10, record.m_record.record_size );
194 }
195
196 return is;
197}

◆ operator<< [1/3]

std::ofstream & operator<< ( std::ofstream & os,
FileEndRecord & record )
friend

Definition at line 250 of file RawFileUtil.cxx.

250 {
251 // write data block
252 if ( os.write( (char*)( &record.m_record ), sizeof( file_end_record ) ).fail() )
253 {
254 std::cerr << "[RawFile] Error occurred while writing file" << std::endl;
255 throw FailedToWrite( "FileEndRecord" );
256 }
257
258 return os;
259}

◆ operator<< [2/3]

std::ofstream & operator<< ( std::ofstream & os,
FileEndRecord & record )
friend

Definition at line 250 of file RawFileUtil.cxx.

250 {
251 // write data block
252 if ( os.write( (char*)( &record.m_record ), sizeof( file_end_record ) ).fail() )
253 {
254 std::cerr << "[RawFile] Error occurred while writing file" << std::endl;
255 throw FailedToWrite( "FileEndRecord" );
256 }
257
258 return os;
259}

◆ operator<< [3/3]

std::ofstream & operator<< ( std::ofstream & os,
FileEndRecord & record )
friend

Definition at line 250 of file RawFileUtil.cxx.

250 {
251 // write data block
252 if ( os.write( (char*)( &record.m_record ), sizeof( file_end_record ) ).fail() )
253 {
254 std::cerr << "[RawFile] Error occurred while writing file" << std::endl;
255 throw FailedToWrite( "FileEndRecord" );
256 }
257
258 return os;
259}

◆ operator>> [1/3]

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

Definition at line 135 of file RawFileUtil.cxx.

135 {
136 // read data block
137 if ( is.read( (char*)( &record.m_record ), sizeof( file_end_record ) ).fail() )
138 {
139 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
140 throw BadInputStream( "FileEndRecord" );
141 }
142
143 // data validation checks
144 if ( record.m_record.marker != 0x1234dddd )
145 {
146 // std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
147 throw WrongMarker( 0x1234dddd, record.m_record.marker );
148 }
149 if ( record.m_record.end_marker != 0x1234eeee )
150 {
151 // std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
152 throw WrongMarker( 0x1234eeee, record.m_record.end_marker );
153 }
154
155 if ( record.m_record.record_size != 10 )
156 {
157 // std::cerr << "[RawFile] Get an unexpected record size" << std::endl;
158 throw UnexpectedRecordSize( "FileEndRecord", 10, record.m_record.record_size );
159 }
160
161 return is;
162}

◆ operator>> [2/3]

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

Definition at line 135 of file RawFileUtil.cxx.

135 {
136 // read data block
137 if ( is.read( (char*)( &record.m_record ), sizeof( file_end_record ) ).fail() )
138 {
139 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
140 throw BadInputStream( "FileEndRecord" );
141 }
142
143 // data validation checks
144 if ( record.m_record.marker != 0x1234dddd )
145 {
146 // std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
147 throw WrongMarker( 0x1234dddd, record.m_record.marker );
148 }
149 if ( record.m_record.end_marker != 0x1234eeee )
150 {
151 // std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
152 throw WrongMarker( 0x1234eeee, record.m_record.end_marker );
153 }
154
155 if ( record.m_record.record_size != 10 )
156 {
157 // std::cerr << "[RawFile] Get an unexpected record size" << std::endl;
158 throw UnexpectedRecordSize( "FileEndRecord", 10, record.m_record.record_size );
159 }
160
161 return is;
162}

◆ operator>> [3/3]

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

Definition at line 135 of file RawFileUtil.cxx.

135 {
136 // read data block
137 if ( is.read( (char*)( &record.m_record ), sizeof( file_end_record ) ).fail() )
138 {
139 // std::cerr << "[RawFile] Error occurred while reading files" << std::endl;
140 throw BadInputStream( "FileEndRecord" );
141 }
142
143 // data validation checks
144 if ( record.m_record.marker != 0x1234dddd )
145 {
146 // std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
147 throw WrongMarker( 0x1234dddd, record.m_record.marker );
148 }
149 if ( record.m_record.end_marker != 0x1234eeee )
150 {
151 // std::cerr << "[RawFile] Get an invalid record marker" << std::endl;
152 throw WrongMarker( 0x1234eeee, record.m_record.end_marker );
153 }
154
155 if ( record.m_record.record_size != 10 )
156 {
157 // std::cerr << "[RawFile] Get an unexpected record size" << std::endl;
158 throw UnexpectedRecordSize( "FileEndRecord", 10, record.m_record.record_size );
159 }
160
161 return is;
162}

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