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-2020 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"
21 namespace HepMC3
22 {
23 class WriterPlugin : public Writer
24 {
25 public:
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 
31 /** @brief Constructor to read from file*/
32 WriterPlugin(const std::string& filename,const std::string &libname, const std::string &newwriter, std::shared_ptr<HepMC3::GenRunInfo>run=std::shared_ptr<GenRunInfo>());
33 
34  /** @brief Reading event */
35  void write_event(const GenEvent& ev) override{if(!m_writer) return; return m_writer->write_event(ev);};
36  /** @brief Close */
37  void close() override{ if(!m_writer) return; m_writer->close();};
38  /** @brief State */
39  bool failed() override{if(!m_writer) return true; return m_writer->failed();};
40  /** @brief Destructor */
41 ~WriterPlugin() override;
42 private:
43  Writer* m_writer; ///< The actual writer
44  void* dll_handle; ///< library handler
45  };
46 }
47 #endif
virtual void write_event(const GenEvent &evt)=0
Write event evt to output target.
GenEvent I/O parsing and serialization using external plugin.
Definition: WriterPlugin.h:23
virtual void close()=0
Close file and/or stream.
void write_event(const GenEvent &ev) override
Reading event.
Definition: WriterPlugin.h:35
virtual bool failed()=0
Get file and/or stream error state.
Writer * m_writer
The actual writer.
Definition: WriterPlugin.h:43
Stores event-related information.
Definition: GenEvent.h:41
void close() override
Close.
Definition: WriterPlugin.h:37
Definition of interface Writer.
bool failed() override
State.
Definition: WriterPlugin.h:39
void * dll_handle
library handler
Definition: WriterPlugin.h:44
Base class for all I/O writers.
Definition: Writer.h:25
Definition of class GenEvent.
WriterPlugin(std::ostream &stream, const std::string &libname, const std::string &newwriter, std::shared_ptr< HepMC3::GenRunInfo >run=std::shared_ptr< GenRunInfo >())
Constructor to read from stream.
~WriterPlugin() override
Destructor.
Definition: WriterPlugin.cc:76