LCWriter wrapper that automatically splits files if a given number of bytes is exceeded. More...
#include <UTIL/LCSplitWriter.h>
Public Member Functions | |
| LCSplitWriter (IO::LCWriter *wrt, EVENT::long64 maxBytes) | |
| The constructor. | |
| LCSplitWriter (const LCSplitWriter &) | |
| no copy constructor | |
| LCSplitWriter & | operator= (const LCSplitWriter &) |
| no assignment operator | |
| virtual | ~LCSplitWriter () |
| Destructor. | |
| 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. | |
| virtual void | open (const std::string &filename, int writeMode) |
| Not implemented - will throw an Exception if called. | |
| virtual void | writeRunHeader (const EVENT::LCRunHeader *hdr) |
| Writes the given run header to file. | |
| virtual void | setCompressionLevel (int level) |
| Set CompressionLevel. | |
| virtual void | writeEvent (const EVENT::LCEvent *evt) |
| Writes the given file to file. | |
| virtual void | close () |
| Closes the output file/stream. | |
| virtual void | flush () |
| Flushes the output file/stream. | |
| EVENT::long64 | fileSize () |
| Return the current file size in bytes. | |
Protected Member Functions | |
| EVENT::long64 | file_size (const char *fname) |
| Helper function that returns the file size in bytes - o if the file does not exist. | |
| const std::string & | getFilename () |
| Get the complete filename w/o extensiomn,e.g. | |
| void | setBaseFilename (const std::string &filename) |
| Helper function to determine base file name, i.e. | |
| std::string | getCountingString (unsigned count) |
| Returns the string representation of the file number, e.g. | |
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 ...
| UTIL::LCSplitWriter::LCSplitWriter | ( | IO::LCWriter * | wrt, | |
| EVENT::long64 | maxBytes | |||
| ) | [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.
| void UTIL::LCSplitWriter::close | ( | ) | [virtual] |
Closes the output file/stream.
| IO::IOException |
Implements IO::LCWriter.
References IO::LCWriter::close().
| void UTIL::LCSplitWriter::flush | ( | ) | [virtual] |
Flushes the output file/stream.
| IO::IOException |
Implements IO::LCWriter.
References IO::LCWriter::flush().
| std::string UTIL::LCSplitWriter::getCountingString | ( | unsigned | count | ) | [protected] |
| const std::string & UTIL::LCSplitWriter::getFilename | ( | ) | [protected] |
Get the complete filename w/o extensiomn,e.g.
MyFilename.007
References getCountingString().
Referenced by fileSize(), open(), writeEvent(), and writeRunHeader().
| void UTIL::LCSplitWriter::open | ( | const std::string & | filename, | |
| int | writeMode | |||
| ) | [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.
| void UTIL::LCSplitWriter::open | ( | const std::string & | filename | ) | [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.
References getFilename(), IO::LCWriter::open(), and setBaseFilename().
| void UTIL::LCSplitWriter::setBaseFilename | ( | const std::string & | filename | ) | [protected] |
| virtual void UTIL::LCSplitWriter::setCompressionLevel | ( | int | level | ) | [inline, virtual] |
Set CompressionLevel.
Implements IO::LCWriter.
References IO::LCWriter::setCompressionLevel().
| void UTIL::LCSplitWriter::writeEvent | ( | const EVENT::LCEvent * | evt | ) | [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.
References IO::LCWriter::close(), fileSize(), IO::LCWriter::flush(), getFilename(), IO::LCWriter::open(), and IO::LCWriter::writeEvent().
| void UTIL::LCSplitWriter::writeRunHeader | ( | const EVENT::LCRunHeader * | hdr | ) | [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.
References IO::LCWriter::close(), fileSize(), IO::LCWriter::flush(), getFilename(), IO::LCWriter::open(), and IO::LCWriter::writeRunHeader().
1.6.1