• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

MyGUI_DynLib.h

Go to the documentation of this file.
00001 
00008 /*
00009     This file is part of MyGUI.
00010     
00011     MyGUI is free software: you can redistribute it and/or modify
00012     it under the terms of the GNU Lesser General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015     
00016     MyGUI is distributed in the hope that it will be useful,
00017     but WITHOUT ANY WARRANTY; without even the implied warranty of
00018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019     GNU Lesser General Public License for more details.
00020     
00021     You should have received a copy of the GNU Lesser General Public License
00022     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00023 */
00024 
00025 #ifndef __MYGUI_DYNLIB_H__
00026 #define __MYGUI_DYNLIB_H__
00027 
00028 #include "MyGUI_Prerequest.h"
00029 
00030 
00031 #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
00032 #    define MYGUI_DYNLIB_HANDLE hInstance
00033 #    define MYGUI_DYNLIB_LOAD( a ) LoadLibrary( a )
00034 #    define MYGUI_DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
00035 #    define MYGUI_DYNLIB_UNLOAD( a ) !FreeLibrary( a )
00036 
00037 struct HINSTANCE__;
00038 typedef struct HINSTANCE__* hInstance;
00039 
00040 #elif MYGUI_PLATFORM == MYGUI_PLATFORM_LINUX
00041 #    define MYGUI_DYNLIB_HANDLE void*
00042 #    define MYGUI_DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL)
00043 #    define MYGUI_DYNLIB_GETSYM( a, b ) dlsym( a, b )
00044 #    define MYGUI_DYNLIB_UNLOAD( a ) dlclose( a )
00045 
00046 #elif MYGUI_PLATFORM == MYGUI_PLATFORM_APPLE
00047 #    define MYGUI_DYNLIB_HANDLE CFBundleRef
00048 #    define MYGUI_DYNLIB_LOAD( a ) mac_loadExeBundle( a )
00049 #    define MYGUI_DYNLIB_GETSYM( a, b ) mac_getBundleSym( a, b )
00050 #    define MYGUI_DYNLIB_UNLOAD( a ) mac_unloadExeBundle( a )
00051 #endif
00052 
00053 namespace MyGUI
00054 {
00055 
00062     class MYGUI_EXPORT DynLib
00063     {
00064         friend class DynLibManager;
00065 
00066     protected:
00067         DynLib(const std::string &name);
00068 
00069         ~DynLib();
00070 
00071     public:
00072 
00075         void load();
00076 
00079         void unload();
00080 
00082         std::string getName(void) const { return mName; }
00083 
00092         void* getSymbol( const std::string& strName ) const throw();
00093 
00094     protected:
00096         std::string dynlibError(void);
00097 
00098 
00099     protected:
00101         std::string mName;
00102 
00104         MYGUI_DYNLIB_HANDLE mInstance;
00105     };
00106 
00107 }
00108 
00109 #endif // __MYGUI_DYNLIB_H__

Generated on Sun Jan 30 2011 for MyGUI by  doxygen 1.7.1