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-2020 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 
20 namespace HepMC3 {
21 
22 // Forward declaration
23 class GenEvent;
24 
25 class Writer {
26 public:
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  }
65 protected:
66 
67  /// options
68  std::map<std::string, std::string> m_options;
69 
70 private:
71 
72  /// The global GenRunInfo object.
73  std::shared_ptr<GenRunInfo> m_run_info;
74 
75 };
76 
77 
78 } // namespace HepMC3
79 
80 #endif
Writer & operator=(const Writer &)=delete
deleted copy assignment operator
Definition of class GenRunInfo.
virtual void write_event(const GenEvent &evt)=0
Write event evt to output target.
std::shared_ptr< GenRunInfo > m_run_info
The global GenRunInfo object.
Definition: Writer.h:73
virtual void close()=0
Close file and/or stream.
virtual bool failed()=0
Get file and/or stream error state.
virtual ~Writer()
Virtual destructor.
Definition: Writer.h:32
Stores event-related information.
Definition: GenEvent.h:41
std::shared_ptr< GenRunInfo > run_info() const
Get the global GenRunInfo object.
Definition: Writer.h:47
std::map< std::string, std::string > get_options() const
Set options.
Definition: Writer.h:61
void set_run_info(std::shared_ptr< GenRunInfo > run)
Set the global GenRunInfo object.
Definition: Writer.h:42
void set_options(const std::map< std::string, std::string > &options)
Set options.
Definition: Writer.h:56
Base class for all I/O writers.
Definition: Writer.h:25
std::map< std::string, std::string > m_options
options
Definition: Writer.h:68
Writer()
Constructor.
Definition: Writer.h:29