1//
2// SharedLibrary.cpp
3//
4// Library: Foundation
5// Package: SharedLibrary
6// Module: SharedLibrary
7//
8// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
9// and Contributors.
10//
11// SPDX-License-Identifier: BSL-1.0
12//
13
14
15#include "Poco/SharedLibrary.h"
16#include "Poco/Exception.h"
17
18
19#if defined(hpux) || defined(_hpux)
20#include "SharedLibrary_HPUX.cpp"
21#elif defined(POCO_VXWORKS)
22#include "SharedLibrary_VX.cpp"
23#elif defined(POCO_OS_FAMILY_UNIX)
24#include "SharedLibrary_UNIX.cpp"
25#elif defined(POCO_OS_FAMILY_WINDOWS)
26#include "SharedLibrary_WIN32.cpp"
27#endif
28
29
30namespace Poco {
31
32
33SharedLibrary::SharedLibrary()
34{
35}
36
37
38SharedLibrary::SharedLibrary(const std::string& path)
39{
40 loadImpl(path, 0);
41}
42
43
44SharedLibrary::SharedLibrary(const std::string& path, int flags)
45{
46 loadImpl(path, flags);
47}
48
49
50SharedLibrary::~SharedLibrary()
51{
52}
53
54
55void SharedLibrary::load(const std::string& path)
56{
57 loadImpl(path, 0);
58}
59
60
61void SharedLibrary::load(const std::string& path, int flags)
62{
63 loadImpl(path, flags);
64}
65
66
67void SharedLibrary::unload()
68{
69 unloadImpl();
70}
71
72
73bool SharedLibrary::isLoaded() const
74{
75 return isLoadedImpl();
76}
77
78
79bool SharedLibrary::hasSymbol(const std::string& name)
80{
81 return findSymbolImpl(name) != 0;
82}
83
84
85void* SharedLibrary::getSymbol(const std::string& name)
86{
87 void* result = findSymbolImpl(name);
88 if (result)
89 return result;
90 else
91 throw NotFoundException(name);
92}
93
94
95const std::string& SharedLibrary::getPath() const
96{
97 return getPathImpl();
98}
99
100
101std::string SharedLibrary::prefix()
102{
103 return prefixImpl();
104}
105
106
107std::string SharedLibrary::suffix()
108{
109 return suffixImpl();
110}
111
112std::string SharedLibrary::getOSName(const std::string& name)
113{
114 return prefix() + name + suffix();
115}
116
117} // namespace Poco
118