TDME2 1.9.121
Reference.cpp
Go to the documentation of this file.
2
3#include <tdme/tdme.h>
5
7
9
10Reference::Reference() : referenceCounter(0) {
11}
12
14}
15
17 AtomicOperations::increment(referenceCounter);
18}
19
21 if (AtomicOperations::decrement(referenceCounter) == 0) {
22 onDelete();
23 delete this;
24 }
25}
26
28}
Reference counter implementation to be used with inheritance.
Definition: Reference.h:10
virtual ~Reference()
destructor
Definition: Reference.cpp:13
void releaseReference()
releases a reference, thus decrementing the counter and delete it if reference counter is zero
Definition: Reference.cpp:20
unsigned int referenceCounter
Definition: Reference.h:38
virtual void onDelete()
Callback method to be overridden, will be called if object will be deleted.
Definition: Reference.cpp:27
void acquireReference()
acquires a reference, incrementing the counter
Definition: Reference.cpp:16