HepMC3 event record library: Reader.h Source File

HepMC3 event record library

Reader.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_READER_H
7#define HEPMC3_READER_H
8///
9/// @file Reader.h
10/// @brief Definition of interface \b Reader
11///
12/// @class HepMC3::Reader
13/// @brief Base class for all I/O readers
14///
15/// @ingroup IO
16///
17
18#include "HepMC3/GenRunInfo.h"
19
20namespace HepMC3 {
21
22// Forward declaration
23class GenEvent;
24
25 class Reader {
26public:
27 ///Constructor
28 Reader() {}
29
30 /// Virtual destructor
31 virtual ~Reader() {}
32
33 /// skip or fast forward reading of some events
34 virtual bool skip(const int) { return !failed();}
35
36 /// Fill next event from input into @a evt
37 virtual bool read_event(GenEvent& evt) = 0;
38 /** @brief Get file and/or stream error state */
39 virtual bool failed()=0;
40 /** @brief Close file and/or stream */
41 virtual void close()=0;
42
43 /** @brief Get the global GenRunInfo object. */
44 virtual std::shared_ptr<GenRunInfo> run_info() const { return m_run_info; }
45
46///deleted copy constructor
47 Reader(const Reader&) = delete;
48///deleted copy assignment operator
49 Reader& operator = (const Reader &) = delete;
50 /** @brief Set options */
51 virtual void set_options(const std::map<std::string, std::string>& options) { m_options = options; }
52 /** @brief Get options */
53 virtual std::map<std::string, std::string> get_options() const { return m_options; }
54//protected:
55 /// Set the global GenRunInfo object.
56 virtual void set_run_info(std::shared_ptr<GenRunInfo> run) { m_run_info = run; }
57
58protected:
59 /// Options
60 std::map<std::string, std::string> m_options;
61private:
62 /// The global GenRunInfo object.
63 std::shared_ptr<GenRunInfo> m_run_info;
64};
65
66
67} // namespace HepMC3
68
69#endif
GenRunInfo.h
Definition of class GenRunInfo.
HepMC3::GenEvent
Stores event-related information.
Definition GenEvent.h:47
HepMC3::Reader::read_event
virtual bool read_event(GenEvent &evt)=0
Fill next event from input into evt.
HepMC3::Reader::~Reader
virtual ~Reader()
Virtual destructor.
Definition Reader.h:31
HepMC3::Reader::skip
virtual bool skip(const int)
skip or fast forward reading of some events
Definition Reader.h:34
HepMC3::Reader::Reader
Reader()
Constructor.
Definition Reader.h:28
HepMC3::Reader::set_run_info
virtual void set_run_info(std::shared_ptr< GenRunInfo > run)
Set the global GenRunInfo object.
Definition Reader.h:56
HepMC3::Reader::run_info
virtual std::shared_ptr< GenRunInfo > run_info() const
Get the global GenRunInfo object.
Definition Reader.h:44
HepMC3::Reader::m_options
std::map< std::string, std::string > m_options
Options.
Definition Reader.h:60
HepMC3::Reader::set_options
virtual void set_options(const std::map< std::string, std::string > &options)
Set options.
Definition Reader.h:51
HepMC3::Reader::failed
virtual bool failed()=0
Get file and/or stream error state.
HepMC3::Reader::get_options
virtual std::map< std::string, std::string > get_options() const
Get options.
Definition Reader.h:53
HepMC3::Reader::Reader
Reader(const Reader &)=delete
deleted copy constructor
HepMC3::Reader::m_run_info
std::shared_ptr< GenRunInfo > m_run_info
The global GenRunInfo object.
Definition Reader.h:63
HepMC3::Reader::operator=
Reader & operator=(const Reader &)=delete
deleted copy assignment operator
HepMC3::Reader::close
virtual void close()=0
Close file and/or stream.
HepMC3
HepMC3 main namespace.
Definition AnalysisExample.h:24