forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodeReferenceCount.h
More file actions
93 lines (77 loc) · 2.49 KB
/
nodeReferenceCount.h
File metadata and controls
93 lines (77 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file nodeReferenceCount.h
* @author drose
* @date 2006-05-01
*/
#ifndef NODEREFERENCECOUNT_H
#define NODEREFERENCECOUNT_H
#include "pandabase.h"
#include "referenceCount.h"
/**
* This class specializes ReferenceCount to add an additional counter, called
* node_ref_count, for the purposes of counting the number of times the object
* is referenced by a "node", whatever that may mean in context.
*
* The new methods node_ref() and node_unref() automatically increment and
* decrement the primary reference count as well. There also exists a
* NodePointerTo<> class to maintain the node_ref counters automatically.
*
* See also CachedTypedWritableReferenceCount, which is similar in principle,
* as well as NodeCachedReferenceCount, which combines both of these.
*/
class EXPCL_PANDA_EXPRESS NodeReferenceCount : public ReferenceCount {
protected:
INLINE NodeReferenceCount();
INLINE NodeReferenceCount(const NodeReferenceCount ©);
INLINE void operator = (const NodeReferenceCount ©);
INLINE ~NodeReferenceCount();
PUBLISHED:
INLINE int get_node_ref_count() const;
INLINE void node_ref() const;
INLINE bool node_unref() const;
INLINE bool test_ref_count_integrity() const;
INLINE void node_unref_only() const;
protected:
bool do_test_ref_count_integrity() const;
private:
mutable AtomicAdjust::Integer _node_ref_count;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
ReferenceCount::init_type();
register_type(_type_handle, "NodeReferenceCount",
ReferenceCount::get_class_type());
}
private:
static TypeHandle _type_handle;
};
template<class RefCountType>
INLINE void node_unref_delete(RefCountType *ptr);
/**
* This works like RefCountObj, but it inherits from NodeReferenceCount
* instead of ReferenceCount.
*/
template<class Base>
class NodeRefCountObj : public NodeReferenceCount, public Base {
public:
INLINE NodeRefCountObj();
INLINE NodeRefCountObj(const Base ©);
ALLOC_DELETED_CHAIN(NodeRefCountObj<Base>);
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type();
private:
static TypeHandle _type_handle;
};
#include "nodeReferenceCount.I"
#endif