OgreOverlayManager.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __OverlayManager_H__
#define __OverlayManager_H__
#include "OgreOverlayPrerequisites.h"
#include "OgreSingleton.h"
#include "OgreStringVector.h"
#include "OgreOverlay.h"
#include "OgreScriptLoader.h"
#include "OgreFrustum.h"
namespace Ogre {
class _OgreOverlayExport OverlayManager : public Singleton<OverlayManager>, public ScriptLoader, public OverlayAlloc
{
public:
typedef map<String, Overlay*>::type OverlayMap;
typedef map<String, OverlayElement*>::type ElementMap;
typedef map<String, OverlayElementFactory*>::type FactoryMap;
protected:
OverlayMap mOverlayMap;
StringVector mScriptPatterns;
void parseNewElement( DataStreamPtr& chunk, String& elemType, String& elemName,
bool isContainer, Overlay* pOverlay, bool isTemplate, String templateName = String(""), OverlayContainer* container = 0);
void parseAttrib( const String& line, Overlay* pOverlay);
void parseElementAttrib( const String& line, Overlay* pOverlay, OverlayElement* pElement );
void skipToNextCloseBrace(DataStreamPtr& chunk);
void skipToNextOpenBrace(DataStreamPtr& chunk);
int mLastViewportWidth, mLastViewportHeight;
bool mViewportDimensionsChanged;
OrientationMode mLastViewportOrientationMode;
bool parseChildren( DataStreamPtr& chunk, const String& line,
Overlay* pOverlay, bool isTemplate, OverlayContainer* parent = NULL);
FactoryMap mFactories;
ElementMap mInstances;
ElementMap mTemplates;
typedef set<String>::type LoadedScripts;
LoadedScripts mLoadedScripts;
ElementMap& getElementMap(bool isTemplate);
OverlayElement* createOverlayElementImpl(const String& typeName, const String& instanceName, ElementMap& elementMap);
OverlayElement* getOverlayElementImpl(const String& name, ElementMap& elementMap);
bool hasOverlayElementImpl(const String& name, ElementMap& elementMap);
void destroyOverlayElementImpl(const String& instanceName, ElementMap& elementMap);
void destroyOverlayElementImpl(OverlayElement* pInstance, ElementMap& elementMap);
void destroyAllOverlayElementsImpl(ElementMap& elementMap);
public:
OverlayManager();
virtual ~OverlayManager();
const StringVector& getScriptPatterns(void) const;
void parseScript(DataStreamPtr& stream, const String& groupName);
Real getLoadingOrder(void) const;
Overlay* create(const String& name);
Overlay* getByName(const String& name);
void destroy(const String& name);
void destroy(Overlay* overlay);
void destroyAll(void);
typedef MapIterator<OverlayMap> OverlayMapIterator;
OverlayMapIterator getOverlayIterator(void);
void _queueOverlaysForRendering(Camera* cam, RenderQueue* pQueue, Viewport *vp);
bool hasViewportChanged(void) const;
int getViewportHeight(void) const;
int getViewportWidth(void) const;
Real getViewportAspectRatio(void) const;
OrientationMode getViewportOrientationMode(void) const;
OverlayElement* createOverlayElement(const String& typeName, const String& instanceName, bool isTemplate = false);
OverlayElement* getOverlayElement(const String& name, bool isTemplate = false);
bool hasOverlayElement(const String& name, bool isTemplate = false);
void destroyOverlayElement(const String& instanceName, bool isTemplate = false);
void destroyOverlayElement(OverlayElement* pInstance, bool isTemplate = false);
void destroyAllOverlayElements(bool isTemplate = false);
void addOverlayElementFactory(OverlayElementFactory* elemFactory);
const FactoryMap& getOverlayElementFactoryMap() const {
return mFactories;
}
OverlayElement* createOverlayElementFromTemplate(const String& templateName, const String& typeName, const String& instanceName, bool isTemplate = false);
OverlayElement* cloneOverlayElementFromTemplate(const String& templateName, const String& instanceName);
OverlayElement* createOverlayElementFromFactory(const String& typeName, const String& instanceName);
typedef MapIterator<ElementMap> TemplateIterator;
TemplateIterator getTemplateIterator ()
{
return TemplateIterator (mTemplates.begin (), mTemplates.end ()) ;
}
/* Returns whether the Element with the given name is a Template */
bool isTemplate (String strName) const {
return (mTemplates.find (strName) != mTemplates.end()) ;
}
static OverlayManager& getSingleton(void);
static OverlayManager* getSingletonPtr(void);
};
}
#endif
OgreScriptLoader.h
Ogre::OverlayManager::getTemplateIterator
TemplateIterator getTemplateIterator()
Returns an iterator over all templates in this manager.
Definition: OgreOverlayManager.h:205
Ogre::OverlayManager::mLoadedScripts
LoadedScripts mLoadedScripts
Definition: OgreOverlayManager.h:81
Ogre::ScriptLoader
Abstract class defining the interface used by classes which wish to perform script loading to define ...
Definition: OgreScriptLoader.h:59
Ogre::OverlayManager::mLastViewportWidth
int mLastViewportWidth
Definition: OgreOverlayManager.h:68
OgreOverlay.h
Ogre::OverlayManager::mTemplates
ElementMap mTemplates
Definition: OgreOverlayManager.h:78
Ogre::MapIterator
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
Definition: OgreIteratorWrapper.h:319
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::OverlayManager::mScriptPatterns
StringVector mScriptPatterns
Definition: OgreOverlayManager.h:59
Ogre::RenderQueue
Class to manage the scene object rendering queue.
Definition: OgreRenderQueue.h:92
Ogre::StringVector
vector< String >::type StringVector
Definition: OgreStringVector.h:45
_OgreOverlayExport
#define _OgreOverlayExport
Definition: OgreOverlayPrerequisites.h:58
Ogre::OverlayManager
Manages Overlay objects, parsing them from .overlay files and storing a lookup library of them...
Definition: OgreOverlayManager.h:51
Ogre::Viewport
An abstraction of a viewport, i.e.
Definition: OgreViewport.h:57
Ogre::OverlayManager::FactoryMap
map< String, OverlayElementFactory * >::type FactoryMap
Definition: OgreOverlayManager.h:56
Ogre::OrientationMode
OrientationMode
Specifies orientation mode.
Definition: OgreFrustum.h:49
OgreSingleton.h
Ogre::OverlayManager::OverlayMapIterator
MapIterator< OverlayMap > OverlayMapIterator
Definition: OgreOverlayManager.h:123
Ogre::OverlayManager::mFactories
FactoryMap mFactories
Definition: OgreOverlayManager.h:75
OgreStringVector.h
Ogre::OverlayElementFactory
Defines the interface which all components wishing to supply OverlayElement subclasses must implement...
Definition: OgreOverlayElementFactory.h:57
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::OverlayManager::getOverlayElementFactoryMap
const FactoryMap & getOverlayElementFactoryMap() const
Get const access to the list of registered OverlayElement factories.
Definition: OgreOverlayManager.h:189
Ogre::set
Definition: OgrePrerequisites.h:519
OgreOverlayPrerequisites.h
Ogre::Camera
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
Ogre::OverlayManager::mLastViewportOrientationMode
OrientationMode mLastViewportOrientationMode
Definition: OgreOverlayManager.h:70
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::SharedPtr< DataStream >
OgreFrustum.h
Ogre::OverlayManager::LoadedScripts
set< String >::type LoadedScripts
Definition: OgreOverlayManager.h:80
Ogre::OverlayManager::mInstances
ElementMap mInstances
Definition: OgreOverlayManager.h:77
Ogre::OverlayElement
Abstract definition of a 2D element to be displayed in an Overlay.
Definition: OgreOverlayElement.h:108
Ogre::Singleton
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
Ogre::map
Definition: OgrePrerequisites.h:533
Ogre::OverlayContainer
A 2D element which contains other OverlayElement instances.
Definition: OgreOverlayContainer.h:56
Ogre::OverlayManager::mViewportDimensionsChanged
bool mViewportDimensionsChanged
Definition: OgreOverlayManager.h:69
Ogre::OverlayManager::isTemplate
bool isTemplate(String strName) const
Definition: OgreOverlayManager.h:210
Ogre::OverlayManager::ElementMap
map< String, OverlayElement * >::type ElementMap
Definition: OgreOverlayManager.h:55
Ogre::OverlayManager::TemplateIterator
MapIterator< ElementMap > TemplateIterator
Definition: OgreOverlayManager.h:203
Ogre::Overlay
Represents a layer which is rendered on top of the &#39;normal&#39; scene contents.
Definition: OgreOverlay.h:70
Ogre::OverlayManager::mOverlayMap
OverlayMap mOverlayMap
Definition: OgreOverlayManager.h:58
Ogre::OverlayManager::OverlayMap
map< String, Overlay * >::type OverlayMap
Definition: OgreOverlayManager.h:54
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.