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#elif defined(POCO_OS_FAMILY_VMS)
28#include "SharedLibrary_VMS.cpp"
29#endif
30
31
32namespace Poco {
33
34
35SharedLibrary::SharedLibrary()
36{
37}
38
39
40SharedLibrary::SharedLibrary(const std::string& path)
41{
42 loadImpl(path, 0);
43}
44
45
46SharedLibrary::SharedLibrary(const std::string& path, int flags)
47{
48 loadImpl(path, flags);
49}
50
51
52SharedLibrary::~SharedLibrary()
53{
54}
55
56
57void SharedLibrary::load(const std::string& path)
58{
59 loadImpl(path, 0);
60}
61
62
63void SharedLibrary::load(const std::string& path, int flags)
64{
65 loadImpl(path, flags);
66}
67
68
69void SharedLibrary::unload()
70{
71 unloadImpl();
72}
73
74
75bool SharedLibrary::isLoaded() const
76{
77 return isLoadedImpl();
78}
79
80
81bool SharedLibrary::hasSymbol(const std::string& name)
82{
83 return findSymbolImpl(name) != 0;
84}
85
86
87void* SharedLibrary::getSymbol(const std::string& name)
88{
89 void* result = findSymbolImpl(name);
90 if (result)
91 return result;
92 else
93 throw NotFoundException(name);
94}
95
96
97const std::string& SharedLibrary::getPath() const
98{
99 return getPathImpl();
100}
101
102
103std::string SharedLibrary::prefix()
104{
105 return prefixImpl();
106}
107
108
109std::string SharedLibrary::suffix()
110{
111 return suffixImpl();
112}
113
114std::string SharedLibrary::getOSName(const std::string& name)
115{
116 return prefix() + name + suffix();
117}
118
119} // namespace Poco
120