File dialog code CEGUISingletonX.h for Linux
A Common File Dialog window for CEGUI - singletonX (Linux)
Welcome to the new Ogre Wiki!
If you haven't done so already, be sure to visit the Wiki Portal to read about how the wiki works. Especially the Ogre Wiki Overview page.
If you haven't done so already, be sure to visit the Wiki Portal to read about how the wiki works. Especially the Ogre Wiki Overview page.
CEGUISingletonX.h
/***************************************************************************** Written by spookyboo ported to Linux by ancestral (granturkoATgmail.com) *****************************************************************************/ #ifndef _CEGUI_SINGLETON_X_H_ #define _CEGUI_SINGLETON_X_H_ #if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 4786) #endif namespace CEGUI { /************************************************************************* Class: CEGUISingletonX Alternative for the existing CEGUI Singleton class. This one doesn't require the Singleton to be explicitly instantiated by 'new'. *************************************************************************/ template<class T> class CEGUISingletonX { private: class _InstPtr { public: _InstPtr() : m_ptr(0) {} ~_InstPtr() { delete m_ptr; } T* get() { return m_ptr; } void Set(T* p) { if(p!= 0) { delete m_ptr; m_ptr = p; } } private: T* m_ptr; }; static _InstPtr sm_ptr; CEGUISingletonX(); CEGUISingletonX(const CEGUISingletonX&); CEGUISingletonX& operator=(const CEGUISingletonX&); public: static T& getSingleton() { if(sm_ptr.get() == 0) { sm_ptr.Set(new T()); } return *sm_ptr.get(); } static T* getSingletonPtr() { if(sm_ptr.get() == 0) { sm_ptr.Set(new T()); } return sm_ptr.get(); } }; template <class T> typename CEGUISingletonX<T>::_InstPtr CEGUISingletonX<T>::sm_ptr ; } #endif
Contributors to this page: jacmoe
and
Spacegaier
.
Page last modified on Saturday 02 of January, 2010 21:17:35 UTC by jacmoe
.
The content on this page is licensed under the terms of the Creative Commons Attribution-ShareAlike License.
As an exception, any source code contributed within the content is released into the Public Domain.
Sidebar
Search box
Online users
59
online users

