Ice 3.7 C++11 API Reference
Loading...
Searching...
No Matches
DynamicLibrary.h
Go to the documentation of this file.
1//
2// Copyright (c) ZeroC, Inc. All rights reserved.
3//
4
5#ifndef ICE_DYNAMIC_LIBRARY_H
6#define ICE_DYNAMIC_LIBRARY_H
7
9#include <IceUtil/Shared.h>
10
11namespace IceInternal
12{
13
14class ICE_API DynamicLibrary : public ::IceUtil::Shared
15{
16public:
17
18 DynamicLibrary();
19 virtual ~DynamicLibrary();
20
21#ifdef _WIN32
22 typedef FARPROC symbol_type;
23#else
24 typedef void* symbol_type;
25#endif
26
27 //
28 // Load an entry point. This is really a convenience function
29 // which combines calls to load() and getSymbol(). However, it
30 // does add some value.
31 //
32 // An entry point has the following format:
33 //
34 // name[,version]:function
35 //
36 // The name of the library is constructed from the given
37 // information. If no version is supplied and the boolean
38 // argument is true, the Ice version (10 * major + minor) is
39 // used instead.
40 //
41 // For example, consider the following entry point:
42 //
43 // foo:create
44 //
45 // This would result in libfoo.so.11 (Unix) and foo11.dll
46 // (Windows), where the Ice version is 1.1.x.
47 //
48 // Now consider this entry point:
49 //
50 // foo,12:create
51 //
52 // The library names in this case are libfoo.so.12 (Unix) and
53 // foo12.dll (Windows).
54 //
55 // On Windows platforms, a 'd' is appended to the version for
56 // debug builds.
57 //
58 // Returns 0 if a failure occurred.
59 //
60 symbol_type loadEntryPoint(const std::string&, bool = true);
61
62 //
63 // Open a library with the given path.
64 //
65 bool load(const std::string&);
66
67 //
68 // Retrieve a symbol from the library. Returns 0 if no match is found.
69 //
70 symbol_type getSymbol(const std::string&);
71
72 //
73 // Get the error message for the last failure.
74 //
75 const std::string& getErrorMessage() const;
76
77private:
78
79#ifdef _WIN32
80 HINSTANCE _hnd;
81#else
82 void* _hnd;
83#endif
84 std::string _err;
85};
86
87class ICE_API DynamicLibraryList : public ::IceUtil::Shared
88{
89public:
90
91 virtual ~DynamicLibraryList();
92
93 void add(const DynamicLibraryPtr&);
94
95private:
96
97 std::vector<DynamicLibraryPtr> _libraries;
98};
99
100}
101
102#endif
#define ICE_API
Definition Config.h:197