OGRE  1.9.0
OgreOverlayManager.h
Go to the documentation of this file.
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-2014 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28#ifndef __OverlayManager_H__
29#define __OverlayManager_H__
30
32#include "OgreSingleton.h"
33#include "OgreStringVector.h"
34#include "OgreOverlay.h"
35#include "OgreScriptLoader.h"
36#include "OgreFrustum.h"
37
38namespace Ogre {
39
51 class _OgreOverlayExport OverlayManager : public Singleton<OverlayManager>, public ScriptLoader, public OverlayAlloc
52 {
53 public:
57 protected:
60
61 void parseNewElement( DataStreamPtr& chunk, String& elemType, String& elemName,
62 bool isContainer, Overlay* pOverlay, bool isTemplate, String templateName = String(""), OverlayContainer* container = 0);
63 void parseAttrib( const String& line, Overlay* pOverlay);
64 void parseElementAttrib( const String& line, Overlay* pOverlay, OverlayElement* pElement );
67
68 int mLastViewportWidth, mLastViewportHeight;
71
72 bool parseChildren( DataStreamPtr& chunk, const String& line,
73 Overlay* pOverlay, bool isTemplate, OverlayContainer* parent = NULL);
74
76
79
82
83
84
85
86 ElementMap& getElementMap(bool isTemplate);
87
88 OverlayElement* createOverlayElementImpl(const String& typeName, const String& instanceName, ElementMap& elementMap);
89
91
92 bool hasOverlayElementImpl(const String& name, ElementMap& elementMap);
93
94 void destroyOverlayElementImpl(const String& instanceName, ElementMap& elementMap);
95
97
99
100 public:
103
105 const StringVector& getScriptPatterns(void) const;
107 void parseScript(DataStreamPtr& stream, const String& groupName);
110
112 Overlay* create(const String& name);
116 Overlay* getByName(const String& name);
118 void destroy(const String& name);
120 void destroy(Overlay* overlay);
122 void destroyAll(void);
125
128
133 bool hasViewportChanged(void) const;
134
136 int getViewportHeight(void) const;
137
139 int getViewportWidth(void) const;
141
144
152 OverlayElement* createOverlayElement(const String& typeName, const String& instanceName, bool isTemplate = false);
153
155 OverlayElement* getOverlayElement(const String& name, bool isTemplate = false);
156
158 bool hasOverlayElement(const String& name, bool isTemplate = false);
159
165 void destroyOverlayElement(const String& instanceName, bool isTemplate = false);
166
172 void destroyOverlayElement(OverlayElement* pInstance, bool isTemplate = false);
173
179 void destroyAllOverlayElements(bool isTemplate = false);
180
187
190 return mFactories;
191 }
192
193 OverlayElement* createOverlayElementFromTemplate(const String& templateName, const String& typeName, const String& instanceName, bool isTemplate = false);
199 OverlayElement* cloneOverlayElementFromTemplate(const String& templateName, const String& instanceName);
200
201 OverlayElement* createOverlayElementFromFactory(const String& typeName, const String& instanceName);
202
206 {
207 return TemplateIterator (mTemplates.begin (), mTemplates.end ()) ;
208 }
209 /* Returns whether the Element with the given name is a Template */
210 bool isTemplate (String strName) const {
211 return (mTemplates.find (strName) != mTemplates.end()) ;
212 }
213
214
247 };
248
249
253}
254
255
256#endif
#define _OgreOverlayExport
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
A viewpoint from which the scene will be rendered.
Definition OgreCamera.h:87
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
A 2D element which contains other OverlayElement instances.
Defines the interface which all components wishing to supply OverlayElement subclasses must implement...
Abstract definition of a 2D element to be displayed in an Overlay.
Manages Overlay objects, parsing them from .overlay files and storing a lookup library of them.
void destroyOverlayElement(OverlayElement *pInstance, bool isTemplate=false)
Destroys a OverlayElement.
void destroyOverlayElement(const String &instanceName, bool isTemplate=false)
Destroys a OverlayElement.
OverlayElement * cloneOverlayElementFromTemplate(const String &templateName, const String &instanceName)
int getViewportWidth(void) const
Gets the width of the destination viewport in pixels.
OverlayMapIterator getOverlayIterator(void)
const FactoryMap & getOverlayElementFactoryMap() const
Get const access to the list of registered OverlayElement factories.
void _queueOverlaysForRendering(Camera *cam, RenderQueue *pQueue, Viewport *vp)
Internal method for queueing the visible overlays for rendering.
void destroyAllOverlayElementsImpl(ElementMap &elementMap)
virtual ~OverlayManager()
OrientationMode mLastViewportOrientationMode
void destroyAllOverlayElements(bool isTemplate=false)
Destroys all the OverlayElement created so far.
void skipToNextOpenBrace(DataStreamPtr &chunk)
Real getLoadingOrder(void) const
Gets the relative loading order of scripts of this type.
void destroyOverlayElementImpl(OverlayElement *pInstance, ElementMap &elementMap)
Overlay * getByName(const String &name)
Retrieve an Overlay by name.
OverlayElement * createOverlayElementFromFactory(const String &typeName, const String &instanceName)
void destroy(const String &name)
Destroys an existing overlay by name.
map< String, Overlay * >::type OverlayMap
Overlay * create(const String &name)
Create a new Overlay.
map< String, OverlayElementFactory * >::type FactoryMap
static OverlayManager * getSingletonPtr(void)
Override standard Singleton retrieval.
bool hasViewportChanged(void) const
Method for determining if the viewport has changed dimensions.
ElementMap & getElementMap(bool isTemplate)
MapIterator< ElementMap > TemplateIterator
void addOverlayElementFactory(OverlayElementFactory *elemFactory)
Registers a new OverlayElementFactory with this manager.
set< String >::type LoadedScripts
void parseNewElement(DataStreamPtr &chunk, String &elemType, String &elemName, bool isContainer, Overlay *pOverlay, bool isTemplate, String templateName=String(""), OverlayContainer *container=0)
OverlayElement * getOverlayElementImpl(const String &name, ElementMap &elementMap)
void destroy(Overlay *overlay)
Destroys an existing overlay.
TemplateIterator getTemplateIterator()
Returns an iterator over all templates in this manager.
void parseAttrib(const String &line, Overlay *pOverlay)
static OverlayManager & getSingleton(void)
Override standard Singleton retrieval.
bool parseChildren(DataStreamPtr &chunk, const String &line, Overlay *pOverlay, bool isTemplate, OverlayContainer *parent=NULL)
MapIterator< OverlayMap > OverlayMapIterator
Real getViewportAspectRatio(void) const
OrientationMode getViewportOrientationMode(void) const
Gets the orientation mode of the destination viewport.
bool hasOverlayElement(const String &name, bool isTemplate=false)
Tests if an element exists.
bool isTemplate(String strName) const
OverlayElement * createOverlayElement(const String &typeName, const String &instanceName, bool isTemplate=false)
Creates a new OverlayElement of the type requested.
void parseScript(DataStreamPtr &stream, const String &groupName)
Parse a script file.
OverlayElement * getOverlayElement(const String &name, bool isTemplate=false)
Gets a reference to an existing element.
OverlayElement * createOverlayElementImpl(const String &typeName, const String &instanceName, ElementMap &elementMap)
OverlayElement * createOverlayElementFromTemplate(const String &templateName, const String &typeName, const String &instanceName, bool isTemplate=false)
void destroyOverlayElementImpl(const String &instanceName, ElementMap &elementMap)
int getViewportHeight(void) const
Gets the height of the destination viewport in pixels.
void skipToNextCloseBrace(DataStreamPtr &chunk)
void destroyAll(void)
Destroys all existing overlays.
map< String, OverlayElement * >::type ElementMap
bool hasOverlayElementImpl(const String &name, ElementMap &elementMap)
const StringVector & getScriptPatterns(void) const
Gets the file patterns which should be used to find scripts for this class.
void parseElementAttrib(const String &line, Overlay *pOverlay, OverlayElement *pElement)
Represents a layer which is rendered on top of the 'normal' scene contents.
Definition OgreOverlay.h:71
Class to manage the scene object rendering queue.
Abstract class defining the interface used by classes which wish to perform script loading to define ...
Template class for creating single-instance global classes.
An abstraction of a viewport, i.e.
vector< String >::type StringVector
OrientationMode
Specifies orientation mode.
Definition OgreFrustum.h:50
float Real
Software floating point type.
_StringBase String
std::map< K, V, P, A > type
std::set< T, P, A > type