LCIO
02.17
|
LCWriter wrapper that automatically splits files if a given number of bytes is exceeded. More...
#include <LCSplitWriter.h>
Public Member Functions | |
LCSplitWriter (IO::LCWriter *wrt, EVENT::long64 maxBytes) | |
The constructor. More... | |
LCSplitWriter (const LCSplitWriter &)=delete | |
no copy constructor More... | |
LCSplitWriter & | operator= (const LCSplitWriter &)=delete |
no assignment operator More... | |
virtual | ~LCSplitWriter () |
Destructor. More... | |
virtual void | open (const std::string &filename) |
Opens a file for writing where the filename has to include the extension but not the number, e.g. More... | |
virtual void | open (const std::string &filename, int writeMode) |
Not implemented - will throw an Exception if called. More... | |
virtual void | writeRunHeader (const EVENT::LCRunHeader *hdr) |
Writes the given run header to file. More... | |
virtual void | setCompressionLevel (int level) |
Set CompressionLevel. More... | |
virtual void | writeEvent (const EVENT::LCEvent *evt) |
Writes the given file to file. More... | |
virtual void | close () |
Closes the output file/stream. More... | |
virtual void | flush () |
Flushes the output file/stream. More... | |
EVENT::long64 | fileSize () |
Return the current file size in bytes. More... | |
![]() | |
virtual | ~LCWriter () |
Destructor. More... | |
Protected Member Functions | |
LCSplitWriter () | |
EVENT::long64 | file_size (const char *fname) |
Helper function that returns the file size in bytes - o if the file does not exist. More... | |
const std::string & | getFilename () |
Get the complete filename w/o extensiomn,e.g. More... | |
void | setBaseFilename (const std::string &filename) |
Helper function to determine base file name, i.e. More... | |
std::string | getCountingString (unsigned count) |
Returns the string representation of the file number, e.g. More... | |
Protected Attributes | |
IO::LCWriter * | _wrt |
EVENT::long64 | _maxBytes |
std::string | _baseFilename |
std::string | _filename |
std::string | _extension |
unsigned | _count |
unsigned | _lastCount |
LCWriter wrapper that automatically splits files if a given number of bytes is exceeded.
File names are extended by a file number of the form .000 - .999 ...
Definition at line 16 of file LCSplitWriter.h.
|
inline |
The constructor.
Takes a pointer to a valid LCWriter instance and the file size in bytes that causes a new file to be opened if exceeded. example:
// replace LCWriter* lcWrt = LCFactory::getInstance()->createLCWriter() ; // with LCSplitWriter* lcWrt = new LCSplitWriter( LCFactory::getInstance()->createLCWriter() , 2040109465 ) ;
to automatically split files after 1.9 GByte file size has been exceeded.
Definition at line 28 of file LCSplitWriter.h.
|
delete |
no copy constructor
|
inlinevirtual |
Destructor.
Definition at line 45 of file LCSplitWriter.h.
|
protected |
|
virtual |
Closes the output file/stream.
IO::IOException |
Implements IO::LCWriter.
Definition at line 73 of file LCSplitWriter.cc.
|
protected |
Helper function that returns the file size in bytes - o if the file does not exist.
Definition at line 96 of file LCSplitWriter.cc.
References STAT64.
long64 UTIL::LCSplitWriter::fileSize | ( | ) |
Return the current file size in bytes.
Definition at line 108 of file LCSplitWriter.cc.
|
virtual |
Flushes the output file/stream.
IO::IOException |
Implements IO::LCWriter.
Definition at line 77 of file LCSplitWriter.cc.
|
protected |
Returns the string representation of the file number, e.g.
"007".
Definition at line 142 of file LCSplitWriter.cc.
References NDIGITS, std::setfill(), std::setw(), and std::stringstream::str().
|
protected |
Get the complete filename w/o extensiomn,e.g.
MyFilename.007
Definition at line 84 of file LCSplitWriter.cc.
|
virtual |
Opens a file for writing where the filename has to include the extension but not the number, e.g.
myfile.slcio. Note that this is different from the LCWriter specification.
IO::IOException |
Implements IO::LCWriter.
Definition at line 31 of file LCSplitWriter.cc.
|
virtual |
Not implemented - will throw an Exception if called.
Overwriting of or appending to split files is not straight forward. Pleas use the default write mode and remove exisiting files.
IO::IOException |
Implements IO::LCWriter.
Definition at line 37 of file LCSplitWriter.cc.
|
delete |
no assignment operator
|
protected |
Helper function to determine base file name, i.e.
w/o extension.
Definition at line 123 of file LCSplitWriter.cc.
References std::string::find_last_of(), std::string::length(), std::string::rfind(), and std::string::substr().
|
inlinevirtual |
Set CompressionLevel.
Implements IO::LCWriter.
Definition at line 76 of file LCSplitWriter.h.
References _wrt, and IO::LCWriter::setCompressionLevel().
|
virtual |
Writes the given file to file.
Opens a new file if the given file size is already exceeded before the execution of the write access.
IO::IOException |
Implements IO::LCWriter.
Definition at line 54 of file LCSplitWriter.cc.
|
virtual |
Writes the given run header to file.
Opens a new file if the given file size is already exceeded before the execution of the write access.
IO::IOException |
Implements IO::LCWriter.
Definition at line 42 of file LCSplitWriter.cc.
|
protected |
Definition at line 131 of file LCSplitWriter.h.
|
protected |
Definition at line 134 of file LCSplitWriter.h.
|
protected |
Definition at line 133 of file LCSplitWriter.h.
|
protected |
Definition at line 132 of file LCSplitWriter.h.
|
protected |
Definition at line 135 of file LCSplitWriter.h.
|
protected |
Definition at line 130 of file LCSplitWriter.h.
|
protected |
Definition at line 129 of file LCSplitWriter.h.
Referenced by setCompressionLevel().