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