HepMC3 event record library
WriterPlugin.h
Go to the documentation of this file.
1// -*- C++ -*-
2//
3// This file is part of HepMC
4// Copyright (C) 2014-2021 The HepMC collaboration (see AUTHORS for details)
5//
6#ifndef HEPMC3_WRITERPLUGIN_H
7#define HEPMC3_WRITERPLUGIN_H
8/**
9 * @file WriterPlugin.h
10 * @brief Definition of \b class WriterPlugin
11 *
12 * @class HepMC3::WriterPlugin
13 * @brief GenEvent I/O parsing and serialization using external plugin
14 *
15 *
16 * @ingroup IO
17 *
18 */
19#include "HepMC3/Writer.h"
20#include "HepMC3/GenEvent.h"
21namespace HepMC3
22{
23class WriterPlugin : public Writer
24{
25public:
26
27 /** @brief Constructor to read from stream */
28 WriterPlugin(std::ostream & stream,const std::string &libname, const std::string &newwriter, std::shared_ptr<HepMC3::GenRunInfo> run = std::shared_ptr<GenRunInfo>());
29
30 /** @brief Constructor to read from file */
31 WriterPlugin(const std::string& filename,const std::string &libname, const std::string &newwriter, std::shared_ptr<HepMC3::GenRunInfo> run = std::shared_ptr<GenRunInfo>());
32
33 /** @brief Reading event */
34 void write_event(const GenEvent& ev) override {if (!m_writer) return; return m_writer->write_event(ev);};
35 /** @brief Close */
36 void close() override { if (!m_writer) return; m_writer->close();};
37 /** @brief State */
38 bool failed() override {if (!m_writer) return true; return m_writer->failed();};
39 /** @brief Destructor */
40 ~WriterPlugin() override;
41private:
42 Writer* m_writer; ///< The actual writer
43 void* dll_handle; ///< library handler
44};
45}
46#endif
Definition of class GenEvent.
Definition of interface Writer.
Stores event-related information.
Definition: GenEvent.h:41
GenEvent I/O parsing and serialization using external plugin.
Definition: WriterPlugin.h:24
~WriterPlugin() override
Destructor.
Definition: WriterPlugin.cc:73
bool failed() override
State.
Definition: WriterPlugin.h:38
Writer * m_writer
The actual writer.
Definition: WriterPlugin.h:42
void close() override
Close.
Definition: WriterPlugin.h:36
void write_event(const GenEvent &ev) override
Reading event.
Definition: WriterPlugin.h:34
void * dll_handle
library handler
Definition: WriterPlugin.h:43
Base class for all I/O writers.
Definition: Writer.h:25
virtual void write_event(const GenEvent &evt)=0
Write event evt to output target.
virtual bool failed()=0
Get file and/or stream error state.
virtual void close()=0
Close file and/or stream.
HepMC3 main namespace.