]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dynlib.h
Made listctrl header BG grey again
[wxWidgets.git] / include / wx / dynlib.h
CommitLineData
7b0bfbb2
VZ
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
34138703
JS
12#ifndef _WX_DYNLIB_H__
13#define _WX_DYNLIB_H__
7a4b9130
GL
14
15#ifdef __GNUG__
7b0bfbb2 16 #pragma interface
7a4b9130
GL
17#endif
18
8a0d4cf6
VZ
19#include <wx/setup.h>
20
21#if wxUSE_DYNLIB_CLASS
22
7a4b9130
GL
23#include <wx/string.h>
24#include <wx/list.h>
f4a8c29f 25#include <wx/hash.h>
7a4b9130 26
8a0d4cf6
VZ
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))
3e4efd7c
VZ
29 #if defined(__LINUX__) || defined(__SOLARIS__) || defined(__SUNOS__) || defined(__FREEBSD__)
30 #define HAVE_DLOPEN
31 #elif defined(__HPUX__)
8a0d4cf6 32 #define HAVE_SHL_LOAD
3e4efd7c
VZ
33 #endif // Unix flavour
34#endif // !Unix or already have some HAVE_xxx defined
35
7b0bfbb2
VZ
36#if defined(HAVE_DLOPEN)
37 #include <dlfcn.h>
38
39 typedef void *wxDllType;
8a0d4cf6 40#elif defined(HAVE_SHL_LOAD)
7b0bfbb2
VZ
41 #include <dl.h>
42
8a0d4cf6 43 typedef shl_t wxDllType;
7b0bfbb2
VZ
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
0c32066b 55#ifdef LoadLibrary
7b0bfbb2 56 #undef LoadLibrary
0c32066b
JS
57#endif
58
7b0bfbb2 59// ----------------------------------------------------------------------------
7a4b9130 60// wxLibrary
7b0bfbb2 61// ----------------------------------------------------------------------------
7a4b9130 62
7b0bfbb2
VZ
63class wxLibrary : public wxObject
64{
65public:
66 wxHashTable classTable;
f4a8c29f 67
7b0bfbb2 68public:
8a0d4cf6 69 wxLibrary(wxDllType handle);
7b0bfbb2 70 ~wxLibrary();
7a4b9130 71
7b0bfbb2
VZ
72 // Get a symbol from the dynamic library
73 void *GetSymbol(const wxString& symbname);
7a4b9130 74
7b0bfbb2
VZ
75 // Create the object whose classname is "name"
76 wxObject *CreateObject(const wxString& name);
7a4b9130 77
7b0bfbb2
VZ
78protected:
79 void PrepareClasses(wxClassInfo *first);
f4a8c29f 80
7b0bfbb2 81 wxDllType m_handle;
7a4b9130
GL
82};
83
7b0bfbb2 84// ----------------------------------------------------------------------------
7a4b9130 85// wxLibraries
7b0bfbb2
VZ
86// ----------------------------------------------------------------------------
87
88class wxLibraries
89{
90public:
91 wxLibraries();
92 ~wxLibraries();
7a4b9130 93
7b0bfbb2
VZ
94 // caller is responsible for deleting the returned pointer if !NULL
95 wxLibrary *LoadLibrary(const wxString& basename);
7a4b9130 96
7b0bfbb2
VZ
97 wxObject *CreateObject(const wxString& name);
98
99protected:
100 wxList m_loaded;
7a4b9130
GL
101};
102
7b0bfbb2 103// ----------------------------------------------------------------------------
7a4b9130 104// Global variables
7b0bfbb2 105// ----------------------------------------------------------------------------
7a4b9130
GL
106
107extern wxLibraries wxTheLibraries;
108
7b0bfbb2 109// ----------------------------------------------------------------------------
7a4b9130 110// Interesting defines
7b0bfbb2 111// ----------------------------------------------------------------------------
7a4b9130 112
f4a8c29f 113#define WXDLL_ENTRY_FUNCTION() \
856d2e52
GL
114extern "C" wxClassInfo *wxGetClassFirst(); \
115wxClassInfo *wxGetClassFirst() { \
116 return wxClassInfo::GetFirst(); \
f4a8c29f 117}
7a4b9130 118
8a0d4cf6
VZ
119#endif // wxUSE_DYNLIB_CLASS
120
7b0bfbb2 121#endif // _WX_DYNLIB_H__