45 : m_DllNamePrefix(
"ncbi_plugin"),
46 m_EntryPointPrefix(
"NCBI_EntryPoint"),
53 const string& interface_name,
54 const string& driver_name,
57 : m_DllNamePrefix(
"ncbi_plugin"),
58 m_EntryPointPrefix(
"NCBI_EntryPoint"),
59 m_InterfaceName(interface_name),
60 m_DriverName(driver_name),
63 m_AutoUnloadDll(unload_dll)
74 const string& driver_name,
81 const string& drv = driver_name.empty() ?
m_DriverName : driver_name;
89 masks.push_back(
mask);
93 masks.push_back(
mask);
94 #if defined(NCBI_OS_UNIX)
96 masks.push_back(
mask);
106 vector<string> paths;
107 paths.push_back(path);
114 const string& driver_name,
119 if (!interface_name.empty()) {
121 name.append(interface_name);
123 if (!driver_name.empty()) {
125 name.append(driver_name);
132 #if defined(NCBI_OS_MSWIN)
134 #elif defined(NCBI_OS_UNIX)
150 const string& interface_name,
151 const string& driver_name,
157 if ( !name.empty() ) {
160 if (interface_name.empty()) {
163 name.append(interface_name);
167 if (driver_name.empty()) {
170 name.append(driver_name);
178 #if defined(NCBI_OS_MSWIN)
180 #elif defined(NCBI_OS_UNIX)
217 const string& interface_name,
218 const string& driver_name)
const
222 if (!interface_name.empty()) {
224 name.append(interface_name);
226 if (!driver_name.empty()) {
228 name.append(driver_name);
254 vector<string> entry_point_names;
262 entry_point_names.push_back(entry_name);
265 entry_point_names.push_back(entry_name);
268 entry_point_names.push_back(entry_name);
271 entry_point_names.push_back(entry_name);
274 string base_name_templ =
"${basename}";
279 entry_name.append(
"_");
280 entry_name.append(base_name_templ);
281 entry_point_names.push_back(entry_name);
286 entry_name.append(
"_");
288 entry_name.append(
"_");
289 entry_name.append(base_name_templ);
290 entry_point_names.push_back(entry_name);
296 entry_name.append(
"_");
298 entry_name.append(
"_");
299 entry_name.append(base_name_templ);
300 entry_point_names.push_back(entry_name);
316 #if defined(NCBI_PLUGIN_AUTO_LOAD) || defined(NCBI_DLL_BUILD)
317 # define LOAD_PLUGINS_FROM_DLLS_BY_DEFAULT true
319 # define LOAD_PLUGINS_FROM_DLLS_BY_DEFAULT false
330 return TLoadPluginsFromDLLsParam::GetDefault();
340 TLoadPluginsFromDLLsParam::SetDefault(enable);
Class for entry point resolution when there are several DLL candidates.
EAutoUnload
Whether to unload DLL in the destructor.
#define NCBI_PLUGIN_SUFFIX
#define NCBI_PLUGIN_PREFIX
void FindCandidates(const TClass1 &paths, const TClass2 &masks, TExtraDllPath extra_path=fDefaultDllPath, const string &driver_name=kEmptyStr)
Try to resolve all files matching the specified masks in the specified directories.
TErrCode GetErrCode(void) const
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
@ eParam_NoThread
Do not use per-thread values.
CDllResolver * GetCreateDllResolver()
static bool IsEnabledGlobally()
Return whether to allow loading plugins from DLLs in general.
virtual void SetDllNamePrefix(const string &prefix)
Set DLL file name prefix.
vector< string > TSearchPaths
Container for the DLL search paths.
virtual const char * GetErrCodeString(void) const override
Translate from the error code value to its string representation.
CDllResolver * CreateDllResolver() const
CDll::EAutoUnload m_AutoUnloadDll
CDllResolver & ResolveFile(const TSearchPaths &paths, const string &driver_name=kEmptyStr, const CVersionInfo &version=CVersionInfo::kAny, CDllResolver::TExtraDllPath std_path=CDllResolver::fDefaultDllPath)
Search for plugin DLLs, resolve entry points.
string m_EntryPointPrefix
virtual string GetEntryPointPrefix() const
Return DLL entry point prefix ("NCBI_EntryPoint")
static bool IsEnabledGloballyByDefault()
Return whether to allow loading plugins from DLLs in general by default.
virtual ~CPluginManager_DllResolver(void)
CDllResolver & Resolve(const string &path)
Search for plugin DLLs, resolve entry points.
virtual string GetDllNamePrefix() const
Return DLL file name prefix ("ncbi_plugin")
CDllResolver * m_DllResolver
static void EnableGlobally(bool enable=true)
Enable (or disable, if called with enable = false) loading plugins from DLLs in general.
virtual string GetDllNameMask(const string &interface_name, const string &driver_name=kEmptyStr, const CVersionInfo &version=CVersionInfo::kAny, EVersionLocation ver_lct=eBeforeSuffix) const
Return DLL name mask.
CPluginManager_DllResolver(void)
virtual string GetEntryPointName(const string &interface_name=kEmptyStr, const string &driver_name=kEmptyStr) const
Return DLL entry point name:
virtual string GetDllName(const string &interface_name, const string &driver_name=kEmptyStr, const CVersionInfo &version=CVersionInfo::kAny) const
Return dll file name.
@ eResolveFailure
Cannot resolve interface driver.
@ eParameterMissing
Missing mandatory parameter.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
const string version
version string
Define class Dll and for Portable DLL handling.
NCBI_PARAM_DEF_EX(bool, NCBI, Load_Plugins_From_DLLs, false, eParam_NoThread, NCBI_LOAD_PLUGINS_FROM_DLLS)
NCBI_PARAM_DECL(bool, NCBI, Load_Plugins_From_DLLs)
typedef NCBI_PARAM_TYPE(NCBI, Load_Plugins_From_DLLs) TLoadPluginsFromDLLsParam
#define LOAD_PLUGINS_FROM_DLLS_BY_DEFAULT
Plugin manager (using class factory paradigm).
static const char delimiter[]