/src/ogre/OgreMain/src/OgreSceneManagerEnumerator.h
Line | Count | Source |
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-2014 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 __SceneManagerEnumerator_H__ |
29 | | #define __SceneManagerEnumerator_H__ |
30 | | |
31 | | #include "OgrePrerequisites.h" |
32 | | |
33 | | #include "OgreSceneManager.h" |
34 | | #include "OgreSingleton.h" |
35 | | #include "OgreHeaderPrefix.h" |
36 | | |
37 | | namespace Ogre { |
38 | | |
39 | | /** \addtogroup Core |
40 | | * @{ |
41 | | */ |
42 | | /** \addtogroup Scene |
43 | | * @{ |
44 | | */ |
45 | | /// Factory for default scene manager |
46 | | class DefaultSceneManagerFactory : public SceneManagerFactory |
47 | | { |
48 | | public: |
49 | 0 | DefaultSceneManagerFactory() {} |
50 | 0 | ~DefaultSceneManagerFactory() {} |
51 | | SceneManager* createInstance(const String& instanceName) override; |
52 | 0 | const String& getTypeName(void) const override { return SMT_DEFAULT; } |
53 | | }; |
54 | | |
55 | | /// Default scene manager |
56 | | class DefaultSceneManager : public SceneManager |
57 | | { |
58 | | public: |
59 | | DefaultSceneManager(const String& name); |
60 | | ~DefaultSceneManager(); |
61 | | const String& getTypeName(void) const override; |
62 | | }; |
63 | | |
64 | | /** Enumerates the SceneManager classes available to applications. |
65 | | |
66 | | As described in the SceneManager class, SceneManagers are responsible |
67 | | for organising the scene and issuing rendering commands to the |
68 | | RenderSystem. Certain scene types can benefit from different |
69 | | rendering approaches, and it is intended that subclasses will |
70 | | be created to special case this. |
71 | | @par |
72 | | In order to give applications easy access to these implementations, |
73 | | this class has a number of methods to create or retrieve a SceneManager |
74 | | which is appropriate to the scene type. |
75 | | @par |
76 | | SceneManagers are created by SceneManagerFactory instances. New factories |
77 | | for new types of SceneManager can be registered with this class to make |
78 | | them available to clients. |
79 | | @par |
80 | | Note that you can still plug in your own custom SceneManager without |
81 | | using a factory, should you choose, it's just not as flexible that way. |
82 | | Just instantiate your own SceneManager manually and use it directly. |
83 | | */ |
84 | | class SceneManagerEnumerator : public Singleton<SceneManagerEnumerator>, public SceneMgtAlloc |
85 | | { |
86 | | public: |
87 | | /// Scene manager instances, indexed by instance name |
88 | | typedef std::map<String, SceneManager*> Instances; |
89 | | private: |
90 | | /// Scene manager factories |
91 | | typedef std::map<String, SceneManagerFactory*> Factories; |
92 | | Factories mFactories; |
93 | | Instances mInstances; |
94 | | /// Stored separately to allow iteration |
95 | | StringVector mMetaDataList; |
96 | | /// Factory for default scene manager |
97 | | DefaultSceneManagerFactory mDefaultFactory; |
98 | | /// Count of creations for auto-naming |
99 | | unsigned long mInstanceCreateCount; |
100 | | /// Currently assigned render system |
101 | | RenderSystem* mCurrentRenderSystem; |
102 | | |
103 | | |
104 | | public: |
105 | | SceneManagerEnumerator(); |
106 | | ~SceneManagerEnumerator(); |
107 | | |
108 | | void addFactory(SceneManagerFactory* fact); |
109 | | |
110 | | void removeFactory(SceneManagerFactory* fact); |
111 | | |
112 | 0 | const StringVector& getMetaData() const { return mMetaDataList; } |
113 | | |
114 | | SceneManager* createSceneManager(const String& typeName, |
115 | | const String& instanceName = BLANKSTRING); |
116 | | |
117 | | void destroySceneManager(SceneManager* sm); |
118 | | |
119 | | SceneManager* getSceneManager(const String& instanceName) const; |
120 | | |
121 | | bool hasSceneManager(const String& instanceName) const; |
122 | | |
123 | | /// Get all the existing SceneManager instances. |
124 | | const Instances& getSceneManagers() const; |
125 | | |
126 | | /** Notifies all SceneManagers of the destination rendering system. |
127 | | */ |
128 | | void setRenderSystem(RenderSystem* rs); |
129 | | |
130 | | /// Utility method to control shutdown of the managers |
131 | | void shutdownAll(void); |
132 | | /// @copydoc Singleton::getSingleton() |
133 | | static SceneManagerEnumerator& getSingleton(void); |
134 | | /// @copydoc Singleton::getSingleton() |
135 | | static SceneManagerEnumerator* getSingletonPtr(void); |
136 | | |
137 | | }; |
138 | | |
139 | | /** @} */ |
140 | | /** @} */ |
141 | | |
142 | | } |
143 | | |
144 | | #include "OgreHeaderSuffix.h" |
145 | | |
146 | | #endif |