UTIL::LCSplitWriter Class Reference

LCWriter wrapper that automatically splits files if a given number of bytes is exceeded. More...

#include <UTIL/LCSplitWriter.h>

Inheritance diagram for UTIL::LCSplitWriter:
IO::LCWriter

List of all members.

Public Member Functions

 LCSplitWriter (IO::LCWriter *wrt, EVENT::long64 maxBytes)
 The constructor.
 LCSplitWriter (const LCSplitWriter &)
 no copy constructor
LCSplitWriteroperator= (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

Detailed Description

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 ...

Author:
gaede
Version:
Id
LCSplitWriter.h,v 1.2 2007-11-09 21:00:55 gaede Exp

Constructor & Destructor Documentation

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.


Member Function Documentation

void UTIL::LCSplitWriter::close (  )  [virtual]

Closes the output file/stream.

Exceptions:
IO::IOException 

Implements IO::LCWriter.

References IO::LCWriter::close().

void UTIL::LCSplitWriter::flush (  )  [virtual]

Flushes the output file/stream.

Exceptions:
IO::IOException 

Implements IO::LCWriter.

References IO::LCWriter::flush().

std::string UTIL::LCSplitWriter::getCountingString ( unsigned  count  )  [protected]

Returns the string representation of the file number, e.g.

"007".

Referenced by getFilename().

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.

Exceptions:
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.

Exceptions:
IO::IOException 

Implements IO::LCWriter.

References getFilename(), IO::LCWriter::open(), and setBaseFilename().

void UTIL::LCSplitWriter::setBaseFilename ( const std::string &  filename  )  [protected]

Helper function to determine base file name, i.e.

w/o extension.

Referenced by open().

virtual void UTIL::LCSplitWriter::setCompressionLevel ( int  level  )  [inline, virtual]

Set CompressionLevel.

See also:
LCWriter::setCompressionLevel()

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.

Exceptions:
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.

Exceptions:
IO::IOException 

Implements IO::LCWriter.

References IO::LCWriter::close(), fileSize(), IO::LCWriter::flush(), getFilename(), IO::LCWriter::open(), and IO::LCWriter::writeRunHeader().


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Friends

Generated on 6 Mar 2020 for LCIO by  doxygen 1.6.1