Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgreDynLib.h @ 1

Last change on this file since 1 was 1, checked in by landauf, 17 years ago
File size: 3.7 KB
Line 
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-2006 Torus Knot Software Ltd
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29#ifndef _DynLib_H__
30#define _DynLib_H__
31
32#include "OgrePrerequisites.h"
33
34#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
35#    define DYNLIB_HANDLE hInstance
36#    define DYNLIB_LOAD( a ) LoadLibrary( a )
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_LINUX
44#    define DYNLIB_HANDLE void*
45#    define DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL)
46#    define DYNLIB_GETSYM( a, b ) dlsym( a, b )
47#    define DYNLIB_UNLOAD( a ) dlclose( a )
48
49#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
50#    define DYNLIB_HANDLE CFBundleRef
51#    define DYNLIB_LOAD( a ) mac_loadExeBundle( a )
52#    define DYNLIB_GETSYM( a, b ) mac_getBundleSym( a, b )
53#    define DYNLIB_UNLOAD( a ) mac_unloadExeBundle( a )
54#endif
55
56namespace Ogre {
57
58    /** Resource holding data about a dynamic library.
59        @remarks
60            This class holds the data required to get symbols from
61            libraries loaded at run-time (i.e. from DLL's for so's)
62        @author
63            Adrian Cearnãu (cearny@cearny.ro)
64        @since
65            27 January 2002
66        @see
67            Resource
68    */
69    class _OgreExport DynLib
70    {
71        protected:
72                String mName;
73        /// Gets the last loading error
74        String dynlibError(void);
75    public:
76        /** Default constructor - used by DynLibManager.
77            @warning
78                Do not call directly
79        */
80        DynLib( const String& name );
81
82        /** Default destructor.
83        */
84        ~DynLib();
85
86        /** Load the library
87        */
88        void load();
89        /** Unload the library
90        */
91        void unload();
92                /// Get the name of the library
93                const String& getName(void) const { return mName; }
94
95        /**
96            Returns the address of the given symbol from the loaded library.
97            @param
98                strName The name of the symbol to search for
99            @returns
100                If the function succeeds, the returned value is a handle to
101                the symbol.
102            @par
103                If the function fails, the returned value is <b>NULL</b>.
104
105        */
106        void* getSymbol( const String& strName ) const throw();
107
108    protected:
109
110        /// Handle to the loaded library.
111        DYNLIB_HANDLE m_hInst;
112    };
113
114}
115
116#endif
Note: See TracBrowser for help on using the repository browser.