]> git.saurik.com Git - wxWidgets.git/blob - include/wx/dynlib.h
Rewrote wxNotebook, incl. PAGE_CHANGING event
[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/setup.h>
20
21 #if wxUSE_DYNLIB_CLASS
22
23 #include <wx/string.h>
24 #include <wx/list.h>
25 #include <wx/hash.h>
26
27 // this is normally done by configure, but I leave it here for now...
28 #if defined(__UNIX__) && !(defined(HAVE_DLOPEN) || defined(HAVE_SHL_LOAD))
29 #if defined(__LINUX__) || defined(__SOLARIS__) || defined(__SUNOS__) || defined(__FREEBSD__)
30 #define HAVE_DLOPEN
31 #elif defined(__HPUX__)
32 #define HAVE_SHL_LOAD
33 #endif // Unix flavour
34 #endif // !Unix or already have some HAVE_xxx defined
35
36 #if defined(HAVE_DLOPEN)
37 #include <dlfcn.h>
38
39 typedef void *wxDllType;
40 #elif defined(HAVE_SHL_LOAD)
41 #include <dl.h>
42
43 typedef shl_t wxDllType;
44 #elif defined(__WINDOWS__)
45 #include <windows.h>
46
47 typedef HMODULE wxDllType;
48 #elif defined(__WXMAC__)
49 typedef CFragConnectionID wxDllType;
50 #else
51 #error "wxLibrary can't be compiled on this platform, sorry."
52 #endif // OS
53
54 // defined in windows.h
55 #ifdef LoadLibrary
56 #undef LoadLibrary
57 #endif
58
59 // ----------------------------------------------------------------------------
60 // wxLibrary
61 // ----------------------------------------------------------------------------
62
63 class wxLibrary : public wxObject
64 {
65 public:
66 wxHashTable classTable;
67
68 public:
69 wxLibrary(wxDllType handle);
70 ~wxLibrary();
71
72 // Get a symbol from the dynamic library
73 void *GetSymbol(const wxString& symbname);
74
75 // Create the object whose classname is "name"
76 wxObject *CreateObject(const wxString& name);
77
78 protected:
79 void PrepareClasses(wxClassInfo *first);
80
81 wxDllType m_handle;
82 };
83
84 // ----------------------------------------------------------------------------
85 // wxLibraries
86 // ----------------------------------------------------------------------------
87
88 class wxLibraries
89 {
90 public:
91 wxLibraries();
92 ~wxLibraries();
93
94 // caller is responsible for deleting the returned pointer if !NULL
95 wxLibrary *LoadLibrary(const wxString& basename);
96
97 wxObject *CreateObject(const wxString& name);
98
99 protected:
100 wxList m_loaded;
101 };
102
103 // ----------------------------------------------------------------------------
104 // Global variables
105 // ----------------------------------------------------------------------------
106
107 extern wxLibraries wxTheLibraries;
108
109 // ----------------------------------------------------------------------------
110 // Interesting defines
111 // ----------------------------------------------------------------------------
112
113 #define WXDLL_ENTRY_FUNCTION() \
114 extern "C" wxClassInfo *wxGetClassFirst(); \
115 wxClassInfo *wxGetClassFirst() { \
116 return wxClassInfo::GetFirst(); \
117 }
118
119 #endif // wxUSE_DYNLIB_CLASS
120
121 #endif // _WX_DYNLIB_H__