Crazy Eddies GUI System
0.7.9
Main Page
Related Pages
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Pages
CEGUISingleton.h
1
/***********************************************************************
2
filename: CEGUISingleton.h
3
created: 22/2/2004
4
author: Paul D Turner
5
6
purpose: Singleton Base Class
7
*************************************************************************/
8
/***************************************************************************
9
* Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10
*
11
* Permission is hereby granted, free of charge, to any person obtaining
12
* a copy of this software and associated documentation files (the
13
* "Software"), to deal in the Software without restriction, including
14
* without limitation the rights to use, copy, modify, merge, publish,
15
* distribute, sublicense, and/or sell copies of the Software, and to
16
* permit persons to whom the Software is furnished to do so, subject to
17
* the following conditions:
18
*
19
* The above copyright notice and this permission notice shall be
20
* included in all copies or substantial portions of the Software.
21
*
22
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28
* OTHER DEALINGS IN THE SOFTWARE.
29
***************************************************************************/
30
/*************************************************************************
31
32
The code in this file is taken from article 1.3 in the the book:
33
Game Programming Gems from Charles River Media
34
35
*************************************************************************/
36
#ifndef _CEGUISingleton_h_
37
#define _CEGUISingleton_h_
38
39
#include "CEGUIBase.h"
40
#include <cassert>
41
42
// Start of CEGUI namespace section
43
namespace
CEGUI
44
{
45
/* Copyright (C) Scott Bilas, 2000.
46
* All rights reserved worldwide.
47
*
48
* This software is provided "as is" without express or implied
49
* warranties. You may freely copy and compile this source into
50
* applications you distribute provided that the copyright text
51
* below is included in the resulting source code, for example:
52
* "Portions Copyright (C) Scott Bilas, 2000"
53
*/
54
55
56
template
<
typename
T>
class
CEGUIEXPORT
Singleton
57
{
58
protected
:
59
// TODO: Come up with something better than this!
60
// TODO:
61
// TODO: This super-nasty piece of nastiness was put in for continued
62
// TODO: compatability with MSVC++ and MinGW - the latter apparently
63
// TODO: needs this.
64
static
65
#ifdef __MINGW32__
66
CEGUIEXPORT
67
#endif
68
T* ms_Singleton;
69
70
public
:
71
Singleton
(
void
)
72
{
73
assert( !ms_Singleton );
74
ms_Singleton =
static_cast<
T*
>
(
this
);
75
}
76
~
Singleton
(
void
)
77
{ assert( ms_Singleton ); ms_Singleton = 0; }
78
static
T& getSingleton(
void
)
79
{ assert( ms_Singleton );
return
( *ms_Singleton ); }
80
static
T* getSingletonPtr(
void
)
81
{
return
( ms_Singleton ); }
82
83
private
:
84
Singleton
& operator=(
const
Singleton
&) {
return
this
; }
85
Singleton
(
const
Singleton
&) {}
86
};
87
88
}
// End of CEGUI namespace section
89
90
91
92
#endif // end of guard _CEGUISingleton_h_
cegui
include
CEGUISingleton.h
Generated by
1.8.3.1