Irrlicht 3D Engine
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
IReferenceCounted.h
Go to the documentation of this file.
1
// Copyright (C) 2002-2012 Nikolaus Gebhardt
2
// This file is part of the "Irrlicht Engine".
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5
#ifndef __I_IREFERENCE_COUNTED_H_INCLUDED__
6
#define __I_IREFERENCE_COUNTED_H_INCLUDED__
7
8
#include "
irrTypes.h
"
9
10
namespace
irr
11
{
12
14
41
class
IReferenceCounted
42
{
43
public
:
44
46
IReferenceCounted
()
47
: DebugName(0), ReferenceCounter(1)
48
{
49
}
50
52
virtual
~IReferenceCounted
()
53
{
54
}
55
57
86
void
grab
()
const
{ ++ReferenceCounter; }
87
89
116
bool
drop
()
const
117
{
118
// someone is doing bad reference counting.
119
_IRR_DEBUG_BREAK_IF
(ReferenceCounter <= 0)
120
121
--ReferenceCounter;
122
if
(!ReferenceCounter)
123
{
124
delete
this
;
125
return
true
;
126
}
127
128
return
false
;
129
}
130
132
133
s32
getReferenceCount
()
const
134
{
135
return
ReferenceCounter;
136
}
137
139
142
const
c8
*
getDebugName
()
const
143
{
144
return
DebugName;
145
}
146
147
protected
:
148
150
153
void
setDebugName
(
const
c8
* newName)
154
{
155
DebugName = newName;
156
}
157
158
private
:
159
161
const
c8
* DebugName;
162
164
mutable
s32
ReferenceCounter;
165
};
166
167
}
// end namespace irr
168
169
#endif
170
Irrlicht Engine
Documentation © 2003-2012 by Nikolaus Gebhardt. Generated on Thu Apr 2 2020 05:59:48 for Irrlicht 3D Engine by
Doxygen
1.8.1.2