HepMC3 event record library: WriterDOT Class Reference

HepMC3 event record library

Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes
WriterDOT Class Reference

## Detailed Description

GenEvent I/O output to dot files that should be processed by graphviz or other software.

Definition at line 26 of file WriterDOT.h.

`#include <WriterDOT.h>`

Inheritance diagram for WriterDOT:
[legend]
Collaboration diagram for WriterDOT:
[legend]

## Public Member Functions
| WriterDOT (const std::string &filename, std::shared_ptr< GenRunInfo > run=std::shared_ptr< GenRunInfo >())
| Constructor.
| WriterDOT (std::ostream &stream, std::shared_ptr< GenRunInfo > run=std::shared_ptr< GenRunInfo >())
| Constructor from ostream.
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_style (const int &istyle)
| Close file stream.
virtual void | set_run_info (std::shared_ptr< GenRunInfo > run)
| Set the global GenRunInfo object.
virtual std::shared_ptr< GenRunInfo > | run_info () const
| Get the global GenRunInfo object.
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 Member Functions
void | allocate_buffer ()
| allocates buffer for output
void | flush ()
| flushes output buffer
void | forced_flush ()
| flushes output buffer

## Private Attributes
std::ofstream | m_file
| Output file.
std::ostream * | m_stream
| Output stream.
int | m_style
| style of dot file
char * | m_buffer
| Stream buffer.
char * | m_cursor
| Cursor inside stream buffer.
unsigned long | m_buffer_size
| Buffer size.
std::shared_ptr< GenRunInfo > | m_run_info
| The global GenRunInfo object.

## Constructor & Destructor Documentation

## ◆ WriterDOT() [1/2]

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

Constructor.

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

Definition at line 14 of file WriterDOT.cc.

References m_buffer, m_buffer_size, m_cursor, m_file, m_stream, and m_style.

## ◆ WriterDOT() [2/2]

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

Constructor from ostream.

Definition at line 26 of file WriterDOT.cc.

References m_buffer, m_buffer_size, m_cursor, m_stream, and m_style.

## Member Function Documentation

## ◆ allocate_buffer()

void allocate_buffer | ( |  | ) |
| private

allocates buffer for output

Definition at line 109 of file WriterDOT.cc.

References HEPMC3_ERROR_LEVEL, HEPMC3_WARNING_LEVEL, m_buffer, m_buffer_size, and m_cursor.

## ◆ close()

void close | ( |  | ) |
| overridevirtual

Close file stream.

Implements Writer.

Definition at line 35 of file WriterDOT.cc.

References forced_flush(), and m_stream.

## ◆ failed()

bool failed | ( |  | ) |
| inlineoverridevirtual

Return status of the stream.

Implements Writer.

Definition at line 39 of file WriterDOT.h.

References m_file.

## ◆ flush()

void flush | ( |  | ) |
| inlineprivate

flushes output buffer

Definition at line 127 of file WriterDOT.cc.

References m_buffer, m_buffer_size, m_cursor, and m_stream.

## ◆ forced_flush()

void forced_flush | ( |  | ) |
| inlineprivate

flushes output buffer

Definition at line 136 of file WriterDOT.cc.

References m_buffer, m_cursor, and m_stream.

## ◆ 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()

virtual std::shared_ptr< GenRunInfo > run_info | ( |  | ) | const
| inlinevirtualinherited

Get the global GenRunInfo object.

Reimplemented in WriterGZ< T, C >, and WriterPlugin.

Definition at line 45 of file Writer.h.

References m_run_info.

## ◆ 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()

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

Set the global GenRunInfo object.

Reimplemented in WriterGZ< T, C >, and WriterPlugin.

Definition at line 42 of file Writer.h.

References m_run_info.

## ◆ set_style()

void set_style | ( | const int & | istyle | ) |
| inline

Close file stream.

Definition at line 45 of file WriterDOT.h.

References m_style.

## ◆ write_event()

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

Write event to file.

Parameters

  [in] | evt | Event to be serialized

Implements Writer.

Definition at line 55 of file WriterDOT.cc.

References allocate_buffer(), GenEvent::beams(), GenEvent::event_number(), flush(), forced_flush(), HepMC3::is_parton(), m_buffer, m_cursor, m_style, GenEvent::particles(), and GenEvent::vertices().

## Field Documentation

## ◆ m_buffer

char* m_buffer
| private

Stream buffer.

Definition at line 56 of file WriterDOT.h.

## ◆ m_buffer_size

unsigned long m_buffer_size
| private

Buffer size.

Definition at line 58 of file WriterDOT.h.

## ◆ m_cursor

char* m_cursor
| private

Cursor inside stream buffer.

Definition at line 57 of file WriterDOT.h.

## ◆ m_file

std::ofstream m_file
| private

Output file.

Definition at line 53 of file WriterDOT.h.

## ◆ 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_stream

std::ostream* m_stream
| private

Output stream.

Definition at line 54 of file WriterDOT.h.

## ◆ m_style

int m_style
| private

style of dot file

Definition at line 55 of file WriterDOT.h.

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

- WriterDOT.h
- WriterDOT.cc