HepMC3 event record library: Writer.h Source File

HepMC3 event record library

Writer.h
Go to the documentation of this file.
1// -*- C++ -*-
2//
3// This file is part of HepMC
4// Copyright (C) 2014-2023 The HepMC collaboration (see AUTHORS for details)
5//
6#ifndef HEPMC3_WRITER_H
7#define HEPMC3_WRITER_H
8///
9/// @file Writer.h
10/// @brief Definition of interface \b Writer
11///
12/// @class HepMC3::Writer
13/// @brief Base class for all I/O writers
14///
15/// @ingroup IO
16///
17
18#include "HepMC3/GenRunInfo.h"
19
20namespace HepMC3 {
21
22// Forward declaration
23class GenEvent;
24
25 class Writer {
26public:
27
28 ///Constructor
29 Writer() {}
30
31 /// Virtual destructor
32 virtual ~Writer() {}
33
34 /// Write event @a evt to output target
35 virtual void write_event(const GenEvent &evt) = 0;
36 /** @brief Get file and/or stream error state */
37 virtual bool failed() = 0;
38 /** @brief Close file and/or stream */
39 virtual void close() = 0;
40
41 /// Set the global GenRunInfo object.
42 virtual void set_run_info(std::shared_ptr<GenRunInfo> run) { m_run_info = run; }
43
44 /// Get the global GenRunInfo object.
45 virtual std::shared_ptr<GenRunInfo> run_info() const { return m_run_info; }
46
47///deleted copy constructor
48 Writer(const Writer&) = delete;
49///deleted copy assignment operator
50 Writer& operator = (const Writer &) = delete;
51 /// Set options
52 virtual void set_options(const std::map<std::string, std::string>& options) { m_options = options; }
53 /// Set options
54 virtual std::map<std::string, std::string> get_options() const { return m_options; }
55
56protected:
57
58 /// options
59 std::map<std::string, std::string> m_options;
60
61private:
62
63 /// The global GenRunInfo object.
64 std::shared_ptr<GenRunInfo> m_run_info;
65
66};
67
68
69} // namespace HepMC3
70
71#endif
GenRunInfo.h
Definition of class GenRunInfo.
HepMC3::GenEvent
Stores event-related information.
Definition GenEvent.h:47
HepMC3::Writer::Writer
Writer()
Constructor.
Definition Writer.h:29
HepMC3::Writer::set_run_info
virtual void set_run_info(std::shared_ptr< GenRunInfo > run)
Set the global GenRunInfo object.
Definition Writer.h:42
HepMC3::Writer::run_info
virtual std::shared_ptr< GenRunInfo > run_info() const
Get the global GenRunInfo object.
Definition Writer.h:45
HepMC3::Writer::write_event
virtual void write_event(const GenEvent &evt)=0
Write event evt to output target.
HepMC3::Writer::m_options
std::map< std::string, std::string > m_options
options
Definition Writer.h:59
HepMC3::Writer::set_options
virtual void set_options(const std::map< std::string, std::string > &options)
Set options.
Definition Writer.h:52
HepMC3::Writer::operator=
Writer & operator=(const Writer &)=delete
deleted copy assignment operator
HepMC3::Writer::Writer
Writer(const Writer &)=delete
deleted copy constructor
HepMC3::Writer::failed
virtual bool failed()=0
Get file and/or stream error state.
HepMC3::Writer::get_options
virtual std::map< std::string, std::string > get_options() const
Set options.
Definition Writer.h:54
HepMC3::Writer::~Writer
virtual ~Writer()
Virtual destructor.
Definition Writer.h:32
HepMC3::Writer::m_run_info
std::shared_ptr< GenRunInfo > m_run_info
The global GenRunInfo object.
Definition Writer.h:64
HepMC3::Writer::close
virtual void close()=0
Close file and/or stream.
HepMC3
HepMC3 main namespace.
Definition AnalysisExample.h:24