HepMC3 event record library: ReaderPlugin.h Source File

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{
23 class 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
GenEvent.h
Definition of class GenEvent.
Reader.h
Definition of interface Reader.
HepMC3::GenEvent
Stores event-related information.
Definition GenEvent.h:47
HepMC3::ReaderPlugin::get_options
std::map< std::string, std::string > get_options() const override
Get options.
Definition ReaderPlugin.h:45
HepMC3::ReaderPlugin::set_run_info
void set_run_info(std::shared_ptr< GenRunInfo > run) override
Set the global GenRunInfo object.
Definition ReaderPlugin.h:49
HepMC3::ReaderPlugin::failed
bool failed() override
State.
Definition ReaderPlugin.h:39
HepMC3::ReaderPlugin::read_event
bool read_event(GenEvent &ev) override
Reading event.
Definition ReaderPlugin.h:35
HepMC3::ReaderPlugin::~ReaderPlugin
~ReaderPlugin() override
Destructor.
Definition ReaderPlugin.cc:86
HepMC3::ReaderPlugin::skip
bool skip(const int n) override
Skip or fast forward reading of some events.
Definition ReaderPlugin.h:33
HepMC3::ReaderPlugin::set_options
void set_options(const std::map< std::string, std::string > &options) override
Set options.
Definition ReaderPlugin.h:43
HepMC3::ReaderPlugin::close
void close() override
Close.
Definition ReaderPlugin.h:37
HepMC3::ReaderPlugin::ReaderPlugin
ReaderPlugin(std::shared_ptr< std::istream > stream, const std::string &libname, const std::string &newreader)
Constructor to read from stream.
Definition ReaderPlugin.cc:27
HepMC3::ReaderPlugin::m_reader
Reader * m_reader
The actual reader.
Definition ReaderPlugin.h:51
HepMC3::ReaderPlugin::run_info
std::shared_ptr< GenRunInfo > run_info() const override
Get the global GenRunInfo object.
Definition ReaderPlugin.h:41
HepMC3::ReaderPlugin::dll_handle
void * dll_handle
library handler
Definition ReaderPlugin.h:52
HepMC3::Reader::Reader
Reader()
Constructor.
Definition Reader.h:28
HepMC3
HepMC3 main namespace.
Definition AnalysisExample.h:24