source: GTP/trunk/App/Demos/Geom/OgreStuff/include/OgreDynLib.h @ 1092

Revision 1092, 3.5 KB checked in by gumbau, 18 years ago (diff)

LodStrips? and LODTrees demos

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-2005 The OGRE Team
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-----------------------------------------------------------------------------
24*/
25#ifndef _DynLib_H__
26#define _DynLib_H__
27
28#include "OgrePrerequisites.h"
29
30#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
31#    define DYNLIB_HANDLE hInstance
32#    define DYNLIB_LOAD( a ) LoadLibrary( a )
33#    define DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
34#    define DYNLIB_UNLOAD( a ) !FreeLibrary( a )
35
36struct HINSTANCE__;
37typedef struct HINSTANCE__* hInstance;
38
39#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
40#    define DYNLIB_HANDLE void*
41#    define DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY )
42#    define DYNLIB_GETSYM( a, b ) dlsym( a, b )
43#    define DYNLIB_UNLOAD( a ) dlclose( a )
44
45#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
46#    define DYNLIB_HANDLE CFBundleRef
47#    define DYNLIB_LOAD( a ) mac_loadExeBundle( a )
48#    define DYNLIB_GETSYM( a, b ) mac_getBundleSym( a, b )
49#    define DYNLIB_UNLOAD( a ) mac_unloadExeBundle( a )
50#endif
51
52namespace Ogre {
53
54    /** Resource holding data about a dynamic library.
55        @remarks
56            This class holds the data required to get symbols from
57            libraries loaded at run-time (i.e. from DLL's for so's)
58        @author
59            Adrian Cearnãu (cearny@cearny.ro)
60        @since
61            27 January 2002
62        @see
63            Resource
64    */
65    class _OgreExport DynLib
66    {
67        protected:
68                String mName;
69        /// Gets the last loading error
70        String dynlibError(void);
71    public:
72        /** Default constructor - used by DynLibManager.
73            @warning
74                Do not call directly
75        */
76        DynLib( const String& name );
77
78        /** Default destructor.
79        */
80        ~DynLib();
81
82        /** Load the library
83        */
84        void load();
85        /** Unload the library
86        */
87        void unload();
88                /// Get the name of the library
89                const String& getName(void) const { return mName; }
90
91        /**
92            Returns the address of the given symbol from the loaded library.
93            @param
94                strName The name of the symbol to search for
95            @returns
96                If the function succeeds, the returned value is a handle to
97                the symbol.
98            @par
99                If the function fails, the returned value is <b>NULL</b>.
100
101        */
102        void* getSymbol( const String& strName ) const throw();
103
104    protected:
105
106        /// Handle to the loaded library.
107        DYNLIB_HANDLE m_hInst;
108    };
109
110}
111
112#endif
Note: See TracBrowser for help on using the repository browser.