Apache SINGA
A distributed deep learning platform .
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerator
Macros
asf
incubator-singa
include
utils
singleton.h
1
#ifndef INCLUDE_UTILS_SINGLETON_H_
2
#define INCLUDE_UTILS_SINGLETON_H_
3
4
template
<
typename
T>
5
class
Singleton
{
6
public
:
7
static
T* Instance() {
8
if
(data_==
nullptr
) {
9
data_ =
new
T();
10
}
11
return
data_;
12
}
13
private
:
14
static
T* data_;
15
};
16
17
template
<
typename
T> T*
Singleton<T>::data_
=
nullptr
;
18
19
23
template
<
typename
T,
typename
X=
int
>
24
class
ASingleton
{
25
public
:
26
static
T* Instance(){
27
return
data_;
28
}
29
static
T* Instance(X x) {
30
if
(data_==
nullptr
) {
31
data_ =
new
T(x);
32
}
33
return
data_;
34
}
35
private
:
36
static
T* data_;
37
};
38
39
template
<
typename
T,
typename
X> T*
ASingleton<T,X>::data_
=
nullptr
;
40
41
#endif // INCLUDE_UTILS_SINGLETON_H_
ASingleton
Singleton initiated with argument.
Definition:
singleton.h:24
Singleton
Definition:
singleton.h:5
Generated on Thu May 28 2015 15:16:12 for Apache SINGA by
1.8.6