| 1 | /* |
|---|
| 2 | ----------------------------------------------------------------------------- |
|---|
| 3 | This source file is part of OGRE |
|---|
| 4 | (Object-oriented Graphics Rendering Engine) |
|---|
| 5 | For the latest info, see http://www.ogre3d.org/ |
|---|
| 6 | |
|---|
| 7 | Copyright (c) 2000-2013 Torus Knot Software Ltd |
|---|
| 8 | |
|---|
| 9 | Permission is hereby granted, free of charge, to any person obtaining a copy |
|---|
| 10 | of this software and associated documentation files (the "Software"), to deal |
|---|
| 11 | in the Software without restriction, including without limitation the rights |
|---|
| 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|---|
| 13 | copies of the Software, and to permit persons to whom the Software is |
|---|
| 14 | furnished to do so, subject to the following conditions: |
|---|
| 15 | |
|---|
| 16 | The above copyright notice and this permission notice shall be included in |
|---|
| 17 | all copies or substantial portions of the Software. |
|---|
| 18 | |
|---|
| 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|---|
| 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|---|
| 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|---|
| 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|---|
| 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|---|
| 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|---|
| 25 | THE SOFTWARE. |
|---|
| 26 | ----------------------------------------------------------------------------- |
|---|
| 27 | */ |
|---|
| 28 | #ifndef __DynLibManager_H__ |
|---|
| 29 | #define __DynLibManager_H__ |
|---|
| 30 | |
|---|
| 31 | #include "OgrePrerequisites.h" |
|---|
| 32 | #include "OgreSingleton.h" |
|---|
| 33 | #include "OgreHeaderPrefix.h" |
|---|
| 34 | |
|---|
| 35 | namespace Ogre { |
|---|
| 36 | /** \addtogroup Core |
|---|
| 37 | * @{ |
|---|
| 38 | */ |
|---|
| 39 | /** \addtogroup General |
|---|
| 40 | * @{ |
|---|
| 41 | */ |
|---|
| 42 | /** Manager for Dynamic-loading Libraries. |
|---|
| 43 | @remarks |
|---|
| 44 | This manager keeps a track of all the open dynamic-loading |
|---|
| 45 | libraries, opens them and returns references to already-open |
|---|
| 46 | libraries. |
|---|
| 47 | */ |
|---|
| 48 | class _OgreExport DynLibManager: public Singleton<DynLibManager>, public DynLibAlloc |
|---|
| 49 | { |
|---|
| 50 | protected: |
|---|
| 51 | typedef map<String, DynLib*>::type DynLibList; |
|---|
| 52 | DynLibList mLibList; |
|---|
| 53 | public: |
|---|
| 54 | /** Default constructor. |
|---|
| 55 | @note |
|---|
| 56 | <br>Should never be called as the singleton is automatically |
|---|
| 57 | created during the creation of the Root object. |
|---|
| 58 | @see |
|---|
| 59 | Root::Root |
|---|
| 60 | */ |
|---|
| 61 | DynLibManager(); |
|---|
| 62 | |
|---|
| 63 | /** Default destructor. |
|---|
| 64 | @see |
|---|
| 65 | Root::~Root |
|---|
| 66 | */ |
|---|
| 67 | virtual ~DynLibManager(); |
|---|
| 68 | |
|---|
| 69 | /** Loads the passed library. |
|---|
| 70 | @param filename |
|---|
| 71 | The name of the library. The extension can be omitted. |
|---|
| 72 | */ |
|---|
| 73 | DynLib* load(const String& filename); |
|---|
| 74 | |
|---|
| 75 | /** Unloads the passed library. |
|---|
| 76 | @param lib |
|---|
| 77 | The library. |
|---|
| 78 | */ |
|---|
| 79 | void unload(DynLib* lib); |
|---|
| 80 | |
|---|
| 81 | /** Override standard Singleton retrieval. |
|---|
| 82 | @remarks |
|---|
| 83 | Why do we do this? Well, it's because the Singleton |
|---|
| 84 | implementation is in a .h file, which means it gets compiled |
|---|
| 85 | into anybody who includes it. This is needed for the |
|---|
| 86 | Singleton template to work, but we actually only want it |
|---|
| 87 | compiled into the implementation of the class based on the |
|---|
| 88 | Singleton, not all of them. If we don't change this, we get |
|---|
| 89 | link errors when trying to use the Singleton-based class from |
|---|
| 90 | an outside dll. |
|---|
| 91 | @par |
|---|
| 92 | This method just delegates to the template version anyway, |
|---|
| 93 | but the implementation stays in this single compilation unit, |
|---|
| 94 | preventing link errors. |
|---|
| 95 | */ |
|---|
| 96 | static DynLibManager& getSingleton(void); |
|---|
| 97 | /** Override standard Singleton retrieval. |
|---|
| 98 | @remarks |
|---|
| 99 | Why do we do this? Well, it's because the Singleton |
|---|
| 100 | implementation is in a .h file, which means it gets compiled |
|---|
| 101 | into anybody who includes it. This is needed for the |
|---|
| 102 | Singleton template to work, but we actually only want it |
|---|
| 103 | compiled into the implementation of the class based on the |
|---|
| 104 | Singleton, not all of them. If we don't change this, we get |
|---|
| 105 | link errors when trying to use the Singleton-based class from |
|---|
| 106 | an outside dll. |
|---|
| 107 | @par |
|---|
| 108 | This method just delegates to the template version anyway, |
|---|
| 109 | but the implementation stays in this single compilation unit, |
|---|
| 110 | preventing link errors. |
|---|
| 111 | */ |
|---|
| 112 | static DynLibManager* getSingletonPtr(void); |
|---|
| 113 | }; |
|---|
| 114 | /** @} */ |
|---|
| 115 | /** @} */ |
|---|
| 116 | } // namespace Ogre |
|---|
| 117 | |
|---|
| 118 | #include "OgreHeaderSuffix.h" |
|---|
| 119 | |
|---|
| 120 | #endif // __DynLibManager_H__ |
|---|