]> Dogcows Code - chaz/yoink/blob - src/stlplus/portability/dynaload.hpp
cleanup stlplus files
[chaz/yoink] / src / stlplus / portability / dynaload.hpp
1 #ifndef STLPLUS_DYNALOAD
2 #define STLPLUS_DYNALOAD
3 ////////////////////////////////////////////////////////////////////////////////
4
5 // Author: Andy Rushton
6 // Copyright: (c) Southampton University 1999-2004
7 // (c) Andy Rushton 2004-2009
8 // License: BSD License, see ../docs/license.html
9
10 // A portable interface to the dynamic loader - i.e. the system for loading
11 // dynamic libraries or shared libraries during the running of a program,
12 // rather than by linking
13
14 ////////////////////////////////////////////////////////////////////////////////
15 #include "portability_fixes.hpp"
16 #include <string>
17
18 namespace stlplus
19 {
20
21 //////////////////////////////////////////////////////////////////////////////
22 // dynaload class manages a dynamic loadable library and unloads it on destruction
23
24 class dynaload
25 {
26 public:
27
28 ////////////////////////////////////////////////////////////////////////////
29 // library management
30
31 // construct the object but do not load
32 dynaload(void);
33
34 // construct and load
35 dynaload(const std::string& library);
36
37 // destroy and unload if loaded
38 ~dynaload(void);
39
40 // load the library - return success or fail
41 bool load(const std::string& library);
42
43 // unload the library if loaded
44 bool unload(void);
45
46 // test whether the library is loaded
47 bool loaded(void) const;
48
49 ////////////////////////////////////////////////////////////////////////////
50 // symbol management
51
52 // test whether a function is exported by the library
53 bool present(const std::string& name);
54
55 // get the function as a generic pointer
56 void* symbol(const std::string& name);
57
58 ////////////////////////////////////////////////////////////////////////////
59 // error management
60
61 // enum values to indicate type of error
62 enum error_t {no_error, load_error, unload_error, symbol_error};
63
64 // test whether there has been an error
65 bool error(void) const;
66
67 // clear an error once it has been handled (or ignored)
68 void clear_error(void);
69
70 // get the type of the error as indicated by the enum error_t
71 error_t error_type(void) const;
72
73 // get the text of the error as provided by the OS
74 std::string error_text(void) const;
75
76 ////////////////////////////////////////////////////////////////////////////
77
78 private:
79 void* m_handle;
80 error_t m_error;
81 std::string m_text;
82 };
83
84 }
85
86 #endif
This page took 0.032917 seconds and 4 git commands to generate.