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-2021 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
25class 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 void set_run_info(std::shared_ptr<GenRunInfo> run) {
43 m_run_info = run;
44 }
45
46 /// Get the global GenRunInfo object.
47 std::shared_ptr<GenRunInfo> run_info() const {
48 return m_run_info;
49 }
50
51///deleted copy constructor
52 Writer(const Writer&) = delete;
53///deleted copy assignment operator
54 Writer& operator = (const Writer &) = delete;
55 /// Set options
56 void set_options(const std::map<std::string, std::string>& options)
57 {
58 m_options=options;
59 }
60 /// Set options
61 std::map<std::string, std::string> get_options() const
62 {
63 return m_options;
64 }
65protected:
66
67 /// options
68 std::map<std::string, std::string> m_options;
69
70private:
71
72 /// The global GenRunInfo object.
73 std::shared_ptr<GenRunInfo> m_run_info;
74
75};
76
77
78} // namespace HepMC3
79
80#endif
Definition of class GenRunInfo.
Stores event-related information.
Definition: GenEvent.h:41
Base class for all I/O writers.
Definition: Writer.h:25
void set_options(const std::map< std::string, std::string > &options)
Set options.
Definition: Writer.h:56
std::shared_ptr< GenRunInfo > run_info() const
Get the global GenRunInfo object.
Definition: Writer.h:47
Writer()
Constructor.
Definition: Writer.h:29
virtual void write_event(const GenEvent &evt)=0
Write event evt to output target.
std::map< std::string, std::string > m_options
options
Definition: Writer.h:68
void set_run_info(std::shared_ptr< GenRunInfo > run)
Set the global GenRunInfo object.
Definition: Writer.h:42
Writer & operator=(const Writer &)=delete
deleted copy assignment operator
std::map< std::string, std::string > get_options() const
Set options.
Definition: Writer.h:61
Writer(const Writer &)=delete
deleted copy constructor
virtual bool failed()=0
Get file and/or stream error state.
virtual ~Writer()
Virtual destructor.
Definition: Writer.h:32
std::shared_ptr< GenRunInfo > m_run_info
The global GenRunInfo object.
Definition: Writer.h:73
virtual void close()=0
Close file and/or stream.
HepMC3 main namespace.