OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreDynLib.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef _DynLib_H__
29 #define _DynLib_H__
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreHeaderPrefix.h"
33 
34 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
35 # define DYNLIB_HANDLE hInstance
36 # define DYNLIB_LOAD( a ) LoadLibraryEx( a, NULL, 0 ) // we can not use LOAD_WITH_ALTERED_SEARCH_PATH with relative paths
37 # define DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
38 # define DYNLIB_UNLOAD( a ) !FreeLibrary( a )
39 
40 struct HINSTANCE__;
41 typedef struct HINSTANCE__* hInstance;
42 
43 #elif OGRE_PLATFORM == OGRE_PLATFORM_WINRT
44 # define DYNLIB_HANDLE hInstance
45 # define DYNLIB_LOAD( a ) LoadPackagedLibrary( UTFString(a).asWStr_c_str(), 0 )
46 # define DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
47 # define DYNLIB_UNLOAD( a ) !FreeLibrary( a )
48 
49 struct HINSTANCE__;
50 typedef struct HINSTANCE__* hInstance;
51 
52 #elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX || OGRE_PLATFORM == OGRE_PLATFORM_ANDROID || OGRE_PLATFORM == OGRE_PLATFORM_NACL || OGRE_PLATFORM == OGRE_PLATFORM_FLASHCC
53 # define DYNLIB_HANDLE void*
54 # define DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_LOCAL)
55 # define DYNLIB_GETSYM( a, b ) dlsym( a, b )
56 # define DYNLIB_UNLOAD( a ) dlclose( a )
57 
58 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS
59 # define DYNLIB_HANDLE void*
60 # define DYNLIB_LOAD( a ) mac_loadDylib( a )
61 # define FRAMEWORK_LOAD( a ) mac_loadFramework( a )
62 # define DYNLIB_GETSYM( a, b ) dlsym( a, b )
63 # define DYNLIB_UNLOAD( a ) dlclose( a )
64 
65 #endif
66 
67 namespace Ogre {
85  {
86  protected:
89  String dynlibError(void);
90  public:
95  DynLib( const String& name );
96 
99  ~DynLib();
100 
103  void load();
106  void unload();
108  const String& getName(void) const { return mName; }
109 
121  void* getSymbol( const String& strName ) const throw();
122 
123  protected:
124 
127  };
131 }
132 
133 #include "OgreHeaderSuffix.h"
134 
135 #endif
#define _OgreExport
Definition: OgrePlatform.h:255
Resource holding data about a dynamic library.
Definition: OgreDynLib.h:84
String mName
Definition: OgreDynLib.h:87
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
const String & getName(void) const
Get the name of the library.
Definition: OgreDynLib.h:108
_StringBase String
Definition: OgreCommon.h:53
#define DYNLIB_HANDLE
Definition: OgreDynLib.h:53
DYNLIB_HANDLE mInst
Handle to the loaded library.
Definition: OgreDynLib.h:126