OGRE  1.9.0
OgreDynLib.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE 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
40struct HINSTANCE__;
41typedef 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
49struct HINSTANCE__;
50typedef 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_GLOBAL)
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
67namespace Ogre {
85 {
86 protected:
90 public:
95 DynLib( const String& name );
96
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 DYNLIB_HANDLE
Definition OgreDynLib.h:53
#define _OgreExport
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Resource holding data about a dynamic library.
Definition OgreDynLib.h:85
void load()
Load the library.
void * getSymbol(const String &strName) const
Returns the address of the given symbol from the loaded library.
void unload()
Unload the library.
DYNLIB_HANDLE mInst
Handle to the loaded library.
Definition OgreDynLib.h:126
DynLib(const String &name)
Default constructor - used by DynLibManager.
String dynlibError(void)
Gets the last loading error.
~DynLib()
Default destructor.
const String & getName(void) const
Get the name of the library.
Definition OgreDynLib.h:108
String mName
Definition OgreDynLib.h:87
Reference-counted shared pointer, used for objects where implicit destruction is required.
_StringBase String