Page MenuHomeHEPForge

get_analysis.cc
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

get_analysis.cc

/**
* \authors The HEJ collaboration (see AUTHORS for details)
* \date 2019
* \copyright GPLv2 or later
*/
#include "HEJ/get_analysis.hh"
#include <dlfcn.h>
#include <string>
#include "yaml-cpp/yaml.h"
#include "HEJ/EmptyAnalysis.hh"
#include "HEJ/RivetAnalysis.hh"
namespace HEJ{
std::unique_ptr<Analysis> get_analysis(YAML::Node const & parameters){
if(!parameters["plugin"]){
if(parameters["rivet"])
return RivetAnalysis::create(parameters);
return EmptyAnalysis::create(parameters);
}
using AnalysisMaker = std::unique_ptr<Analysis> (*)(YAML::Node);
const auto plugin_name = parameters["plugin"].as<std::string>();
auto handle = dlopen(plugin_name.c_str(), RTLD_NOW);
char * error = dlerror();
if(error != nullptr) throw std::runtime_error(error);
void * sym = dlsym(handle, "make_analysis");
error = dlerror();
if(error != nullptr) throw std::runtime_error(error);
auto make_analysis = reinterpret_cast<AnalysisMaker>(sym);
return make_analysis(parameters);
}
}

File Metadata

Mime Type
text/x-c
Expires
Tue, Sep 30, 6:09 AM (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6405135
Default Alt Text
get_analysis.cc (1 KB)

Event Timeline