18 #ifndef NVDS3D_CUSTOMLIB_FACTORY_HPP
19 #define NVDS3D_CUSTOMLIB_FACTORY_HPP
22 #include <ds3d/common/common.h>
34 return reinterpret_cast<T*
>(dlsym(handle, name));
50 template <
class CustomRefCtx>
51 CustomRefCtx*
CreateCtx(
const std::string& libName,
const std::string& symName)
55 _libHandle = dlopen(libName.c_str(), RTLD_NOW | RTLD_LOCAL);
58 _libName == libName || libName.empty(),
nullptr,
59 "CustomLibFactory existing libname: %s is different from new lib: %s",
65 LOG_INFO(
"Library Opened Successfully");
67 std::function<CustomRefCtx*()> createCtxFunc =
70 createCtxFunc,
nullptr,
"dlsym: %s not found, error: %s", symName.c_str(), dlerror());
72 CustomRefCtx* customCtx = createCtxFunc();
74 customCtx,
nullptr,
"create custom context failed during call: %s", symName.c_str());
75 LOG_INFO(
"Custom Context created from %s", symName.c_str());