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_WRITERPLUGIN_H
0007 #define HEPMC3_WRITERPLUGIN_H
0008 /**
0009  *  @file  WriterPlugin.h
0010  *  @brief Definition of \b class WriterPlugin
0011  *
0012  *  @class HepMC3::WriterPlugin
0013  *  @brief GenEvent I/O parsing and serialization using external plugin
0014  *
0015  *
0016  *  @ingroup IO
0017  *
0018  */
0019 #include "HepMC3/Writer.h"
0020 #include "HepMC3/GenEvent.h"
0021 namespace HepMC3
0022 {
0023 class WriterPlugin : public Writer
0024 {
0025 public:
0026     /** @brief Constructor  to write to stream */
0027     WriterPlugin(std::shared_ptr<std::ostream> stream, const std::string &libname, const std::string &newwriter, std::shared_ptr<HepMC3::GenRunInfo> run = std::shared_ptr<GenRunInfo>());
0028 
0029     /** @brief Constructor  to write to stream */
0030     WriterPlugin(std::ostream & stream, const std::string &libname, const std::string &newwriter, std::shared_ptr<HepMC3::GenRunInfo> run = std::shared_ptr<GenRunInfo>());
0031 
0032     /** @brief Constructor to write to file */
0033     WriterPlugin(const std::string& filename, const std::string &libname, const std::string &newwriter, std::shared_ptr<HepMC3::GenRunInfo> run = std::shared_ptr<GenRunInfo>());
0034 
0035     /** @brief Reading event */
0036     void write_event(const GenEvent& ev) override {if (!m_writer) return; return m_writer->write_event(ev);};
0037     /** @brief Close */
0038     void close() override { if (!m_writer) return; m_writer->close();};
0039     /** @brief State */
0040     bool failed() override {if (!m_writer) return true; return m_writer->failed();};
0041     /** @brief Get the global GenRunInfo object. */
0042     std::shared_ptr<GenRunInfo> run_info()  const override { return m_writer?m_writer->run_info():nullptr; }
0043     /** @brief  Set options */
0044     void set_options(const std::map<std::string, std::string>& options)  override { if (!m_writer) return; else m_writer->set_options(options); }
0045     /** @brief  Get options  */
0046     std::map<std::string, std::string> get_options()  const  override { return m_writer?m_writer->get_options(): std::map<std::string, std::string>();  }
0047     /// Set the global GenRunInfo object.
0048     void set_run_info(std::shared_ptr<GenRunInfo> run) override { if (!m_writer) return; else m_writer->set_run_info(run); }
0049     /** @brief Destructor */
0050     ~WriterPlugin()  override;
0051 private:
0052     Writer* m_writer = nullptr; ///< The actual writer
0053     void* dll_handle = nullptr; ///< library handler
0054 };
0055 }
0056 #endif