HepMC3 event record library: WriterGZ< T, C > Class Template Reference

HepMC3 event record library

Public Member Functions | Protected Attributes | Private Attributes
WriterGZ< T, C > Class Template Reference

## Detailed Description

template<class T, Compression C = Compression::z>
class HepMC3::WriterGZ< T, C >

GenEvent I/O serialization for compressed files.

Definition at line 25 of file WriterGZ.h.

`#include <WriterGZ.h>`

Inheritance diagram for WriterGZ< T, C >:
[legend]
Collaboration diagram for WriterGZ< T, C >:
[legend]

## Public Member Functions
| WriterGZ (const std::string &filename, std::shared_ptr< GenRunInfo > run=std::shared_ptr< GenRunInfo >())
| Constructor.
| WriterGZ (std::ostream &stream, std::shared_ptr< GenRunInfo > run=std::shared_ptr< GenRunInfo >())
| Constructor from ostream.
| WriterGZ (std::shared_ptr< std::ostream > s_stream, std::shared_ptr< GenRunInfo > run=std::shared_ptr< GenRunInfo >())
| Constructor from ostream.
| ~WriterGZ ()
| Destructor.
void | write_event (const GenEvent &evt) override
| Write event to file.
bool | failed () override
| Return status of the stream.
void | close () override
| Close file stream.
void | set_run_info (std::shared_ptr< GenRunInfo > run) override
| Set the act writer's GenRunInfo object.
std::shared_ptr< GenRunInfo > | run_info () const override
| Get the act writer's GenRunInfo object.
std::shared_ptr< Writer > | writer ()
| Return writer.
virtual void | set_options (const std::map< std::string, std::string > &options)
| Set options.
virtual std::map< std::string, std::string > | get_options () const
| Set options.

## Protected Attributes
std::map< std::string, std::string > | m_options
| options

## Private Attributes
std::shared_ptr< std::ostream > | m_zstr = nullptr
| Stream to write.
std::shared_ptr< Writer > | m_writer = nullptr
| actual writter
std::shared_ptr< GenRunInfo > | m_run_info
| The global GenRunInfo object.

## Constructor & Destructor Documentation

## ◆ WriterGZ() [1/3]

template<class T, Compression C = Compression::z>

WriterGZ | ( | const std::string & | filename,
|  | std::shared_ptr< GenRunInfo > | run = std::shared_ptr<GenRunInfo>() )
| inline

Constructor.

Warning
  If file already exists, it will be cleared before writing

Definition at line 30 of file WriterGZ.h.

References m_writer, and m_zstr.

## ◆ WriterGZ() [2/3]

template<class T, Compression C = Compression::z>

WriterGZ | ( | std::ostream & | stream,
|  | std::shared_ptr< GenRunInfo > | run = std::shared_ptr<GenRunInfo>() )
| inline

Constructor from ostream.

Definition at line 36 of file WriterGZ.h.

References m_writer, and m_zstr.

## ◆ WriterGZ() [3/3]

template<class T, Compression C = Compression::z>

WriterGZ | ( | std::shared_ptr< std::ostream > | s_stream,
|  | std::shared_ptr< GenRunInfo > | run = std::shared_ptr<GenRunInfo>() )
| inline

Constructor from ostream.

Definition at line 42 of file WriterGZ.h.

References m_writer, and m_zstr.

## ◆ ~WriterGZ()

template<class T, Compression C = Compression::z>

~WriterGZ | ( |  | ) |
| inline

Destructor.

Definition at line 48 of file WriterGZ.h.

## Member Function Documentation

## ◆ close()

template<class T, Compression C = Compression::z>

void close | ( |  | ) |
| inlineoverridevirtual

Close file stream.

Implements Writer.

Definition at line 59 of file WriterGZ.h.

References m_writer, and m_zstr.

## ◆ failed()

template<class T, Compression C = Compression::z>

bool failed | ( |  | ) |
| inlineoverridevirtual

Return status of the stream.

Implements Writer.

Definition at line 56 of file WriterGZ.h.

References m_writer.

## ◆ get_options()

virtual std::map< std::string, std::string > get_options | ( |  | ) | const
| inlinevirtualinherited

Set options.

Reimplemented in WriterPlugin.

Definition at line 54 of file Writer.h.

References m_options.

## ◆ run_info()

template<class T, Compression C = Compression::z>

std::shared_ptr< GenRunInfo > run_info | ( |  | ) | const
| inlineoverridevirtual

Get the act writer's GenRunInfo object.

Reimplemented from Writer.

Definition at line 69 of file WriterGZ.h.

References m_writer.

## ◆ set_options()

virtual void set_options | ( | const std::map< std::string, std::string > & | options | ) |
| inlinevirtualinherited

Set options.

Reimplemented in WriterPlugin.

Definition at line 52 of file Writer.h.

References m_options.

## ◆ set_run_info()

template<class T, Compression C = Compression::z>

void set_run_info | ( | std::shared_ptr< GenRunInfo > | run | ) |
| inlineoverridevirtual

Set the act writer's GenRunInfo object.

Reimplemented from Writer.

Definition at line 66 of file WriterGZ.h.

References m_writer.

## ◆ write_event()

template<class T, Compression C = Compression::z>

void write_event | ( | const GenEvent & | evt | ) |
| inlineoverridevirtual

Write event to file.

Parameters

  [in] | evt | Event to be serialized

Implements Writer.

Definition at line 53 of file WriterGZ.h.

References m_writer.

## ◆ writer()

template<class T, Compression C = Compression::z>

std::shared_ptr< Writer > writer | ( |  | ) |
| inline

Return writer.

Definition at line 72 of file WriterGZ.h.

References m_writer.

## Field Documentation

## ◆ m_options

std::map<std::string, std::string> m_options
| protectedinherited

options

Definition at line 59 of file Writer.h.

## ◆ m_run_info

std::shared_ptr<GenRunInfo> m_run_info
| privateinherited

The global GenRunInfo object.

Definition at line 64 of file Writer.h.

## ◆ m_writer

template<class T, Compression C = Compression::z>

std::shared_ptr<Writer> m_writer = nullptr
| private

actual writter

Definition at line 76 of file WriterGZ.h.

## ◆ m_zstr

template<class T, Compression C = Compression::z>

std::shared_ptr< std::ostream > m_zstr = nullptr
| private

Stream to write.

Definition at line 75 of file WriterGZ.h.

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

- WriterGZ.h