Main Page
Namespaces
Classes
Files
File List
include
robotis_framework_common
singleton.h
Go to the documentation of this file.
1
/*******************************************************************************
2
* Copyright 2018 ROBOTIS CO., LTD.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*******************************************************************************/
16
17
/*
18
* singleton.h
19
*
20
* Created on: 2016. 5. 17.
21
* Author: zerom
22
*/
23
24
#ifndef ROBOTIS_FRAMEWORK_COMMON_SINGLETON_H_
25
#define ROBOTIS_FRAMEWORK_COMMON_SINGLETON_H_
26
27
28
namespace
robotis_framework
29
{
30
31
template
<
class
T>
32
class
Singleton
33
{
34
private
:
35
static
T *
unique_instance_
;
36
37
protected
:
38
Singleton
() { }
39
Singleton
(
Singleton
const
&) { }
40
Singleton
&
operator=
(
Singleton
const
&) {
return
*
this
; }
41
42
public
:
43
static
T*
getInstance
()
44
{
45
if
(unique_instance_ == NULL)
46
unique_instance_ =
new
T;
47
return
unique_instance_
;
48
}
49
50
static
void
destroyInstance
()
51
{
52
if
(unique_instance_)
53
{
54
delete
unique_instance_
;
55
unique_instance_ = NULL;
56
}
57
}
58
};
59
60
template
<
class
T> T*
Singleton<T>::unique_instance_
= NULL;
61
62
}
63
64
65
#endif
/* ROBOTIS_FRAMEWORK_COMMON_SINGLETON_H_ */
robotis_framework::Singleton::destroyInstance
static void destroyInstance()
Definition:
singleton.h:50
robotis_framework::Singleton::unique_instance_
static T * unique_instance_
Definition:
singleton.h:35
robotis_framework::Singleton::getInstance
static T * getInstance()
Definition:
singleton.h:43
robotis_framework
robotis_framework::Singleton::Singleton
Singleton()
Definition:
singleton.h:38
robotis_framework::Singleton
Definition:
singleton.h:32
robotis_framework::Singleton::Singleton
Singleton(Singleton const &)
Definition:
singleton.h:39
robotis_framework::Singleton::operator=
Singleton & operator=(Singleton const &)
Definition:
singleton.h:40
robotis_framework_common
Author(s): Zerom
, Kayman
, SCH
autogenerated on Mon Jun 10 2019 14:35:11