13 #ifndef NVDS3D_CUSTOMLIB_FACTORY_HPP
14 #define NVDS3D_CUSTOMLIB_FACTORY_HPP
29 return reinterpret_cast<T*
>(dlsym(handle, name));
43 template <
class CustomRefCtx>
44 CustomRefCtx*
CreateCtx(
const std::string& libName,
const std::string& symName)
48 _libHandle = dlopen(libName.c_str(), RTLD_NOW | RTLD_LOCAL);
51 _libName == libName || libName.empty(),
nullptr,
52 "CustomLibFactory existing libname: %s is different from new lib: %s",
58 LOG_INFO(
"Library Opened Successfully");
60 std::function<CustomRefCtx*()> createCtxFunc =
63 createCtxFunc,
nullptr,
"dlsym: %s not found, error: %s", symName.c_str(), dlerror());
65 CustomRefCtx* customCtx = createCtxFunc();
67 customCtx,
nullptr,
"create custom context failed during call: %s", symName.c_str());
68 LOG_INFO(
"Custom Context created from %s", symName.c_str());