TexGen
Core
Singleton.h
Go to the documentation of this file.
1
/*=============================================================================
2
TexGen: Geometric textile modeller.
3
Copyright (C) 2006 Martin Sherburn
4
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License
7
as published by the Free Software Foundation; either version 2
8
of the License, or (at your option) any later version.
9
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
=============================================================================*/
19
20
#pragma once
21
namespace
TexGen
22
{
24
30
template
<
typename
T>
31
class
CLASS_DECLSPEC
CSingleton
32
{
33
public
:
34
CSingleton
()
35
{
36
// There should only be one instance created, only use static GetInstance() function
37
// instead of instantiating manually
38
assert(
this
== &
CSingleton::GetInstance
());
39
}
40
static
T &
GetInstance
()
41
{
42
return
m_SingleInstance;
43
}
44
protected
:
45
static
T
m_SingleInstance
;
46
};
47
48
};
// namespace TexGen
CLASS_DECLSPEC
#define CLASS_DECLSPEC
Definition:
Misc.h:35
TexGen::CSingleton
Template used as a base class for creating singletons.
Definition:
Singleton.h:32
TexGen::CSingleton::CSingleton
CSingleton()
Definition:
Singleton.h:34
TexGen::CSingleton::GetInstance
static T & GetInstance()
Definition:
Singleton.h:40
TexGen::CSingleton::m_SingleInstance
static T m_SingleInstance
Definition:
Singleton.h:45
TexGen
Namespace containing a series of customised math operations not found in the standard c++ library.
Definition:
AdjustMeshInterference.h:27
Generated by
1.9.2