MyGUI  3.2.0
MyGUI_DynLib.h
Go to the documentation of this file.
1 
7 /*
8  This file is part of MyGUI.
9 
10  MyGUI is free software: you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  MyGUI is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
22 */
23 
24 #ifndef __MYGUI_DYNLIB_H__
25 #define __MYGUI_DYNLIB_H__
26 
27 #include "MyGUI_Prerequest.h"
28 #include <string>
29 
30 
31 #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
32 # define MYGUI_DYNLIB_HANDLE hInstance
33 # define MYGUI_DYNLIB_LOAD( a ) LoadLibrary( a )
34 # define MYGUI_DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
35 # define MYGUI_DYNLIB_UNLOAD( a ) !FreeLibrary( a )
36 
37 struct HINSTANCE__;
38 typedef struct HINSTANCE__* hInstance;
39 
40 #elif MYGUI_PLATFORM == MYGUI_PLATFORM_LINUX
41 # define MYGUI_DYNLIB_HANDLE void*
42 # define MYGUI_DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL)
43 # define MYGUI_DYNLIB_GETSYM( a, b ) dlsym( a, b )
44 # define MYGUI_DYNLIB_UNLOAD( a ) dlclose( a )
45 
46 #elif MYGUI_PLATFORM == MYGUI_PLATFORM_APPLE
47 # include <CoreFoundation/CFBundle.h>
48 # define MYGUI_DYNLIB_HANDLE CFBundleRef
49 # define MYGUI_DYNLIB_LOAD( a ) mac_loadExeBundle( a )
50 # define MYGUI_DYNLIB_GETSYM( a, b ) mac_getBundleSym( a, b )
51 # define MYGUI_DYNLIB_UNLOAD( a ) mac_unloadExeBundle( a )
52 #endif
53 
54 namespace MyGUI
55 {
56 
64  {
65  friend class DynLibManager;
66 
67  protected:
68  DynLib(const std::string& name);
69 
70  ~DynLib();
71 
72  public:
73 
76  bool load();
77 
80  void unload();
81 
83  std::string getName(void) const;
84 
93  void* getSymbol( const std::string& strName ) const throw();
94 
95  protected:
97  std::string dynlibError() const;
98 
99  protected:
101  std::string mName;
102 
105  };
106 
107 } // namespace MyGUI
108 
109 #endif // __MYGUI_DYNLIB_H__
void * mInstance
Handle to the loaded library.
Definition: MyGUI_DynLib.h:104
Resource holding data about a dynamic library.
Definition: MyGUI_DynLib.h:63
std::string mName
Name of library.
Definition: MyGUI_DynLib.h:101
#define MYGUI_DYNLIB_HANDLE
Definition: MyGUI_DynLib.h:41
Manager of dynamic libraries.
#define MYGUI_EXPORT