Skylicht Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
Irrlicht
Include
IReferenceCounted.h
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
#ifdef _IRR_COMPILE_WITH_LEAK_HUNTER_
11
#include "leakHunter.h"
12
#endif
13
14
namespace
irr
15
{
16
18
45
class
IReferenceCounted
46
{
47
public
:
48
50
IReferenceCounted
()
51
: DebugName(0), ReferenceCounter(1)
52
{
53
#ifdef _IRR_COMPILE_WITH_LEAK_HUNTER_
54
LeakHunter::addObject(
this
);
55
#endif
56
}
57
59
virtual
~IReferenceCounted
()
60
{
61
#ifdef _IRR_COMPILE_WITH_LEAK_HUNTER_
62
LeakHunter::removeObject(
this
);
63
#endif
64
}
65
67
96
void
grab
()
const
{ ++ReferenceCounter; }
97
99
126
bool
drop
()
const
127
{
128
// someone is doing bad reference counting.
129
_IRR_DEBUG_BREAK_IF(ReferenceCounter <= 0)
130
131
--ReferenceCounter;
132
if
(!ReferenceCounter)
133
{
134
delete
this
;
135
return
true
;
136
}
137
138
return
false
;
139
}
140
142
143
s32
getReferenceCount
()
const
144
{
145
return
ReferenceCounter;
146
}
147
149
152
const
c8
*
getDebugName
()
const
153
{
154
return
DebugName;
155
}
156
157
protected
:
158
160
163
void
setDebugName
(
const
c8
* newName)
164
{
165
DebugName = newName;
166
}
167
168
private
:
169
171
const
c8
* DebugName;
172
174
mutable
s32
ReferenceCounter;
175
};
176
177
}
// end namespace irr
178
179
#endif
180
irr::IReferenceCounted::getDebugName
const c8 * getDebugName() const
Returns the debug name of the object.
Definition
IReferenceCounted.h:152
irr::IReferenceCounted::drop
bool drop() const
Drops the object. Decrements the reference counter by one.
Definition
IReferenceCounted.h:126
irr::IReferenceCounted::grab
void grab() const
Grabs the object. Increments the reference counter by one.
Definition
IReferenceCounted.h:96
irr::IReferenceCounted::setDebugName
void setDebugName(const c8 *newName)
Sets the debug name of the object.
Definition
IReferenceCounted.h:163
irr::IReferenceCounted::~IReferenceCounted
virtual ~IReferenceCounted()
Destructor.
Definition
IReferenceCounted.h:59
irr::IReferenceCounted::IReferenceCounted
IReferenceCounted()
Constructor.
Definition
IReferenceCounted.h:50
irr::IReferenceCounted::getReferenceCount
s32 getReferenceCount() const
Get the reference count.
Definition
IReferenceCounted.h:143
irr
Everything in the Irrlicht Engine can be found in this namespace.
Definition
Skylicht.h:33
irr::c8
char c8
8 bit character variable.
Definition
irrTypes.h:31
irr::s32
signed int s32
32 bit signed variable.
Definition
irrTypes.h:66
Generated by
1.17.0