LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LCSplitWriter.h
Go to the documentation of this file.
1 #ifndef UTIL_LCSplitWriter_H
2 #define UTIL_LCSplitWriter_H 1
3 
4 #include "IO/LCWriter.h"
5 #include "LCIOTypes.h"
6 #include <string>
7 
8 namespace UTIL{
9 
16  class LCSplitWriter : public IO::LCWriter {
17 
18  public:
19 
29  _wrt( wrt ),
30  _maxBytes(maxBytes),
31  _baseFilename(""),
32  _filename(""),
33  _extension(""),
34  _count(0) ,
35  _lastCount(4294967295UL) {
36  }
37 
39  LCSplitWriter(const LCSplitWriter&) = delete ;
41  LCSplitWriter& operator=(const LCSplitWriter&) = delete ;
42 
45  virtual ~LCSplitWriter() {;}
46 
47 
48  //-------------------- the LCWriter interface: -------------------------------------
49 
50 
56  virtual void open(const std::string & filename) ;
57 
64  virtual void open(const std::string & filename, int writeMode) ;
65 
71  virtual void writeRunHeader(const EVENT::LCRunHeader * hdr) ;
72 
76  virtual void setCompressionLevel(int level) {
77  _wrt->setCompressionLevel(level) ;
78  }
79 
80 
86  virtual void writeEvent(const EVENT::LCEvent * evt) ;
87 
92  virtual void close() ;
93 
94 
99  virtual void flush() ;
100 
101 
102  //---------------------------------------------------------------------------------------------
103 
107 
108 
109 
110  protected:
111  LCSplitWriter( );
112 
115  EVENT::long64 file_size( const char *fname) ;
116 
119  const std::string& getFilename() ;
120 
123  void setBaseFilename( const std::string& filename ) ;
124 
127  std::string getCountingString(unsigned count) ;
128 
134  unsigned _count ;
135  unsigned _lastCount ;
136 
137  }; // class
138 
139 } // namespace UTIL
140 
141 #endif /* ifndef UTIL_LCSplitWriter_H */
std::string _extension
std::string _baseFilename
std::string _filename
virtual void setCompressionLevel(int level)=0
Set the compression level - needs to be called before open() otherwise call will have no effect...
Interface for the run header.
Definition: LCRunHeader.h:23
EVENT::long64 fileSize()
Return the current file size in bytes.
virtual void writeEvent(const EVENT::LCEvent *evt)
Writes the given file to file.
virtual void flush()
Flushes the output file/stream.
const std::string & getFilename()
Get the complete filename w/o extensiomn,e.g.
EVENT::long64 _maxBytes
virtual void setCompressionLevel(int level)
Set CompressionLevel.
Definition: LCSplitWriter.h:76
long long long64
64 bit signed integer,e.g.to be used for timestamps
Definition: LCIOTypes.h:14
STL class.
LCWriter wrapper that automatically splits files if a given number of bytes is exceeded.
Definition: LCSplitWriter.h:16
LCSplitWriter(IO::LCWriter *wrt, EVENT::long64 maxBytes)
The constructor.
Definition: LCSplitWriter.h:28
virtual ~LCSplitWriter()
Destructor.
Definition: LCSplitWriter.h:45
std::string getCountingString(unsigned count)
Returns the string representation of the file number, e.g.
EVENT::long64 file_size(const char *fname)
Helper function that returns the file size in bytes - o if the file does not exist.
LCSplitWriter & operator=(const LCSplitWriter &)=delete
no assignment operator
virtual void writeRunHeader(const EVENT::LCRunHeader *hdr)
Writes the given run header to file.
void setBaseFilename(const std::string &filename)
Helper function to determine base file name, i.e.
The main event interface.
Definition: LCEvent.h:31
pair< int, string > level
Definition: lsh.cc:50
Interface for writing data with LCIO.
Definition: LCWriter.h:27
virtual void close()
Closes the output file/stream.
virtual void open(const std::string &filename)
Opens a file for writing where the filename has to include the extension but not the number...
IO::LCWriter * _wrt