[692] | 1 | /************************************************************************
|
---|
| 2 | filename: CEGUIFactoryModule.h
|
---|
| 3 | created: 12/4/2004
|
---|
| 4 | author: Paul D Turner
|
---|
| 5 |
|
---|
| 6 | purpose: Defines interface for object that controls a loadable
|
---|
| 7 | module (.dll/.so/ whatever) that contains concrete
|
---|
| 8 | window / widget implementations and their factories.
|
---|
| 9 | *************************************************************************/
|
---|
| 10 | /*************************************************************************
|
---|
| 11 | Crazy Eddie's GUI System (http://www.cegui.org.uk)
|
---|
| 12 | Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
|
---|
| 13 |
|
---|
| 14 | This library is free software; you can redistribute it and/or
|
---|
| 15 | modify it under the terms of the GNU Lesser General Public
|
---|
| 16 | License as published by the Free Software Foundation; either
|
---|
| 17 | version 2.1 of the License, or (at your option) any later version.
|
---|
| 18 |
|
---|
| 19 | This library is distributed in the hope that it will be useful,
|
---|
| 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 22 | Lesser General Public License for more details.
|
---|
| 23 |
|
---|
| 24 | You should have received a copy of the GNU Lesser General Public
|
---|
| 25 | License along with this library; if not, write to the Free Software
|
---|
| 26 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 27 | *************************************************************************/
|
---|
| 28 | #ifndef _CEGUIFactoryModule_h_
|
---|
| 29 | #define _CEGUIFactoryModule_h_
|
---|
| 30 |
|
---|
| 31 | /*************************************************************************
|
---|
| 32 | The following is basically taken from DynLib.h, which is part of
|
---|
| 33 | the Ogre project (http://www.ogre3d.org/)
|
---|
| 34 | *************************************************************************/
|
---|
| 35 | #if defined(__WIN32__) || defined(_WIN32)
|
---|
| 36 | # define DYNLIB_HANDLE hInstance
|
---|
| 37 | # define DYNLIB_LOAD( a ) LoadLibrary( a )
|
---|
| 38 | # define DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
|
---|
| 39 | # define DYNLIB_UNLOAD( a ) !FreeLibrary( a )
|
---|
| 40 |
|
---|
| 41 | struct HINSTANCE__;
|
---|
| 42 | typedef struct HINSTANCE__* hInstance;
|
---|
| 43 |
|
---|
| 44 | #elif defined(__linux__)
|
---|
| 45 | # define DYNLIB_HANDLE void*
|
---|
| 46 | # define DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY )
|
---|
| 47 | # define DYNLIB_GETSYM( a, b ) dlsym( a, b )
|
---|
| 48 | # define DYNLIB_UNLOAD( a ) dlclose( a )
|
---|
| 49 | # define DYNLIB_ERROR( ) dlerror( )
|
---|
| 50 |
|
---|
| 51 | #elif defined(__APPLE_CC__)
|
---|
| 52 | # define DYNLIB_HANDLE CFBundleRef
|
---|
| 53 | # define DYNLIB_LOAD( a ) mac_loadExeBundle( a )
|
---|
| 54 | # define DYNLIB_GETSYM( a, b ) mac_getBundleSym( a, b )
|
---|
| 55 | # define DYNLIB_UNLOAD( a ) mac_unloadExeBundle( a )
|
---|
| 56 | # define DYNLIB_ERROR( ) mac_errorBundle()
|
---|
| 57 | #endif
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | // Start of CEGUI namespace section
|
---|
| 61 | namespace CEGUI
|
---|
| 62 | {
|
---|
| 63 |
|
---|
| 64 | /*!
|
---|
| 65 | \brief
|
---|
| 66 | Class that encapsulates access to a dynamic loadable module containing implementations of Windows, Widgets, and their factories.
|
---|
| 67 | */
|
---|
| 68 | class FactoryModule
|
---|
| 69 | {
|
---|
| 70 | public:
|
---|
| 71 | /*!
|
---|
| 72 | \brief
|
---|
| 73 | Construct the FactoryModule object by loading the dynamic loadable module specified.
|
---|
| 74 |
|
---|
| 75 | \param filename
|
---|
| 76 | String object holding the filename of a loadable module.
|
---|
| 77 |
|
---|
| 78 | \return
|
---|
| 79 | Nothing
|
---|
| 80 | */
|
---|
| 81 | FactoryModule(const String& filename);
|
---|
| 82 |
|
---|
| 83 |
|
---|
| 84 | /*!
|
---|
| 85 | \brief
|
---|
| 86 | Destroys the FactoryModule object and unloads any loadable module.
|
---|
| 87 |
|
---|
| 88 | \return
|
---|
| 89 | Nothing
|
---|
| 90 | */
|
---|
| 91 | virtual ~FactoryModule(void);
|
---|
| 92 |
|
---|
| 93 |
|
---|
| 94 | /*!
|
---|
| 95 | \brief
|
---|
| 96 | Register a WindowFactory for \a type Windows.
|
---|
| 97 |
|
---|
| 98 | \param type
|
---|
| 99 | String object holding the name of the Window type a factory is to be registered for.
|
---|
| 100 |
|
---|
| 101 | \return
|
---|
| 102 | Nothing.
|
---|
| 103 | */
|
---|
| 104 | void registerFactory(const String& type) const;
|
---|
| 105 |
|
---|
| 106 |
|
---|
| 107 | /*!
|
---|
| 108 | \brief
|
---|
| 109 | Register all factories available in this module.
|
---|
| 110 |
|
---|
| 111 | \return
|
---|
| 112 | uint value indicating the number of factories registered.
|
---|
| 113 | */
|
---|
| 114 | uint registerAllFactories() const;
|
---|
| 115 |
|
---|
| 116 | private:
|
---|
| 117 | /*!
|
---|
| 118 | \brief
|
---|
| 119 | Return a String containing the last failure message from the platforms
|
---|
| 120 | dynamic loading system.
|
---|
| 121 | */
|
---|
| 122 | String getFailureString() const;
|
---|
| 123 |
|
---|
| 124 | /*************************************************************************
|
---|
| 125 | Implementation Data
|
---|
| 126 | *************************************************************************/
|
---|
| 127 | static const char RegisterFactoryFunctionName[];
|
---|
| 128 | static const char RegisterAllFunctionName[];
|
---|
| 129 |
|
---|
| 130 | typedef void (*FactoryRegisterFunction)(const String&);
|
---|
| 131 | typedef uint (*RegisterAllFunction)(void);
|
---|
| 132 |
|
---|
| 133 | FactoryRegisterFunction d_regFunc; //!< Pointer to the function called to register factories.
|
---|
| 134 | RegisterAllFunction d_regAllFunc; //!< Pointer to a function called to register all factories in a module.
|
---|
| 135 | String d_moduleName; //!< Holds the name of the loaded module.
|
---|
| 136 | DYNLIB_HANDLE d_handle; //!< Pointer to a ImplDat derived class that can hold any required implementation data
|
---|
| 137 | };
|
---|
| 138 |
|
---|
| 139 | } // End of CEGUI namespace section
|
---|
| 140 |
|
---|
| 141 |
|
---|
| 142 | #endif // end of guard _CEGUIFactoryModule_h_
|
---|