SharedLibrary.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //
  2. // SharedLibrary.cpp
  3. //
  4. // $Id: //poco/1.4/Foundation/src/SharedLibrary.cpp#3 $
  5. //
  6. // Library: Foundation
  7. // Package: SharedLibrary
  8. // Module: SharedLibrary
  9. //
  10. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #include "Poco/SharedLibrary.h"
  16. #include "Poco/Exception.h"
  17. #if defined(hpux) || defined(_hpux)
  18. #include "SharedLibrary_HPUX.cpp"
  19. #elif defined(POCO_VXWORKS)
  20. #include "SharedLibrary_VX.cpp"
  21. #elif defined(POCO_OS_FAMILY_UNIX)
  22. #include "SharedLibrary_UNIX.cpp"
  23. #elif defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
  24. #include "SharedLibrary_WIN32U.cpp"
  25. #elif defined(POCO_OS_FAMILY_WINDOWS)
  26. #include "SharedLibrary_WIN32.cpp"
  27. #elif defined(POCO_OS_FAMILY_VMS)
  28. #include "SharedLibrary_VMS.cpp"
  29. #endif
  30. namespace Poco {
  31. SharedLibrary::SharedLibrary()
  32. {
  33. }
  34. SharedLibrary::SharedLibrary(const std::string& path)
  35. {
  36. loadImpl(path, 0);
  37. }
  38. SharedLibrary::SharedLibrary(const std::string& path, int flags)
  39. {
  40. loadImpl(path, flags);
  41. }
  42. SharedLibrary::~SharedLibrary()
  43. {
  44. }
  45. void SharedLibrary::load(const std::string& path)
  46. {
  47. loadImpl(path, 0);
  48. }
  49. void SharedLibrary::load(const std::string& path, int flags)
  50. {
  51. loadImpl(path, flags);
  52. }
  53. void SharedLibrary::unload()
  54. {
  55. unloadImpl();
  56. }
  57. bool SharedLibrary::isLoaded() const
  58. {
  59. return isLoadedImpl();
  60. }
  61. bool SharedLibrary::hasSymbol(const std::string& name)
  62. {
  63. return findSymbolImpl(name) != 0;
  64. }
  65. void* SharedLibrary::getSymbol(const std::string& name)
  66. {
  67. void* result = findSymbolImpl(name);
  68. if (result)
  69. return result;
  70. else
  71. throw NotFoundException(name);
  72. }
  73. const std::string& SharedLibrary::getPath() const
  74. {
  75. return getPathImpl();
  76. }
  77. std::string SharedLibrary::suffix()
  78. {
  79. return suffixImpl();
  80. }
  81. } // namespace Poco