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_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 
20 namespace HepMC3 {
21 
22 // Forward declaration
23 class GenEvent;
24 
25 class Reader {
26 public:
27     ///Constructor
Reader()28     Reader() {}
29 
30     /// Virtual destructor
~Reader()31     virtual ~Reader() {}
32 
33     /// skip or fast forward reading of some events
skip(const int)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     /// Get the global GenRunInfo object.
run_info()44     std::shared_ptr<GenRunInfo> run_info() const {
45         return m_run_info;
46     }
47 
48 ///deleted copy constructor
49     Reader(const Reader&) = delete;
50 ///deleted copy assignment operator
51     Reader& operator = (const Reader &) = delete;
52     /// Set options
set_options(const std::map<std::string,std::string> & options)53     void set_options(const std::map<std::string, std::string>& options)
54     {
55     m_options=options;
56     }
57     /// Set options
get_options()58     std::map<std::string, std::string> get_options() const
59     {
60     return m_options;
61     }
62 protected:
63     /// Set the global GenRunInfo object.
set_run_info(std::shared_ptr<GenRunInfo> run)64     void set_run_info(std::shared_ptr<GenRunInfo> run) {
65         m_run_info = run;
66     }
67         /// options
68     std::map<std::string, std::string> m_options;
69 private:
70     /// The global GenRunInfo object.
71     std::shared_ptr<GenRunInfo> m_run_info;
72 };
73 
74 
75 } // namespace HepMC3
76 
77 #endif
78