1 #include "DynLibLoaderWin.hxx"
5 using namespace YACS::BASES;
7 const char DynLibLoaderWin::_extForDynLib[]=".dll";
9 DynLibLoaderWin::DynLibLoaderWin(const std::string& libNameWithoutExtension):_libName(libNameWithoutExtension),
14 DynLibLoaderWin::~DynLibLoaderWin()
16 if(_handleOnLoadedLib)
17 dlclose(_handleOnLoadedLib);
20 bool DynLibLoaderWin::isLibFileFindable() const
26 Append a directory with name \b dirName to the searching paths.
27 \return If append succeeds 0 is returned.
28 If the directory does not exists 1 is returned.
29 If the addition of directory causes some troubles due to seach paths name 2 is returned.
31 int DynLibLoaderWin::appendDirInSearchPath(const std::string& dirName)
37 Removes a directory with name \b dirName from the searching paths.
38 \return If removal succeeds 0 is returned.
39 If the directory does not exists 1 is returned.
40 If the path were not already in existing paths 2 is returned.
42 int DynLibLoaderWin::removeDirInSearchPath(const std::string& dirName)
47 void *DynLibLoaderWin::getHandleOnSymbolWithName(const std::string& symbName)
49 if(!_handleOnLoadedLib)
50 if(!isLibFileFindable())
52 std::cerr << "Dynamic library with name " << symbName << _extForDynLib;
53 std::cerr << " not existing in paths specified" << std::endl;
58 return resolveSymb(symbName);
61 void DynLibLoaderWin::loadLib()
63 std::string fullLibName(_libName);
64 fullLibName+=_extForDynLib;
65 _handleOnLoadedLib=LoadLibrary(fullLibName.c_str());
68 void *DynLibLoaderWin::resolveSymb(const std::string& symbName)
70 void *ret=GetProcAddress(_handleOnLoadedLib,symbName.c_str());
74 const char *DynLibLoaderWin::getExtensionForDynLib()
76 return _extForDynLib+1;