11#define WIN32_LEAN_AND_MEAN
12#define NOWINBASEINTERLOCK
18#if defined(__linux__) || defined(__darwin__) || defined(__APPLE__) || defined(BSD) || defined(__sun)
29WriterPlugin::WriterPlugin(std::ostream & stream,
const std::string &libname,
const std::string &newwriter, std::shared_ptr<GenRunInfo> run) {
33 if (!
dll_handle) { printf(
"Error while loading library %s. Error code %i\n", libname.c_str(), GetLastError());
m_writer =
nullptr;
return; }
34 typedef Writer* (__stdcall *f_funci)(std::ostream & stream, shared_ptr<GenRunInfo>);
35 f_funci newWriter = (f_funci)GetProcAddress((HINSTANCE)(
dll_handle), newwriter.c_str());
36 if (!newWriter) { printf(
"Error while loading function %s from library %s. Error code %i\n", newwriter.c_str(), libname.c_str(), GetLastError());
m_writer =
nullptr;
return; }
40#if defined(__linux__) || defined(__darwin__) || defined(__APPLE__) || defined(BSD) || defined(__sun)
42 dll_handle = dlopen(libname.c_str(), RTLD_LAZY | RTLD_GLOBAL);
43 if (!
dll_handle) { printf(
"Error while loading library %s: %s\n", libname.c_str(), dlerror());
m_writer=
nullptr;
return; }
44 Writer* (*newWriter)(std::ostream & stream, std::shared_ptr<GenRunInfo>);
45 newWriter = (
Writer* (*)(std::ostream & stream, std::shared_ptr<GenRunInfo>))dlsym(
dll_handle, newwriter.c_str());
46 if (!newWriter) { printf(
"Error while loading function %s from library %s: %s\n", newwriter.c_str(), libname.c_str(), dlerror());
m_writer =
nullptr;
return; }
51WriterPlugin::WriterPlugin(
const std::string& filename,
const std::string &libname,
const std::string &newwriter, std::shared_ptr<GenRunInfo> run) {
55 if (!
dll_handle) { printf(
"Error while loading library %s. Error code %i\n", libname.c_str(), GetLastError());
m_writer =
nullptr;
return; }
56 typedef Writer* (__stdcall *f_funci)(
const std::string&, shared_ptr<GenRunInfo>);
57 f_funci newWriter = (f_funci)GetProcAddress((HINSTANCE)(
dll_handle), newwriter.c_str());
58 if (!newWriter) { printf(
"Error while loading function %s from library %s. Error code %i\n", newwriter.c_str(), libname.c_str(), GetLastError());
m_writer =
nullptr;
return; }
62#if defined(__linux__) || defined(__darwin__) || defined(__APPLE__) || defined(BSD) || defined(__sun)
64 dll_handle = dlopen(libname.c_str(), RTLD_LAZY | RTLD_GLOBAL);
65 if (!
dll_handle) { printf(
"Error while loading library %s: %s\n", libname.c_str(), dlerror());
m_writer =
nullptr;
return; }
66 Writer* (*newWriter)(
const std::string&, std::shared_ptr<GenRunInfo>);
67 newWriter = (
Writer* (*)(
const std::string&, std::shared_ptr<GenRunInfo>))dlsym(
dll_handle, newwriter.c_str());
68 if (!newWriter) { printf(
"Error while loading function %s from library %s: %s\n", newwriter.c_str(), libname.c_str(), dlerror());
m_writer =
nullptr;
return; }
81#if defined(__linux__) || defined(__darwin__) || defined(__APPLE__) || defined(BSD) || defined(__sun)
Definition of class GenEvent.
Definition of class WriterPlugin.
~WriterPlugin() override
Destructor.
Writer * m_writer
The actual writer.
void * dll_handle
library handler
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.
Base class for all I/O writers.
virtual void close()=0
Close file and/or stream.