LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SIO::SIOWriter Class Reference

Concrete implementation of LCWriter using SIO. More...

#include <SIOWriter.h>

+ Inheritance diagram for SIO::SIOWriter:

Public Member Functions

 SIOWriter ()=default
 Default constructor. More...
 
 SIOWriter (const SIOWriter &)=delete
 no copy constructor More...
 
SIOWriteroperator= (const SIOWriter &)=delete
 no assignment operator More...
 
 ~SIOWriter ()=default
 Destructor. More...
 
virtual void open (const std::string &filename)
 Opens a file for writing. More...
 
virtual void open (const std::string &filename, int writeMode)
 Opens a file for writing. More...
 
virtual void setCompressionLevel (int level)
 Set the compression level - needs to be called before open() otherwise call will have no effect. More...
 
virtual void writeRunHeader (const EVENT::LCRunHeader *hdr)
 Writes the given run header to file. More...
 
virtual void writeEvent (const EVENT::LCEvent *evt)
 Writes the given event to file. More...
 
virtual void close ()
 Closes the output file/stream etc. More...
 
virtual void flush ()
 Flushes the output file/stream etc. More...
 
- Public Member Functions inherited from IO::LCWriter
virtual ~LCWriter ()
 Destructor. More...
 

Private Member Functions

void getSIOFileName (const std::string &filename, std::string &sioFilename)
 Creates a proper filename with extension 'slcio' in sioFilename. More...
 

Private Attributes

sio::ofstream _stream {}
 The output file stream. More...
 
sio::buffer _rawBuffer {2*sio::mbyte}
 The raw buffer for writing bytes to the stream. More...
 
sio::buffer _compBuffer {sio::mbyte}
 The raw buffer for compression. More...
 
sio::zlib_compression _compressor {}
 The compression in use. More...
 
SIOHandlerMgr _eventHandlerMgr {}
 The collection block handler manager for events. More...
 
LCIORandomAccessMgr _raMgr {}
 The random access manager. More...
 

Detailed Description

Concrete implementation of LCWriter using SIO.

Use LCFactory to instantiate.

See Also
LCFactory
Author
gaede
Version
Mar 6, 2003

Definition at line 29 of file SIOWriter.h.

Constructor & Destructor Documentation

SIO::SIOWriter::SIOWriter ( )
default

Default constructor.

SIO::SIOWriter::SIOWriter ( const SIOWriter )
delete

no copy constructor

SIO::SIOWriter::~SIOWriter ( )
default

Destructor.

Member Function Documentation

void SIO::SIOWriter::close ( )
virtual

Closes the output file/stream etc.

Exceptions
IOException

Implements IO::LCWriter.

Definition at line 159 of file SIOWriter.cc.

References _raMgr, _stream, SIO::LCIORandomAccessMgr::clear(), and SIO::LCIORandomAccessMgr::writeRandomAccessRecords().

void SIO::SIOWriter::flush ( )
virtual

Flushes the output file/stream etc.

Exceptions
IOException

Implements IO::LCWriter.

Definition at line 167 of file SIOWriter.cc.

References _stream.

void SIO::SIOWriter::getSIOFileName ( const std::string filename,
std::string sioFilename 
)
private

Creates a proper filename with extension 'slcio' in sioFilename.

Definition at line 39 of file SIOWriter.cc.

References SIO::LCSIO::FileExtension, std::string::length(), and std::string::rfind().

Referenced by open().

void SIO::SIOWriter::open ( const std::string filename)
virtual

Opens a file for writing.

If file with given name exists, an exception is thrown. Use append or new mode instead.

Exceptions
IOException

Implements IO::LCWriter.

Definition at line 20 of file SIOWriter.cc.

References std::string::c_str(), and getSIOFileName().

void SIO::SIOWriter::open ( const std::string filename,
int  writeMode 
)
virtual

Opens a file for writing.

Possible write modes are: LCIO::WRITE_NEW (existing files are replaced) and LCIO::WRITE_APPEND.

Exceptions
IOException

Implements IO::LCWriter.

Definition at line 51 of file SIOWriter.cc.

References _raMgr, _stream, std::string::c_str(), getSIOFileName(), SIO::LCIORandomAccessMgr::initAppend(), SIO::LCSIO::RandomAccessSize, and std::stringstream::str().

SIOWriter& SIO::SIOWriter::operator= ( const SIOWriter )
delete

no assignment operator

void SIO::SIOWriter::setCompressionLevel ( int  level)
virtual

Set the compression level - needs to be called before open() otherwise call will have no effect.

If not called the Writer will use default compression.
Valid compression levels are:

  • level < 0 : default compression
  • level == 0 : no compression
  • level > 0 : 1 (fastest) - 9 (best compression)

Experimental code - don't use for production.

Parameters
levelcompression level

Implements IO::LCWriter.

Definition at line 99 of file SIOWriter.cc.

References _compressor.

Referenced by IOIMPL::LCFactory::createLCWriter().

void SIO::SIOWriter::writeEvent ( const EVENT::LCEvent evt)
virtual
void SIO::SIOWriter::writeRunHeader ( const EVENT::LCRunHeader hdr)
virtual

Writes the given run header to file.

Exceptions
IOException

Implements IO::LCWriter.

Definition at line 105 of file SIOWriter.cc.

References _compBuffer, _compressor, _raMgr, _rawBuffer, _stream, SIO::LCIORandomAccessMgr::add(), EVENT::LCRunHeader::getRunNumber(), and SIO::SIORunHeaderRecord::writeRecord().

Member Data Documentation

sio::buffer SIO::SIOWriter::_compBuffer {sio::mbyte}
private

The raw buffer for compression.

Definition at line 108 of file SIOWriter.h.

Referenced by writeEvent(), and writeRunHeader().

sio::zlib_compression SIO::SIOWriter::_compressor {}
private

The compression in use.

Definition at line 110 of file SIOWriter.h.

Referenced by setCompressionLevel(), writeEvent(), and writeRunHeader().

SIOHandlerMgr SIO::SIOWriter::_eventHandlerMgr {}
private

The collection block handler manager for events.

Definition at line 112 of file SIOWriter.h.

Referenced by writeEvent().

LCIORandomAccessMgr SIO::SIOWriter::_raMgr {}
private

The random access manager.

Definition at line 114 of file SIOWriter.h.

Referenced by close(), open(), writeEvent(), and writeRunHeader().

sio::buffer SIO::SIOWriter::_rawBuffer {2*sio::mbyte}
private

The raw buffer for writing bytes to the stream.

Definition at line 106 of file SIOWriter.h.

Referenced by writeEvent(), and writeRunHeader().

sio::ofstream SIO::SIOWriter::_stream {}
private

The output file stream.

Definition at line 104 of file SIOWriter.h.

Referenced by close(), flush(), open(), writeEvent(), and writeRunHeader().


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