00001 /************************************************************************ 00002 filename: CEGUIFactoryModule.h 00003 created: 12/4/2004 00004 author: Paul D Turner 00005 00006 purpose: Defines interface for object that controls a loadable 00007 module (.dll/.so/ whatever) that contains concrete 00008 window / widget implementations and their factories. 00009 *************************************************************************/ 00010 /************************************************************************* 00011 Crazy Eddie's GUI System (http://www.cegui.org.uk) 00012 Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk) 00013 00014 This library is free software; you can redistribute it and/or 00015 modify it under the terms of the GNU Lesser General Public 00016 License as published by the Free Software Foundation; either 00017 version 2.1 of the License, or (at your option) any later version. 00018 00019 This library is distributed in the hope that it will be useful, 00020 but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00022 Lesser General Public License for more details. 00023 00024 You should have received a copy of the GNU Lesser General Public 00025 License along with this library; if not, write to the Free Software 00026 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00027 *************************************************************************/ 00028 #ifndef _CEGUIFactoryModule_h_ 00029 #define _CEGUIFactoryModule_h_ 00030 00031 /************************************************************************* 00032 The following is basically taken from DynLib.h, which is part of 00033 the Ogre project (http://www.ogre3d.org/) 00034 *************************************************************************/ 00035 #if defined(__WIN32__) || defined(_WIN32) 00036 # define DYNLIB_HANDLE hInstance 00037 # define DYNLIB_LOAD( a ) LoadLibrary( a ) 00038 # define DYNLIB_GETSYM( a, b ) GetProcAddress( a, b ) 00039 # define DYNLIB_UNLOAD( a ) !FreeLibrary( a ) 00040 # define DYNLIB_ERROR( ) "Unknown Error" 00041 00042 struct HINSTANCE__; 00043 typedef struct HINSTANCE__* hInstance; 00044 00045 #elif defined(__linux__) 00046 # define DYNLIB_HANDLE void* 00047 # define DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY ) 00048 # define DYNLIB_GETSYM( a, b ) dlsym( a, b ) 00049 # define DYNLIB_UNLOAD( a ) dlclose( a ) 00050 # define DYNLIB_ERROR( ) dlerror( ) 00051 00052 #elif defined(__APPLE_CC__) 00053 # define DYNLIB_HANDLE CFBundleRef 00054 # define DYNLIB_LOAD( a ) mac_loadExeBundle( a ) 00055 # define DYNLIB_GETSYM( a, b ) mac_getBundleSym( a, b ) 00056 # define DYNLIB_UNLOAD( a ) mac_unloadExeBundle( a ) 00057 # define DYNLIB_ERROR( ) mac_errorBundle() 00058 #endif 00059 00060 00061 // Start of CEGUI namespace section 00062 namespace CEGUI 00063 { 00064 00069 class FactoryModule 00070 { 00071 public: 00082 FactoryModule(const String& filename); 00083 00084 00092 virtual ~FactoryModule(void); 00093 00094 00105 void registerFactory(const String& type) const; 00106 00107 private: 00108 /************************************************************************* 00109 Implementation Data 00110 *************************************************************************/ 00111 static const char RegisterFactoryFunctionName[]; 00112 00113 typedef void (*FactoryRegisterFunction)(const String&); 00114 00115 FactoryRegisterFunction d_regFunc; 00116 String d_moduleName; 00117 DYNLIB_HANDLE d_handle; 00118 }; 00119 00120 } // End of CEGUI namespace section 00121 00122 00123 #endif // end of guard _CEGUIFactoryModule_h_