HP-UX support added
[wxWidgets.git] / include / wx / dynlib.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dynlib.cpp
3 // Purpose: Dynamic library management
4 // Author: Guilhem Lavaux
5 // Modified by:
6 // Created: 20/07/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Guilhem Lavaux
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_DYNLIB_H__
13 #define _WX_DYNLIB_H__
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include <wx/string.h>
20 #include <wx/list.h>
21 #include <wx/hash.h>
22
23 #if defined(HAVE_DLOPEN)
24 #include <dlfcn.h>
25
26 typedef void *wxDllType;
27 #elif defined(HAVE_SHLLOAD)
28 #include <dl.h>
29
30 typedef void *wxDllType;
31 #elif defined(__WINDOWS__)
32 #include <windows.h>
33
34 typedef HMODULE wxDllType;
35 #elif defined(__WXMAC__)
36 typedef CFragConnectionID wxDllType;
37 #else
38 #error "wxLibrary can't be compiled on this platform, sorry."
39 #endif // OS
40
41 // defined in windows.h
42 #ifdef LoadLibrary
43 #undef LoadLibrary
44 #endif
45
46 // ----------------------------------------------------------------------------
47 // wxLibrary
48 // ----------------------------------------------------------------------------
49
50 class wxLibrary : public wxObject
51 {
52 public:
53 wxHashTable classTable;
54
55 public:
56 wxLibrary(void *handle);
57 ~wxLibrary();
58
59 // Get a symbol from the dynamic library
60 void *GetSymbol(const wxString& symbname);
61
62 // Create the object whose classname is "name"
63 wxObject *CreateObject(const wxString& name);
64
65 protected:
66 void PrepareClasses(wxClassInfo *first);
67
68 wxDllType m_handle;
69 };
70
71 // ----------------------------------------------------------------------------
72 // wxLibraries
73 // ----------------------------------------------------------------------------
74
75 class wxLibraries
76 {
77 public:
78 wxLibraries();
79 ~wxLibraries();
80
81 // caller is responsible for deleting the returned pointer if !NULL
82 wxLibrary *LoadLibrary(const wxString& basename);
83
84 wxObject *CreateObject(const wxString& name);
85
86 protected:
87 wxList m_loaded;
88 };
89
90 // ----------------------------------------------------------------------------
91 // Global variables
92 // ----------------------------------------------------------------------------
93
94 extern wxLibraries wxTheLibraries;
95
96 // ----------------------------------------------------------------------------
97 // Interesting defines
98 // ----------------------------------------------------------------------------
99
100 #define WXDLL_ENTRY_FUNCTION() \
101 extern "C" wxClassInfo *wxGetClassFirst(); \
102 wxClassInfo *wxGetClassFirst() { \
103 return wxClassInfo::GetFirst(); \
104 }
105
106 #endif // _WX_DYNLIB_H__