2010-05-07 04:47:10 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2010, Pier Luigi Fiorini. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _SINGLETON_H
|
|
|
|
#define _SINGLETON_H
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
class Singleton {
|
|
|
|
public:
|
2010-05-19 16:36:36 -05:00
|
|
|
static T* Get()
|
|
|
|
{
|
|
|
|
if (!fInstance)
|
|
|
|
fInstance = new T();
|
|
|
|
return fInstance;
|
|
|
|
}
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
protected:
|
2010-05-19 16:36:36 -05:00
|
|
|
static T* fInstance;
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-05-19 16:36:36 -05:00
|
|
|
Singleton() {}
|
2010-05-07 04:47:10 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _SINGLETON_H
|