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-2020 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
GenEvent I/O parsing and serialization using external plugin.
Definition: ReaderPlugin.h:23
void close() override
Close.
Definition: ReaderPlugin.h:33
Definition of interface Reader.
virtual void close()=0
Close file and/or stream.
bool failed() override
State.
Definition: ReaderPlugin.h:35
virtual bool failed()=0
Get file and/or stream error state.
virtual bool read_event(GenEvent &evt)=0
Fill next event from input into evt.
~ReaderPlugin() override
Destructor.
Definition: ReaderPlugin.cc:74
Reader * m_reader
The actual reader.
Definition: ReaderPlugin.h:39
void * dll_handle
library handler
Definition: ReaderPlugin.h:40
Stores event-related information.
Definition: GenEvent.h:41
Definition of class GenEvent.
ReaderPlugin(std::istream &stream, const std::string &libname, const std::string &newreader)
Constructor to read from stream.
Definition: ReaderPlugin.cc:28
Base class for all I/O readers.
Definition: Reader.h:25
bool read_event(GenEvent &ev) override
Reading event.
Definition: ReaderPlugin.h:31