[148] | 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 __Lod_Strategy_Manager_H__ |
---|
| 29 | #define __Lod_Strategy_Manager_H__ |
---|
| 30 | |
---|
| 31 | #include "OgrePrerequisites.h" |
---|
| 32 | |
---|
| 33 | #include "OgreLodStrategy.h" |
---|
| 34 | #include "OgreSingleton.h" |
---|
| 35 | #include "OgreIteratorWrappers.h" |
---|
| 36 | #include "OgreHeaderPrefix.h" |
---|
| 37 | |
---|
| 38 | namespace Ogre { |
---|
| 39 | |
---|
| 40 | /** \addtogroup Core |
---|
| 41 | * @{ |
---|
| 42 | */ |
---|
| 43 | /** \addtogroup LOD |
---|
| 44 | * @{ |
---|
| 45 | */ |
---|
| 46 | /** Manager for LOD strategies. */ |
---|
| 47 | class _OgreExport LodStrategyManager : public Singleton<LodStrategyManager>, public LodAlloc |
---|
| 48 | { |
---|
| 49 | /** Map of strategies. */ |
---|
| 50 | typedef map<String, LodStrategy *>::type StrategyMap; |
---|
| 51 | |
---|
| 52 | /** Internal map of strategies. */ |
---|
| 53 | StrategyMap mStrategies; |
---|
| 54 | |
---|
| 55 | /** Default strategy. */ |
---|
| 56 | LodStrategy *mDefaultStrategy; |
---|
| 57 | |
---|
| 58 | public: |
---|
| 59 | /** Default constructor. */ |
---|
| 60 | LodStrategyManager(); |
---|
| 61 | |
---|
| 62 | /** Destructor. */ |
---|
| 63 | ~LodStrategyManager(); |
---|
| 64 | |
---|
| 65 | /** Add a strategy to the manager. */ |
---|
| 66 | void addStrategy(LodStrategy *strategy); |
---|
| 67 | |
---|
| 68 | /** Remove a strategy from the manager with a specified name. |
---|
| 69 | @remarks |
---|
| 70 | The removed strategy is returned so the user can control |
---|
| 71 | how it is destroyed. |
---|
| 72 | */ |
---|
| 73 | LodStrategy *removeStrategy(const String& name); |
---|
| 74 | |
---|
| 75 | /** Remove and delete all strategies from the manager. |
---|
| 76 | @remarks |
---|
| 77 | All strategies are deleted. If finer control is required |
---|
| 78 | over strategy destruction, use removeStrategy. |
---|
| 79 | */ |
---|
| 80 | void removeAllStrategies(); |
---|
| 81 | |
---|
| 82 | /** Get the strategy with the specified name. */ |
---|
| 83 | LodStrategy *getStrategy(const String& name); |
---|
| 84 | |
---|
| 85 | /** Set the default strategy. */ |
---|
| 86 | void setDefaultStrategy(LodStrategy *strategy); |
---|
| 87 | |
---|
| 88 | /** Set the default strategy by name. */ |
---|
| 89 | void setDefaultStrategy(const String& name); |
---|
| 90 | |
---|
| 91 | /** Get the current default strategy. */ |
---|
| 92 | LodStrategy *getDefaultStrategy(); |
---|
| 93 | |
---|
| 94 | /** Get an iterator for all contained strategies. */ |
---|
| 95 | MapIterator<StrategyMap> getIterator(); |
---|
| 96 | |
---|
| 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 LodStrategyManager& getSingleton(void); |
---|
| 113 | /** Override standard Singleton retrieval. |
---|
| 114 | @remarks |
---|
| 115 | Why do we do this? Well, it's because the Singleton |
---|
| 116 | implementation is in a .h file, which means it gets compiled |
---|
| 117 | into anybody who includes it. This is needed for the |
---|
| 118 | Singleton template to work, but we actually only want it |
---|
| 119 | compiled into the implementation of the class based on the |
---|
| 120 | Singleton, not all of them. If we don't change this, we get |
---|
| 121 | link errors when trying to use the Singleton-based class from |
---|
| 122 | an outside dll. |
---|
| 123 | @par |
---|
| 124 | This method just delegates to the template version anyway, |
---|
| 125 | but the implementation stays in this single compilation unit, |
---|
| 126 | preventing link errors. |
---|
| 127 | */ |
---|
| 128 | static LodStrategyManager* getSingletonPtr(void); |
---|
| 129 | }; |
---|
| 130 | /** @} */ |
---|
| 131 | /** @} */ |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | #include "OgreHeaderSuffix.h" |
---|
| 135 | |
---|
| 136 | #endif |
---|