HepMC3 event record library
ReaderPlugin.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_READERPLUGIN_H
7 #define HEPMC3_READERPLUGIN_H
8 /**
9  * @file ReaderPlugin.h
10  * @brief Definition of \b class ReaderPlugin
11  *
12  * @class HepMC3::ReaderPlugin
13  * @brief GenEvent I/O parsing and serialization using external plugin
14  *
15  *
16  * @ingroup IO
17  *
18  */
19 #include "HepMC3/Reader.h"
20 #include "HepMC3/GenEvent.h"
21 namespace HepMC3
22 {
23 class ReaderPlugin : public Reader
24 {
25 public:
26  /** @brief Constructor to read from stream*/
27  ReaderPlugin(std::istream & stream,const std::string &libname, const std::string &newreader);
28  /** @brief Constructor to read from file*/
29  ReaderPlugin(const std::string& filename,const std::string &libname, const std::string &newreader);
30  /** @brief Reading event */
31  bool read_event(GenEvent& ev) override {if (!m_reader) return false; return m_reader->read_event(ev);};
32  /** @brief Close */
33  void close() override { if (!m_reader) return; m_reader->close(); };
34  /** @brief State */
35  bool failed() override {if (!m_reader) return true; return m_reader->failed();};
36  /** @brief Destructor */
37  ~ReaderPlugin() override;
38 private:
39  Reader* m_reader; ///< The actual reader
40  void* dll_handle; ///< library handler
41 };
42 }
43 #endif
Definition of class GenEvent.
Definition of interface Reader.
Stores event-related information.
Definition: GenEvent.h:41
GenEvent I/O parsing and serialization using external plugin.
Definition: ReaderPlugin.h:24
ReaderPlugin(std::istream &stream, const std::string &libname, const std::string &newreader)
Constructor to read from stream.
Definition: ReaderPlugin.cc:28
bool failed() override
State.
Definition: ReaderPlugin.h:35
bool read_event(GenEvent &ev) override
Reading event.
Definition: ReaderPlugin.h:31
~ReaderPlugin() override
Destructor.
Definition: ReaderPlugin.cc:71
void close() override
Close.
Definition: ReaderPlugin.h:33
Reader * m_reader
The actual reader.
Definition: ReaderPlugin.h:39
void * dll_handle
library handler
Definition: ReaderPlugin.h:40
Base class for all I/O readers.
Definition: Reader.h:25
virtual bool read_event(GenEvent &evt)=0
Fill next event from input into evt.
virtual bool failed()=0
Get file and/or stream error state.
virtual void close()=0
Close file and/or stream.
HepMC3 main namespace.