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