24 #ifndef PLUGINTEMPLATE_H_
25 #define PLUGINTEMPLATE_H_
43 logInfo(
"getCreateFunction : Trying to load library with name: ",libname);
46 char* fileWithPath =
const_cast<char*
>(libname.c_str());
47 std::string libFileName = basename(fileWithPath);
50 std::string createFunctionName = libFileName.substr(3, libFileName.length() - 6) +
"Factory";
53 libraryHandle = dlopen(libname.c_str(), RTLD_LAZY );
54 const char* dlopen_error = dlerror();
55 if (!libraryHandle || dlopen_error)
57 logError(
"getCreateFunction : dlopen failed",dlopen_error);
74 functionPointer.voidPointer = dlsym(libraryHandle, createFunctionName.c_str());
75 T* createFunction = functionPointer.typedPointer;
77 const char* dlsym_error = dlerror();
78 if (!createFunction || dlsym_error)
80 logError(
"getCreateFunction: Failed to load shared lib entry point",dlsym_error);
84 logInfo(
"getCreateFunction : loaded successfully plugin", createFunctionName);
86 return (createFunction);
void logInfo(T value, TArgs...args)
logs given values with infolevel with the default context
T * getCreateFunction(const std::string &libname, void *&libraryHandle)
SPDX license identifier: MPL-2.0.
void logError(T value, TArgs...args)
logs given values with errorlevel with the default context