/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/RawFile/RawFile-00-00-10/RawFile/raw_ofstream.h

Go to the documentation of this file.
00001 #ifndef BESIII_RAW_OFSTREAM_H
00002 #define BESIII_RAW_OFSTREAM_H
00003 
00004 #include "RawFile/RawFileUtil.h"
00005 #include <stdint.h>
00006 #include <fstream>
00007 #include <string>
00008 #include <pthread.h>
00009 #include <assert.h>
00010 
00011 class raw_ofstream : virtual public std::ofstream
00012 {
00013    public :
00014 
00015       static raw_ofstream* instance(const std::string& fname);
00016       static void release();
00017 
00018       static void lock() {
00019          int lstat = pthread_mutex_lock( &_pthread_lock );
00020          assert( lstat == 0 );
00021       };
00022       static void unlock() {
00023          int lstat = pthread_mutex_unlock( &_pthread_lock );
00024          assert( lstat == 0 );
00025       };
00026 
00027       int write_event(const char* pbuf, int size);
00028       void close();
00029 
00030    private :
00031 
00032       raw_ofstream(const std::string& fname);
00033       virtual ~raw_ofstream();
00034 
00035       void init_fstream();
00036       std::string real_fname();
00037 
00038       raw_ofstream();  //stop default
00039 
00040 
00041    private :
00042 
00043       int                   m_nevt;
00044       int                   m_nfile;
00045       std::string           m_fname;
00046 
00047       FileStartRecord       m_fileStartRecord;
00048       FileNameStrings       m_fileNameStrings;
00049       RunParametersRecord   m_runParametersRecord;
00050       DataSeparatorRecord   m_dataSeparatorRecord;
00051       FileEndRecord         m_fileEndRecord;
00052 
00053       static int               _nHandler;
00054       static raw_ofstream*      _instance;
00055       static pthread_mutex_t   _pthread_lock;
00056 };
00057 
00058 #endif

Generated on Tue Nov 29 22:58:36 2016 for BOSS_7.0.2 by  doxygen 1.4.7