11 #define WIN32_LEAN_AND_MEAN
12 #define NOWINBASEINTERLOCK
18 #if defined(__linux__) || defined(__darwin__)
29 WriterPlugin::WriterPlugin(std::ostream & stream,
const std::string &libname,
const std::string &newwriter,std::shared_ptr<GenRunInfo> run) {
34 if (!
dll_handle) { printf(
"Error while loading library %s. Error code %i\n",libname.c_str(),GetLastError());
m_writer=
nullptr;
return; }
35 typedef Writer* (__stdcall *f_funci)(std::ostream & stream,shared_ptr<GenRunInfo>);
36 f_funci newWriter = (f_funci)GetProcAddress((HINSTANCE)(
dll_handle), newwriter.c_str());
37 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; }
41 #if defined(__linux__) || defined(__darwin__)
43 dll_handle = dlopen(libname.c_str(), RTLD_LAZY | RTLD_GLOBAL);
44 if (!
dll_handle) { printf(
"Error while loading library %s: %s\n",libname.c_str(),dlerror());
m_writer=
nullptr;
return; }
45 Writer* (*newWriter)(std::ostream & stream,std::shared_ptr<GenRunInfo>);
46 newWriter=(
Writer* (*)(std::ostream & stream,std::shared_ptr<GenRunInfo>))dlsym(
dll_handle, newwriter.c_str());
47 if (!newWriter) { printf(
"Error while loading function %s from library %s: %s\n",newwriter.c_str(),libname.c_str(),dlerror());
m_writer=
nullptr;
return; }
53 WriterPlugin::WriterPlugin(
const std::string& filename,
const std::string &libname,
const std::string &newwriter,std::shared_ptr<GenRunInfo> run) {
58 if (!
dll_handle) { printf(
"Error while loading library %s. Error code %i\n",libname.c_str(),GetLastError());
m_writer=
nullptr;
return; }
59 typedef Writer* (__stdcall *f_funci)(
const std::string&,shared_ptr<GenRunInfo>);
60 f_funci newWriter = (f_funci)GetProcAddress((HINSTANCE)(
dll_handle), newwriter.c_str());
61 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; }
65 #if defined(__linux__) || defined(__darwin__)
67 dll_handle = dlopen(libname.c_str(), RTLD_LAZY | RTLD_GLOBAL);
68 if (!
dll_handle) { printf(
"Error while loading library %s: %s\n",libname.c_str(),dlerror());
m_writer=
nullptr;
return; }
69 Writer* (*newWriter)(
const std::string&,std::shared_ptr<GenRunInfo>);
70 newWriter=(
Writer* (*)(
const std::string&,std::shared_ptr<GenRunInfo>))dlsym(
dll_handle, newwriter.c_str());
71 if (!newWriter) { printf(
"Error while loading function %s from library %s: %s\n",newwriter.c_str(),libname.c_str(),dlerror());
m_writer=
nullptr;
return; }
84 #if defined(__linux__) || defined(__darwin__)
virtual void close()=0
Close file and/or stream.
Writer * m_writer
The actual writer.
Definition of class WriterPlugin.
void * dll_handle
library handler
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.