BOSS 7.1.1
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 71 of file raw_ofstream.cxx.

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

Referenced by write_event().

◆ instance()

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

Definition at line 14 of file raw_ofstream.cxx.

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

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 29 of file raw_ofstream.cxx.

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

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 54 of file raw_ofstream.cxx.

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

Referenced by RawFileWriter::writeEvent().


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