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-2023 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"
21namespace HepMC3
22{
23class ReaderPlugin : public Reader
24{
25public:
26 /** @brief Constructor to read from stream*/
27 ReaderPlugin(std::shared_ptr<std::istream> stream, const std::string &libname, const std::string &newreader);
28 /** @brief Constructor to read from stream*/
29 ReaderPlugin(std::istream & stream, const std::string &libname, const std::string &newreader);
30 /** @brief Constructor to read from file*/
31 ReaderPlugin(const std::string& filename, const std::string &libname, const std::string &newreader);
32 /** @brief Skip or fast forward reading of some events*/
33 bool skip(const int n) override { if (!m_reader) return false; return m_reader->skip(n); }
34 /** @brief Reading event */
35 bool read_event(GenEvent& ev) override {if (!m_reader) return false; return m_reader->read_event(ev);};
36 /** @brief Close */
37 void close() override { if (!m_reader) return; m_reader->close(); };
38 /** @brief State */
39 bool failed() override { if (!m_reader) return true; return m_reader->failed();};
40 /** @brief Get the global GenRunInfo object. */
41 std::shared_ptr<GenRunInfo> run_info() const override { return m_reader?m_reader->run_info():nullptr; }
42 /** @brief Set options */
43 void set_options(const std::map<std::string, std::string>& options) override { if (!m_reader) return; else m_reader->set_options(options); }
44 /** @brief Get options */
45 std::map<std::string, std::string> get_options() const override { return m_reader?m_reader->get_options(): std::map<std::string, std::string>(); }
46 /** @brief Destructor */
47 ~ReaderPlugin() override;
48 /// Set the global GenRunInfo object.
49 void set_run_info(std::shared_ptr<GenRunInfo> run) override { if (!m_reader) return; else m_reader->set_run_info(run); }
50private:
51 Reader* m_reader = nullptr; ///< The actual reader
52 void* dll_handle = nullptr; ///< library handler
53};
54}
55#endif
Definition of class GenEvent.
Definition of interface Reader.
Stores event-related information.
Definition GenEvent.h:47
std::map< std::string, std::string > get_options() const override
Get options.
void set_run_info(std::shared_ptr< GenRunInfo > run) override
Set the global GenRunInfo object.
bool failed() override
State.
bool read_event(GenEvent &ev) override
Reading event.
~ReaderPlugin() override
Destructor.
bool skip(const int n) override
Skip or fast forward reading of some events.
void set_options(const std::map< std::string, std::string > &options) override
Set options.
void close() override
Close.
ReaderPlugin(std::shared_ptr< std::istream > stream, const std::string &libname, const std::string &newreader)
Constructor to read from stream.
Reader * m_reader
The actual reader.
std::shared_ptr< GenRunInfo > run_info() const override
Get the global GenRunInfo object.
void * dll_handle
library handler
Reader()
Constructor.
Definition Reader.h:28
HepMC3 main namespace.