QGIS API Documentation
2.8.6-Wien
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
src
core
qgssingleton.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgssingleton.h
3
--------------------------------------
4
Date : 24.11.2014
5
Copyright : (C) 2014 Matthias Kuhn
6
Email : matthias dot kuhn at gmx dot ch
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
#ifndef QGSSINGLETON_H
17
#define QGSSINGLETON_H
18
19
template
<
typename
T>
20
class
QgsSingleton
21
{
22
public
:
23
static
T*
instance
()
24
{
25
if
( sInstance == 0 )
26
{
27
sInstance = createInstance();
28
}
29
return
sInstance;
30
}
31
32
static
void
cleanup
()
33
{
34
delete
sInstance;
35
sInstance = 0;
36
}
37
38
protected
:
39
virtual
~QgsSingleton
() {}
40
41
explicit
QgsSingleton
()
42
{
43
}
44
45
private
:
46
static
T* sInstance;
47
static
T* createInstance()
48
{
49
return
new
T;
50
}
51
};
52
53
template
<
typename
T> T*
QgsSingleton<T>::sInstance
= 0;
54
55
#endif // QGSSINGLETON_H
QgsSingleton
Definition:
qgssingleton.h:20
QgsSingleton::instance
static T * instance()
Definition:
qgssingleton.h:23
QgsSingleton::QgsSingleton
QgsSingleton()
Definition:
qgssingleton.h:41
QgsSingleton::cleanup
static void cleanup()
Definition:
qgssingleton.h:32
QgsSingleton::~QgsSingleton
virtual ~QgsSingleton()
Definition:
qgssingleton.h:39
Generated on Mon Feb 1 2016 14:19:44 for QGIS API Documentation by
1.8.8