source: GTP/trunk/Lib/Geom/OgreStuff/include/OgreSceneManagerEnumerator.h @ 1809

Revision 1809, 8.8 KB checked in by gumbau, 18 years ago (diff)
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25#ifndef __SceneManagerEnumerator_H__
26#define __SceneManagerEnumerator_H__
27
28#include "OgrePrerequisites.h"
29
30#include "OgreSceneManager.h"
31#include "OgreSingleton.h"
32#include "OgreIteratorWrappers.h"
33
34namespace Ogre {
35   
36        /// Factory for default scene manager
37        class _OgreExport DefaultSceneManagerFactory : public SceneManagerFactory
38        {
39        protected:
40                void initMetaData(void) const;
41        public:
42                DefaultSceneManagerFactory() {}
43                ~DefaultSceneManagerFactory() {}
44                /// Factory type name
45                static const String FACTORY_TYPE_NAME;
46                SceneManager* createInstance(const String& instanceName);
47                void destroyInstance(SceneManager* instance);
48        };
49        /// Default scene manager
50        class _OgreExport DefaultSceneManager : public SceneManager
51        {
52        public:
53                DefaultSceneManager(const String& name);
54                ~DefaultSceneManager();
55                const String& getTypeName(void) const;
56        };
57
58    /** Enumerates the SceneManager classes available to applications.
59        @remarks
60            As described in the SceneManager class, SceneManagers are responsible
61            for organising the scene and issuing rendering commands to the
62            RenderSystem. Certain scene types can benefit from different
63            rendering approaches, and it is intended that subclasses will
64            be created to special case this.
65        @par
66            In order to give applications easy access to these implementations,
67            this class has a number of methods to create or retrieve a SceneManager
68            which is appropriate to the scene type.
69                @par
70                        SceneManagers are created by SceneManagerFactory instances. New factories
71                        for new types of SceneManager can be registered with this class to make
72                        them available to clients.
73                @par
74                        Note that you can still plug in your own custom SceneManager without
75                        using a factory, should you choose, it's just not as flexible that way.
76                        Just instantiate your own SceneManager manually and use it directly.
77    */
78    class _OgreExport SceneManagerEnumerator : public Singleton<SceneManagerEnumerator>
79    {
80        public:
81                /// Scene manager instances, indexed by instance name
82                typedef std::map<String, SceneManager*> Instances;
83                /// List of available scene manager types as meta data
84                typedef std::vector<const SceneManagerMetaData*> MetaDataList;
85    private:
86                /// Scene manager factories
87                typedef std::list<SceneManagerFactory*> Factories;
88                Factories mFactories;
89                Instances mInstances;
90                /// Stored separately to allow iteration
91                MetaDataList mMetaDataList;
92                /// Factory for default scene manager
93                DefaultSceneManagerFactory mDefaultFactory;
94                /// Count of creations for auto-naming
95                unsigned long mInstanceCreateCount;
96                /// Currently assigned render system
97                RenderSystem* mCurrentRenderSystem;
98
99
100    public:
101        SceneManagerEnumerator();
102        ~SceneManagerEnumerator();
103
104                /** Register a new SceneManagerFactory.
105                @remarks
106                        Plugins should call this to register as new SceneManager providers.
107                */
108                void addFactory(SceneManagerFactory* fact);
109
110                /** Remove a SceneManagerFactory.
111                */
112                void removeFactory(SceneManagerFactory* fact);
113
114                /** Get more information about a given type of SceneManager.
115                @remarks
116                        The metadata returned tells you a few things about a given type
117                        of SceneManager, which can be created using a factory that has been
118                        registered already.
119                @param typeName The type name of the SceneManager you want to enquire on.
120                        If you don't know the typeName already, you can iterate over the
121                        metadata for all types using getMetaDataIterator.
122                */
123                const SceneManagerMetaData* getMetaData(const String& typeName) const;
124
125                typedef ConstVectorIterator<MetaDataList> MetaDataIterator;
126                /** Iterate over all types of SceneManager available for construction,
127                        providing some information about each one.
128                */
129                MetaDataIterator getMetaDataIterator(void) const;
130
131                /** Create a SceneManager instance of a given type.
132                @remarks
133                        You can use this method to create a SceneManager instance of a
134                        given specific type. You may know this type already, or you may
135                        have discovered it by looking at the results from getMetaDataIterator.
136                @note
137                        This method throws an exception if the named type is not found.
138                @param typeName String identifying a unique SceneManager type
139                @param instanceName Optional name to given the new instance that is
140                        created. If you leave this blank, an auto name will be assigned.
141                */
142                SceneManager* createSceneManager(const String& typeName,
143                        const String& instanceName = StringUtil::BLANK);
144
145                /** Create a SceneManager instance based on scene type support.
146                @remarks
147                        Creates an instance of a SceneManager which supports the scene types
148                        identified in the parameter. If more than one type of SceneManager
149                        has been registered as handling that combination of scene types,
150                        in instance of the last one registered is returned.
151                @note This method always succeeds, if a specific scene manager is not
152                        found, the default implementation is always returned.
153                @param typeMask A mask containing one or more SceneType flags
154                @param instanceName Optional name to given the new instance that is
155                        created. If you leave this blank, an auto name will be assigned.
156                */
157                SceneManager* createSceneManager(SceneTypeMask typeMask,
158                        const String& instanceName = StringUtil::BLANK);
159
160                /** Destroy an instance of a SceneManager. */
161                void destroySceneManager(SceneManager* sm);
162
163                /** Get an existing SceneManager instance that has already been created,
164                        identified by the instance name.
165                @param instanceName The name of the instance to retrieve.
166                */
167                SceneManager* getSceneManager(const String& instanceName) const;
168
169                typedef MapIterator<Instances> SceneManagerIterator;
170                /** Get an iterator over all the existing SceneManager instances. */
171                SceneManagerIterator getSceneManagerIterator(void);
172
173        /** Notifies all SceneManagers of the destination rendering system.
174        */
175        void setRenderSystem(RenderSystem* rs);
176
177        /// Utility method to control shutdown of the managers
178        void shutdownAll(void);
179        /** Override standard Singleton retrieval.
180        @remarks
181        Why do we do this? Well, it's because the Singleton
182        implementation is in a .h file, which means it gets compiled
183        into anybody who includes it. This is needed for the
184        Singleton template to work, but we actually only want it
185        compiled into the implementation of the class based on the
186        Singleton, not all of them. If we don't change this, we get
187        link errors when trying to use the Singleton-based class from
188        an outside dll.
189        @par
190        This method just delegates to the template version anyway,
191        but the implementation stays in this single compilation unit,
192        preventing link errors.
193        */
194        static SceneManagerEnumerator& getSingleton(void);
195        /** Override standard Singleton retrieval.
196        @remarks
197        Why do we do this? Well, it's because the Singleton
198        implementation is in a .h file, which means it gets compiled
199        into anybody who includes it. This is needed for the
200        Singleton template to work, but we actually only want it
201        compiled into the implementation of the class based on the
202        Singleton, not all of them. If we don't change this, we get
203        link errors when trying to use the Singleton-based class from
204        an outside dll.
205        @par
206        This method just delegates to the template version anyway,
207        but the implementation stays in this single compilation unit,
208        preventing link errors.
209        */
210        static SceneManagerEnumerator* getSingletonPtr(void);
211
212    };
213
214
215}
216
217#endif
Note: See TracBrowser for help on using the repository browser.