SCV
4.2.1
Simple Components for Visual
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
Singleton.h
Go to the documentation of this file.
1
#ifndef __SINGLETON_H__
2
#define __SINGLETON_H__
3
4
template
<
typename
T>
5
class
Singleton
{
6
public
:
7
static
void
setInstance
(T *instance) {
8
_instance
= instance;
9
};
10
11
static
T*
getInstance
() {
12
if
(
_instance
== 0)
_instance
=
new
T;
13
return
_instance
;
14
};
15
16
static
void
destroyInstance
() {
17
delete
_instance
;
18
_instance
= 0;
19
};
20
21
protected
:
22
Singleton
(
void
) {
23
};
24
virtual
~Singleton
(
void
) {
25
};
26
27
Singleton
(
const
Singleton
& source) {
28
};
29
30
static
T*
_instance
;
31
};
32
33
template
<
typename
T> T*
Singleton<T>::_instance
= 0;
34
35
#endif // ! defined __SINGLETON_H__
include
SCV
Singleton.h
Generated on Fri Dec 14 2012 09:44:49 for SCV by
1.8.2