BOSS 7.0.5
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 ()
 
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 ()
 
static raw_ofstreaminstance (const std::string &fname)
 
static void release ()
 
static void lock ()
 
static void unlock ()
 

Detailed Description

Member Function Documentation

◆ close() [1/2]

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}

Referenced by write_event().

◆ close() [2/2]

void raw_ofstream::close ( )

◆ instance() [1/2]

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}

Referenced by RawFileWriter::RawFileWriter().

◆ instance() [2/2]

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

◆ lock() [1/2]

static void raw_ofstream::lock ( )
inlinestatic

Definition at line 18 of file Event/RawFile/RawFile-00-00-10/RawFile/raw_ofstream.h.

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

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

◆ lock() [2/2]

static void raw_ofstream::lock ( )
inlinestatic

Definition at line 18 of file InstallArea/include/RawFile/RawFile/raw_ofstream.h.

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

◆ release() [1/2]

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().

◆ release() [2/2]

static void raw_ofstream::release ( )
static

◆ unlock() [1/2]

static void raw_ofstream::unlock ( )
inlinestatic

Definition at line 22 of file Event/RawFile/RawFile-00-00-10/RawFile/raw_ofstream.h.

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

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

◆ unlock() [2/2]

static void raw_ofstream::unlock ( )
inlinestatic

Definition at line 22 of file InstallArea/include/RawFile/RawFile/raw_ofstream.h.

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

◆ write_event() [1/2]

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}
#define MAX_RAWFILE_SiZE
Definition: raw_ofstream.cxx:5

Referenced by RawFileWriter::writeEvent().

◆ write_event() [2/2]

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

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