source: OGRE/trunk/ogrenew/Tools/MayaExport/include/singleton.h @ 692

Revision 692, 747 bytes checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

Line 
1#ifndef _SINGLETON_H__
2#define _SINGLETON_H__
3
4// Copied frome Ogre::Singleton, created by Steve Streeting for Ogre
5
6namespace OgreMayaExporter
7{
8    /** Template class for creating single-instance global classes.
9    */
10    template <typename T> class Singleton
11    {
12    protected:
13        static T* ms_Singleton;
14
15    public:
16        Singleton(){
17            assert( !ms_Singleton );
18                    ms_Singleton = static_cast< T* >( this );
19        }
20        ~Singleton(){
21                        assert( ms_Singleton );
22                        ms_Singleton = 0; 
23                }
24                static T& getSingleton(){
25                        assert( ms_Singleton ); 
26                        return ( *ms_Singleton );
27                }
28        static T* getSingletonPtr(){
29                        return ms_Singleton;
30                }
31    };
32
33}; // end namespace
34#endif
Note: See TracBrowser for help on using the repository browser.