LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SIOWriter.h
Go to the documentation of this file.
1 #ifndef SIO_SIOWRITER_H
2 #define SIO_SIOWRITER_H 1
3 
4 // -- std headers
5 #include <string>
6 #include <vector>
7 
8 // -- lcio headers
9 #include "IO/LCWriter.h"
10 #include "EVENT/LCEvent.h"
11 #include "EVENT/LCRunHeader.h"
12 #include "SIO/LCIORecords.h"
14 
15 // -- sio headers
16 #include "sio/definitions.h"
17 #include "sio/buffer.h"
18 #include <sio/compression/zlib.h>
19 
20 namespace SIO {
21 
29  class SIOWriter : public IO::LCWriter {
30  public:
31 
33  SIOWriter() = default ;
35  SIOWriter(const SIOWriter&) = delete ;
37  SIOWriter& operator=(const SIOWriter&) = delete ;
39  ~SIOWriter() = default ;
40 
46  virtual void open(const std::string & filename) ;
47 
54  virtual void open(const std::string & filename, int writeMode) ;
55 
69  virtual void setCompressionLevel(int level) ;
70 
71 
76  virtual void writeRunHeader(const EVENT::LCRunHeader * hdr) ;
77 
82  virtual void writeEvent(const EVENT::LCEvent * evt) ;
83 
88  virtual void close() ;
89 
94  virtual void flush() ;
95 
96  private:
100  void getSIOFileName(const std::string& filename, std::string& sioFilename) ;
101 
102  private:
104  sio::ofstream _stream {} ;
106  sio::buffer _rawBuffer {2*sio::mbyte} ;
108  sio::buffer _compBuffer {sio::mbyte} ;
110  sio::zlib_compression _compressor {} ;
115  }; // class
116 
117 } // namespace.
118 
119 #endif /* ifndef SIO_SIOWRITER_H */
SIOWriter & operator=(const SIOWriter &)=delete
no assignment operator
void getSIOFileName(const std::string &filename, std::string &sioFilename)
Creates a proper filename with extension &#39;slcio&#39; in sioFilename.
Definition: SIOWriter.cc:39
Manager class for LCIO direct access.
SIOHandlerMgr _eventHandlerMgr
The collection block handler manager for events.
Definition: SIOWriter.h:112
SIOWriter()=default
Default constructor.
Interface for the run header.
Definition: LCRunHeader.h:23
virtual void close()
Closes the output file/stream etc.
Definition: SIOWriter.cc:159
Concrete implementation of LCWriter using SIO.
Definition: SIOWriter.h:29
sio::ofstream _stream
The output file stream.
Definition: SIOWriter.h:104
sio::buffer _rawBuffer
The raw buffer for writing bytes to the stream.
Definition: SIOWriter.h:106
sio::buffer _compBuffer
The raw buffer for compression.
Definition: SIOWriter.h:108
virtual void flush()
Flushes the output file/stream etc.
Definition: SIOWriter.cc:167
virtual void writeRunHeader(const EVENT::LCRunHeader *hdr)
Writes the given run header to file.
Definition: SIOWriter.cc:105
STL class.
~SIOWriter()=default
Destructor.
virtual void setCompressionLevel(int level)
Set the compression level - needs to be called before open() otherwise call will have no effect...
Definition: SIOWriter.cc:99
sio::zlib_compression _compressor
The compression in use.
Definition: SIOWriter.h:110
The main event interface.
Definition: LCEvent.h:31
Holds instances of all types of SIOObjectHandlers.
Definition: SIOHandlerMgr.h:20
pair< int, string > level
Definition: lsh.cc:50
Interface for writing data with LCIO.
Definition: LCWriter.h:27
virtual void writeEvent(const EVENT::LCEvent *evt)
Writes the given event to file.
Definition: SIOWriter.cc:125
virtual void open(const std::string &filename)
Opens a file for writing.
Definition: SIOWriter.cc:20
LCIORandomAccessMgr _raMgr
The random access manager.
Definition: SIOWriter.h:114