source: nscp/trunk/include/Singleton.h @ 7da80b5

Last change on this file since 7da80b5 was e0705d4, checked in by Michael Medin <michael@…>, 8 years ago

Initial release

  • Property mode set to 100644
File size: 484 bytes
Line 
1// Singleton.h: interface for the Singleton class.
2//
3//////////////////////////////////////////////////////////////////////
4
5#pragma once
6
7template <class T>
8class Singleton {
9private:
10        static T* pObject;
11protected:
12        Singleton() {}
13        virtual ~Singleton() {}
14
15public:
16        static T* getInstance() {
17                if (!pObject)
18                        pObject = new T();
19                return pObject;
20        }
21        static void destroyInstance() {
22                delete pObject;
23                pObject = NULL;
24        }
25};
26
27template <class T>
28T* Singleton<T>::pObject = NULL;
29
Note: See TracBrowser for help on using the repository browser.