Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:14

0001 // -*- C++ -*-
0002 //
0003 // This file is part of HepMC
0004 // Copyright (C) 2014-2023 The HepMC collaboration (see AUTHORS for details)
0005 //
0006 #ifndef HEPMC3_READERPLUGIN_H
0007 #define HEPMC3_READERPLUGIN_H
0008 /**
0009  *  @file  ReaderPlugin.h
0010  *  @brief Definition of \b class ReaderPlugin
0011  *
0012  *  @class HepMC3::ReaderPlugin
0013  *  @brief GenEvent I/O parsing and serialization using external plugin
0014  *
0015  *
0016  *  @ingroup IO
0017  *
0018  */
0019 #include "HepMC3/Reader.h"
0020 #include "HepMC3/GenEvent.h"
0021 namespace HepMC3
0022 {
0023 class ReaderPlugin : public Reader
0024 {
0025 public:
0026     /** @brief Constructor  to read from stream*/
0027     ReaderPlugin(std::shared_ptr<std::istream> stream, const std::string &libname, const std::string &newreader);
0028     /** @brief Constructor  to read from stream*/
0029     ReaderPlugin(std::istream & stream, const std::string &libname, const std::string &newreader);
0030     /** @brief Constructor to read from file*/
0031     ReaderPlugin(const std::string& filename, const std::string &libname, const std::string &newreader);
0032     /** @brief Skip or fast forward reading of some events*/
0033     bool skip(const int n) override { if (!m_reader) return false; return m_reader->skip(n); }
0034     /** @brief Reading event */
0035     bool read_event(GenEvent& ev)  override {if (!m_reader) return false; return m_reader->read_event(ev);};
0036     /** @brief Close */
0037     void close() override { if (!m_reader) return; m_reader->close(); };
0038     /** @brief State */
0039     bool failed() override { if (!m_reader) return true; return m_reader->failed();};
0040     /** @brief Get the global GenRunInfo object. */
0041     std::shared_ptr<GenRunInfo> run_info() const  override  { return m_reader?m_reader->run_info():nullptr; }
0042     /** @brief  Set options */
0043     void set_options(const std::map<std::string, std::string>& options)  override { if (!m_reader) return; else m_reader->set_options(options); }
0044     /** @brief  Get options  */
0045     std::map<std::string, std::string> get_options()  const  override { return m_reader?m_reader->get_options(): std::map<std::string, std::string>();  }
0046     /** @brief Destructor */
0047     ~ReaderPlugin()  override;
0048     /// Set the global GenRunInfo object.
0049     void set_run_info(std::shared_ptr<GenRunInfo> run) override { if (!m_reader) return; else m_reader->set_run_info(run); }
0050 private:
0051     Reader* m_reader = nullptr; ///< The actual reader
0052     void*  dll_handle = nullptr; ///< library handler
0053 };
0054 }
0055 #endif