31WriterPlugin::WriterPlugin(std::shared_ptr<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::shared_ptr<std::ostream> stream, std::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__) || 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 using f_funci =
Writer* (*)(std::shared_ptr<std::ostream> stream, std::shared_ptr<GenRunInfo>);
45 auto newWriter = (f_funci)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(std::ostream & stream,
const std::string &libname,
const std::string &newwriter, std::shared_ptr<GenRunInfo> run) {
54 if (!
dll_handle) { printf(
"Error while loading library %s. Error code %i\n", libname.c_str(), GetLastError());
m_writer =
nullptr;
return; }
55 typedef Writer* (__stdcall *f_funci)(std::ostream & stream, std::shared_ptr<GenRunInfo>);
56 f_funci newWriter = (f_funci)GetProcAddress((HINSTANCE)(
dll_handle), newwriter.c_str());
57 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; }
61#if defined(__linux__) || defined(__darwin__) || defined(__APPLE__) || defined(BSD) || defined(__sun)
62 dll_handle = dlopen(libname.c_str(), RTLD_LAZY | RTLD_GLOBAL);
63 if (!
dll_handle) { printf(
"Error while loading library %s: %s\n", libname.c_str(), dlerror());
m_writer=
nullptr;
return; }
64 using f_funci =
Writer* (*)(std::ostream & stream, std::shared_ptr<GenRunInfo>);
65 auto newWriter = (f_funci)dlsym(
dll_handle, newwriter.c_str());
66 if (!newWriter) { printf(
"Error while loading function %s from library %s: %s\n", newwriter.c_str(), libname.c_str(), dlerror());
m_writer =
nullptr;
return; }
71WriterPlugin::WriterPlugin(
const std::string& filename,
const std::string &libname,
const std::string &newwriter, std::shared_ptr<GenRunInfo> run) {
74 if (!
dll_handle) { printf(
"Error while loading library %s. Error code %i\n", libname.c_str(), GetLastError());
m_writer =
nullptr;
return; }
75 typedef Writer* (__stdcall *f_funci)(
const std::string&, std::shared_ptr<GenRunInfo>);
76 f_funci newWriter = (f_funci)GetProcAddress((HINSTANCE)(
dll_handle), newwriter.c_str());
77 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; }
81#if defined(__linux__) || defined(__darwin__) || defined(__APPLE__) || defined(BSD) || defined(__sun)
82 dll_handle = dlopen(libname.c_str(), RTLD_LAZY | RTLD_GLOBAL);
83 if (!
dll_handle) { printf(
"Error while loading library %s: %s\n", libname.c_str(), dlerror());
m_writer =
nullptr;
return; }
84 using f_funci =
Writer* (*)(
const std::string&, std::shared_ptr<GenRunInfo>);
85 auto newWriter = (f_funci)dlsym(
dll_handle, newwriter.c_str());
86 if (!newWriter) { printf(
"Error while loading function %s from library %s: %s\n", newwriter.c_str(), libname.c_str(), dlerror());
m_writer =
nullptr;
return; }
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 >())
Constructor to write to stream.