Oxygine
1
2g game engine
oxygine
src
core
ref_counter.h
1
#pragma once
2
#include "oxygine-include.h"
3
#include "intrusive_ptr.h"
4
5
namespace
oxygine
6
{
8
class
ref_counter
9
{
10
public
:
11
int
_ref_counter;
12
13
ref_counter
(): _ref_counter(0) {}
14
virtual
~
ref_counter
() {}
15
16
void
addRef()
17
{
18
++_ref_counter;
19
}
20
21
void
releaseRef()
22
{
23
if
(0 == --_ref_counter)
24
delete
this
;
25
}
26
27
private
:
28
ref_counter
(
const
ref_counter
&);
29
const
ref_counter
& operator=(
const
ref_counter
&);
30
};
31
32
33
inline
void
intrusive_ptr_add_ref(
ref_counter
* p)
34
{
35
p->addRef();
36
}
37
38
inline
void
intrusive_ptr_release(ref_counter* p)
39
{
40
p->releaseRef();
41
}
42
43
44
class
AutoRefHolder
45
{
46
public
:
47
AutoRefHolder
(
ref_counter
* rc) : _rc(rc)
48
{
49
_rc->addRef();
50
}
51
52
~
AutoRefHolder
()
53
{
54
_rc->releaseRef();
55
}
56
57
ref_counter
* _rc;
58
59
private
:
60
AutoRefHolder
(
const
AutoRefHolder
&);
61
AutoRefHolder
& operator=(
const
AutoRefHolder
&);
62
};
63
}
oxygine::ref_counter
Definition:
ref_counter.h:8
oxygine
–oxgl-end–!
Definition:
Actor.h:14
oxygine::AutoRefHolder
Definition:
ref_counter.h:44
Generated on Tue Feb 13 2018 05:01:17 for Oxygine by
1.8.14