CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
raw_ofstream.h
Go to the documentation of this file.
1#ifndef BESIII_RAW_OFSTREAM_H
2#define BESIII_RAW_OFSTREAM_H
3
5#include <stdint.h>
6#include <fstream>
7#include <string>
8#include <pthread.h>
9#include <assert.h>
10
11class raw_ofstream : virtual public std::ofstream
12{
13 public :
14
15 static raw_ofstream* instance(const std::string& fname);
16 static void release();
17
18 static void lock() {
19 int lstat = pthread_mutex_lock( &_pthread_lock );
20 assert( lstat == 0 );
21 };
22 static void unlock() {
23 int lstat = pthread_mutex_unlock( &_pthread_lock );
24 assert( lstat == 0 );
25 };
26
27 int write_event(const char* pbuf, int size);
28 void close();
29
30 private :
31
32 raw_ofstream(const std::string& fname);
33 virtual ~raw_ofstream();
34
35 void init_fstream();
36 std::string real_fname();
37
38 raw_ofstream(); //stop default
39
40
41 private :
42
43 int m_nevt;
44 int m_nfile;
45 std::string m_fname;
46
47 FileStartRecord m_fileStartRecord;
48 FileNameStrings m_fileNameStrings;
49 RunParametersRecord m_runParametersRecord;
50 DataSeparatorRecord m_dataSeparatorRecord;
51 FileEndRecord m_fileEndRecord;
52
53 static int _nHandler;
54 static raw_ofstream* _instance;
55 static pthread_mutex_t _pthread_lock;
56};
57
58#endif
#define private
static void release()
int write_event(const char *pbuf, int size)
static raw_ofstream * instance(const std::string &fname)
static void lock()
Definition: raw_ofstream.h:18
static void unlock()
Definition: raw_ofstream.h:22