LCIO  "2.7.4"
 All Classes Namespaces Functions Variables Typedefs Friends Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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

Public Member Functions

 LCSplitWriter (IO::LCWriter *wrt, EVENT::long64 maxBytes)
 The constructor. More...
 
virtual ~LCSplitWriter ()
 Destructor.
 
virtual void open (const std::string &filename) throw (IO::IOException, std::exception )
 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) throw (IO::IOException, std::exception )
 Not implemented - will throw an Exception if called. More...
 
virtual void writeRunHeader (const EVENT::LCRunHeader *hdr) throw (IO::IOException, std::exception )
 Writes the given run header to file. More...
 
virtual void setCompressionLevel (int level)
 Set CompressionLevel. More...
 
virtual void writeEvent (const EVENT::LCEvent *evt) throw (IO::IOException, std::exception )
 Writes the given file to file. More...
 
virtual void close () throw (IO::IOException, std::exception )
 Closes the output file/stream. More...
 
virtual void flush () throw (IO::IOException, std::exception )
 Flushes the output file/stream. More...
 
EVENT::long64 fileSize ()
 Return the current file size in bytes.
 
- Public Member Functions inherited from IO::LCWriter
virtual ~LCWriter ()
 Destructor.
 

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

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 ( )
throw (IO::IOException,
std::exception
)
virtual

Closes the output file/stream.

Exceptions
IO::IOException

Implements IO::LCWriter.

void UTIL::LCSplitWriter::flush ( )
throw (IO::IOException,
std::exception
)
virtual

Flushes the output file/stream.

Exceptions
IO::IOException

Implements IO::LCWriter.

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

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

"007".

const std::string & UTIL::LCSplitWriter::getFilename ( )
protected

Get the complete filename w/o extensiomn,e.g.

MyFilename.007

void UTIL::LCSplitWriter::open ( const std::string &  filename)
throw (IO::IOException,
std::exception
)
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.

void UTIL::LCSplitWriter::open ( const std::string &  filename,
int  writeMode 
)
throw (IO::IOException,
std::exception
)
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::setBaseFilename ( const std::string &  filename)
protected

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

w/o extension.

virtual void UTIL::LCSplitWriter::setCompressionLevel ( int  level)
inlinevirtual

Set CompressionLevel.

See Also
LCWriter::setCompressionLevel()

Implements IO::LCWriter.

References IO::LCWriter::setCompressionLevel().

void UTIL::LCSplitWriter::writeEvent ( const EVENT::LCEvent evt)
throw (IO::IOException,
std::exception
)
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.

void UTIL::LCSplitWriter::writeRunHeader ( const EVENT::LCRunHeader hdr)
throw (IO::IOException,
std::exception
)
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.


The documentation for this class was generated from the following files: