50 T GetFromMacro(
const std::string&
file,
const std::string& funcname,
const std::string&
type,
const std::string& unique)
57 auto firstindex =
file.find_last_of(
"/") + 1;
58 auto lastindex =
file.find_last_of(
".");
60 lastindex <
size ? lastindex - firstindex :
size - firstindex) +
63 auto gfunc =
func.substr(0,
func.find_first_of(
'('));
66 if (!gROOT->GetGlobalFunction(gfunc.c_str())) {
67 if (gROOT->LoadMacro(
file.c_str()) != 0) {
68 std::cout <<
"Cannot find " <<
file << std::endl;
71 if (!gROOT->GetGlobalFunction(gfunc.c_str())) {
72 std::cout <<
"Global function '" << gfunc <<
"' not defined" << std::endl;
78 if (strcmp(gROOT->GetGlobalFunction(gfunc.c_str())->GetReturnTypeName(),
type.c_str())) {
79 std::cout <<
"Global function '" << gfunc <<
"' does not return a '" <<
type <<
"' type" << std::endl;
84 gROOT->ProcessLine(Form(
"%s __%s__ = %s;",
type.c_str(), unique.c_str(),
func.c_str()));
85 auto ptr = (T*)gROOT->GetGlobal(Form(
"__%s__", unique.c_str()))->GetAddress();