MyGUI 3.2.2

MyGUI_DynLib.h
Go to the documentation of this file.
1 /*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7 #ifndef MYGUI_DYNLIB_H_
8 #define MYGUI_DYNLIB_H_
9
10 #include "MyGUI_Prerequest.h"
11 #include <string>
12
13
14 #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
15 # define MYGUI_DYNLIB_HANDLE hInstance
16 # define MYGUI_DYNLIB_LOAD( a ) LoadLibrary( a )
17 # define MYGUI_DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
18 # define MYGUI_DYNLIB_UNLOAD( a ) !FreeLibrary( a )
19
20 struct HINSTANCE__;
21 typedef struct HINSTANCE__* hInstance;
22
23 #elif MYGUI_PLATFORM == MYGUI_PLATFORM_LINUX
24 # define MYGUI_DYNLIB_HANDLE void*
25 # define MYGUI_DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL)
26 # define MYGUI_DYNLIB_GETSYM( a, b ) dlsym( a, b )
27 # define MYGUI_DYNLIB_UNLOAD( a ) dlclose( a )
28
29 #elif MYGUI_PLATFORM == MYGUI_PLATFORM_APPLE
30 # include <CoreFoundation/CFBundle.h>
31 # define MYGUI_DYNLIB_HANDLE CFBundleRef
32 # define MYGUI_DYNLIB_LOAD( a ) mac_loadExeBundle( a )
33 # define MYGUI_DYNLIB_GETSYM( a, b ) mac_getBundleSym( a, b )
34 # define MYGUI_DYNLIB_UNLOAD( a ) mac_unloadExeBundle( a )
35 #endif
36
37 namespace MyGUI
38 {
39
46 class MYGUI_EXPORT DynLib
47 {
48 friend class DynLibManager;
49
50 protected:
51 DynLib(const std::string& name);
52
53 ~DynLib();
54
55 public:
56
59 bool load();
60
63 void unload();
64
66 std::string getName(void) const;
67
76 void* getSymbol( const std::string& strName ) const throw();
77
78 protected:
80 std::string dynlibError() const;
81
82 protected:
84 std::string mName;
85
87 MYGUI_DYNLIB_HANDLE mInstance;
88 };
89
90 } // namespace MyGUI
91
92 #endif // MYGUI_DYNLIB_H_
MyGUI_Prerequest.h
MyGUI::DynLib::mInstance
void * mInstance
Handle to the loaded library.
Definition: MyGUI_DynLib.h:87
MyGUI::DynLib
Resource holding data about a dynamic library.
Definition: MyGUI_DynLib.h:46
MyGUI::DynLib::mName
std::string mName
Name of library.
Definition: MyGUI_DynLib.h:84
MYGUI_DYNLIB_HANDLE
#define MYGUI_DYNLIB_HANDLE
Definition: MyGUI_DynLib.h:24
MyGUI
Definition: MyGUI_ActionController.h:14
MyGUI::DynLibManager
Manager of dynamic libraries.
Definition: MyGUI_DynLibManager.h:20
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:103