BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
raw_ofstream Class Reference

#include <raw_ofstream.h>

+ Inheritance diagram for raw_ofstream:

Public Member Functions

int write_event (const char *pbuf, int size)
 
void close ()
 

Static Public Member Functions

static raw_ofstreaminstance (const std::string &fname)
 
static void release ()
 
static void lock ()
 
static void unlock ()
 

Detailed Description

Definition at line 11 of file raw_ofstream.h.

Member Function Documentation

◆ close()

void raw_ofstream::close ( )

Definition at line 70 of file raw_ofstream.cxx.

71{
72 if ( is_open() ) {
73 m_fileEndRecord.setEventsInFile(m_nevt);
74 m_nevt = 0;
75
76 (*this) << m_fileEndRecord;
77 std::ofstream::close();
78
79 std::cout << "[RawFile] Finished writing file: " << real_fname() << std::endl;
80 }
81}
void setEventsInFile(uint32_t file_nevt)
Definition: RawFileUtil.h:169

Referenced by write_event().

◆ instance()

raw_ofstream * raw_ofstream::instance ( const std::string &  fname)
static

Definition at line 13 of file raw_ofstream.cxx.

14{
15 lock();
16
17 if ( _instance == 0 ) {
18 _instance = new raw_ofstream(fname);
19 }
20
21 ++_nHandler;
22
23 unlock();
24
25 return _instance;
26}
static void lock()
Definition: raw_ofstream.h:18
static void unlock()
Definition: raw_ofstream.h:22

Referenced by RawFileWriter::RawFileWriter().

◆ lock()

static void raw_ofstream::lock ( )
inlinestatic

Definition at line 18 of file raw_ofstream.h.

18 {
19 int lstat = pthread_mutex_lock( &_pthread_lock );
20 assert( lstat == 0 );
21 };

Referenced by instance(), release(), and RawFileWriter::writeEvent().

◆ release()

void raw_ofstream::release ( )
static

Definition at line 28 of file raw_ofstream.cxx.

29{
30 lock();
31
32 if ( _nHandler > 0 && --_nHandler == 0 ) {
33 delete _instance;
34 _instance = 0;
35 }
36
37 unlock();
38}

Referenced by RawFileWriter::~RawFileWriter().

◆ unlock()

static void raw_ofstream::unlock ( )
inlinestatic

Definition at line 22 of file raw_ofstream.h.

22 {
23 int lstat = pthread_mutex_unlock( &_pthread_lock );
24 assert( lstat == 0 );
25 };

Referenced by instance(), release(), and RawFileWriter::writeEvent().

◆ write_event()

int raw_ofstream::write_event ( const char *  pbuf,
int  size 
)

Definition at line 53 of file raw_ofstream.cxx.

54{
55 uint32_t fsize = tellp();
56 if ( fsize >= MAX_RAWFILE_SiZE ) {
57 this->close();
58 init_fstream();
59 }
60
61 m_dataSeparatorRecord.setDataBlockNumber(++m_nevt);
62 m_dataSeparatorRecord.setDataBlockSize(size);
63
64 (*this) << m_dataSeparatorRecord;
65 std::ofstream::write(pbuf, size);
66
67 return m_nfile;
68}
void setDataBlockSize(uint32_t ds)
Definition: RawFileUtil.h:136
void setDataBlockNumber(uint32_t dn)
Definition: RawFileUtil.h:135
#define MAX_RAWFILE_SiZE
Definition: raw_ofstream.cxx:5

Referenced by RawFileWriter::writeEvent().


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