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);
96 logInfo(
"destroy : Trying to destroy : ",libname);
99 char* fileWithPath =
const_cast<char*
>(libname.c_str());
100 std::string libFileName = basename(fileWithPath);
103 std::string destroyFunctionName =
"destroy" + libFileName.substr(3, libFileName.length() - 6);
113 functionPointer.voidPointer = dlsym(libraryHandle, destroyFunctionName.c_str());
114 T* destroyFunction = functionPointer.typedPointer;
116 const char* dlsym_error = dlerror();
117 if (!destroyFunction || dlsym_error)
119 logError(
"getDestroyFunction: Failed to load shared lib entry point function name=",
120 destroyFunctionName,
"error=",dlsym_error);
124 logInfo(
"getDestroyFunction: loaded successfully plugin", destroyFunctionName);
126 return (destroyFunction);
A Common-API wrapper class, which loads the common-api runtime and instantiates all necessary objects...
void logInfo(T value, TArgs...args)
logs given values with infolevel with the default context
SPDX license identifier: MPL-2.0.
T * getCreateFunction(const std::string &libname, void *&libraryHandle)
void logError(T value, TArgs...args)
logs given values with errorlevel with the default context
T * getDestroyFunction(const std::string &libname, void *libraryHandle)