32 INLINE NodeReferenceCount::
33 NodeReferenceCount() {
47 INLINE NodeReferenceCount::
65 INLINE
void NodeReferenceCount::
67 nassertv(
this != NULL);
76 nassertv(_node_ref_count != -100);
78 ReferenceCount::operator = (copy);
92 INLINE NodeReferenceCount::
93 ~NodeReferenceCount() {
94 nassertv(
this != NULL);
103 nassertv(_node_ref_count != -100);
108 nassertv(_node_ref_count >= 0);
120 nassertv(_node_ref_count == 0);
126 _node_ref_count = -100;
183 return do_test_ref_count_integrity();
197 INLINE
void NodeReferenceCount::
198 node_unref_only()
const {
206 nassertv(_node_ref_count > 0);
221 template<
class RefCountType>
223 node_unref_delete(RefCountType *ptr) {
224 if (!ptr->node_unref()) {
260 #if defined(HAVE_RTTI) && !defined(__EDG__)
262 string base_name =
typeid(Base).name();
264 string base_name =
"unknown";
267 TypeHandle base_type = register_dynamic_type(base_name);
269 ReferenceCount::init_type();
271 register_dynamic_type(
"NodeRefCountObj<" + base_name +
">",
272 base_type, ReferenceCount::get_class_type());
int get_node_ref_count() const
Returns the current reference count.
static void inc(Integer &var)
Atomically increments the indicated variable.
static bool dec(Integer &var)
Atomically decrements the indicated variable and returns true if the new value is nonzero...
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.
This works like RefCountObj, but it inherits from NodeReferenceCount instead of ReferenceCount.
virtual bool unref() const
Explicitly decrements the reference count.
static Integer get(const Integer &var)
Atomically retrieves the snapshot value of the indicated variable.
void node_ref() const
Explicitly increments the node reference count and the normal reference count simultaneously.
bool test_ref_count_integrity() const
Does some easy checks to make sure that the reference count isn't completely bogus.
A base class for all things that want to be reference-counted.
void ref() const
Explicitly increments the reference count.
bool node_unref() const
Explicitly decrements the node reference count and the normal reference count simultaneously.
TypeHandle is the identifier used to differentiate C++ class types.