Newton Dynamics
4.00
dRefCounter.h
1
/* Copyright (c) <2003-2019> <Newton Game Dynamics>
2
*
3
* This software is provided 'as-is', without any express or implied
4
* warranty. In no event will the authors be held liable for any damages
5
* arising from the use of this software.
6
*
7
* Permission is granted to anyone to use this software for any purpose,
8
* including commercial applications, and to alter it and redistribute it
9
* freely
10
*/
11
12
#ifndef __DREF_COUNTER_H__
13
#define __DREF_COUNTER_H__
14
15
#include "dCoreStdafx.h"
16
17
template
<
class
T>
18
class
dRefCounter
19
{
20
public
:
21
dRefCounter
();
22
dInt32 GetRef()
const
;
23
24
T* AddRef();
25
dInt32 Release();
26
27
protected
:
28
virtual
~
dRefCounter
(
void
);
29
30
private
:
31
dInt32 m_refCount;
32
};
33
34
template
<
class
T>
35
dRefCounter<T>::dRefCounter
(
void
)
36
:m_refCount(1)
37
{
38
}
39
40
template
<
class
T>
41
inline
dRefCounter<T>::~dRefCounter
(
void
)
42
{
43
}
44
45
template
<
class
T>
46
inline
T*
dRefCounter<T>::AddRef
()
47
{
48
m_refCount++;
49
return
(T*)
this
;
50
}
51
52
template
<
class
T>
53
inline
dInt32
dRefCounter<T>::Release
()
54
{
55
m_refCount--;
56
dAssert(m_refCount >= 0);
57
if
(!m_refCount)
58
{
59
delete
this
;
60
return
0;
61
}
62
return
m_refCount;
63
}
64
65
template
<
class
T>
66
inline
dInt32
dRefCounter<T>::GetRef
()
const
67
{
68
return
m_refCount;
69
}
70
71
#endif
dRefCounter
Definition:
dRefCounter.h:19
Development
newton-dynamics
newton-4.00
sdk
dCore
dRefCounter.h
Generated by
1.8.20