00001 #ifndef UTIL_LCSplitWriter_H 00002 #define UTIL_LCSplitWriter_H 1 00003 00004 #include "IO/LCWriter.h" 00005 #include "LCIOTypes.h" 00006 #include <string> 00007 00008 namespace UTIL{ 00009 00016 class LCSplitWriter : public IO::LCWriter { 00017 00018 public: 00019 00028 LCSplitWriter( IO::LCWriter* wrt, EVENT::long64 maxBytes ) : 00029 _wrt( wrt ), 00030 _maxBytes(maxBytes), 00031 _baseFilename(""), 00032 _filename(""), 00033 _extension(""), 00034 _count(0) , 00035 _lastCount(4294967295UL) { 00036 } 00037 00039 LCSplitWriter(const LCSplitWriter&) = delete ; 00041 LCSplitWriter& operator=(const LCSplitWriter&) = delete ; 00042 00045 virtual ~LCSplitWriter() {;} 00046 00047 00048 //-------------------- the LCWriter interface: ------------------------------------- 00049 00050 00056 virtual void open(const std::string & filename) ; 00057 00064 virtual void open(const std::string & filename, int writeMode) ; 00065 00071 virtual void writeRunHeader(const EVENT::LCRunHeader * hdr) ; 00072 00076 virtual void setCompressionLevel(int level) { 00077 _wrt->setCompressionLevel(level) ; 00078 } 00079 00080 00086 virtual void writeEvent(const EVENT::LCEvent * evt) ; 00087 00092 virtual void close() ; 00093 00094 00099 virtual void flush() ; 00100 00101 00102 //--------------------------------------------------------------------------------------------- 00103 00106 EVENT::long64 fileSize() ; 00107 00108 00109 00110 protected: 00111 LCSplitWriter( ); 00112 00115 EVENT::long64 file_size( const char *fname) ; 00116 00119 const std::string& getFilename() ; 00120 00123 void setBaseFilename( const std::string& filename ) ; 00124 00127 std::string getCountingString(unsigned count) ; 00128 00129 IO::LCWriter* _wrt ; 00130 EVENT::long64 _maxBytes ; 00131 std::string _baseFilename ; 00132 std::string _filename ; 00133 std::string _extension ; 00134 unsigned _count ; 00135 unsigned _lastCount ; 00136 00137 }; // class 00138 00139 } // namespace UTIL 00140 00141 #endif /* ifndef UTIL_LCSplitWriter_H */