Panda3D
Public Member Functions | Static Public Member Functions | Protected Member Functions

NodeReferenceCount Class Reference

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. More...

#include "nodeReferenceCount.h"

Inheritance diagram for NodeReferenceCount:
ReferenceCount MemoryBase NodeRefCountObj< Base > ReferenceCountedVector< Element >

List of all members.

Public Member Functions

int get_node_ref_count () const
 Returns the current reference count.
void node_ref () const
 Explicitly increments the node reference count and the normal reference count simultaneously.
bool node_unref () const
 Explicitly decrements 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.

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()

Protected Member Functions

 NodeReferenceCount ()
 The ReferenceCount constructor is protected because you almost never want to create just a ReferenceCount object by itself, and it's probably a mistake if you try.
 NodeReferenceCount (const NodeReferenceCount &copy)
 The copies of reference-counted objects do not themselves inherit the reference count!
 ~NodeReferenceCount ()
 The ReferenceCount destructor is protected to discourage users from accidentally trying to delete a ReferenceCount pointer directly.
bool do_test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus.
void node_unref_only () const
 Decrements the node reference count without affecting the normal reference count.
void operator= (const NodeReferenceCount &copy)
 The copies of reference-counted objects do not themselves inherit the reference count!

Detailed Description

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.

Definition at line 41 of file nodeReferenceCount.h.


Constructor & Destructor Documentation

NodeReferenceCount::NodeReferenceCount ( ) [inline, protected]

The ReferenceCount constructor is protected because you almost never want to create just a ReferenceCount object by itself, and it's probably a mistake if you try.

ReferenceCount doesn't store any useful information in its own right; its only purpose is to add reference-counting to some other class via inheritance.

Definition at line 33 of file nodeReferenceCount.I.

NodeReferenceCount::NodeReferenceCount ( const NodeReferenceCount copy) [inline, protected]

The copies of reference-counted objects do not themselves inherit the reference count!

This copy constructor is protected because you almost never want to create just a ReferenceCount object by itself, and it's probably a mistake if you try.

Definition at line 48 of file nodeReferenceCount.I.

NodeReferenceCount::~NodeReferenceCount ( ) [inline, protected]

The ReferenceCount destructor is protected to discourage users from accidentally trying to delete a ReferenceCount pointer directly.

This is almost always a bad idea, since the destructor is not virtual, and you've almost certainly got some pointer to something that inherits from ReferenceCount, not just a plain old ReferenceCount object.

Definition at line 93 of file nodeReferenceCount.I.


Member Function Documentation

bool NodeReferenceCount::do_test_ref_count_integrity ( ) const [protected]

Does some easy checks to make sure that the reference count isn't completely bogus.

Reimplemented from ReferenceCount.

Definition at line 26 of file nodeReferenceCount.cxx.

Referenced by test_ref_count_integrity().

int NodeReferenceCount::get_node_ref_count ( ) const [inline]

Returns the current reference count.

Definition at line 136 of file nodeReferenceCount.I.

References test_ref_count_integrity().

void NodeReferenceCount::node_ref ( ) const [inline]

Explicitly increments the node reference count and the normal reference count simultaneously.

Definition at line 150 of file nodeReferenceCount.I.

References ReferenceCount::ref(), and test_ref_count_integrity().

bool NodeReferenceCount::node_unref ( ) const [inline]

Explicitly decrements the node reference count and the normal reference count simultaneously.

The return value is true if the new reference count is nonzero, false if it is zero.

Definition at line 169 of file nodeReferenceCount.I.

References node_unref_only(), and ReferenceCount::unref().

void NodeReferenceCount::node_unref_only ( ) const [inline, protected]

Decrements the node reference count without affecting the normal reference count.

Intended to be called by derived classes only, presumably to reimplement node_unref().

Definition at line 198 of file nodeReferenceCount.I.

References test_ref_count_integrity().

Referenced by node_unref().

void NodeReferenceCount::operator= ( const NodeReferenceCount copy) [inline, protected]

The copies of reference-counted objects do not themselves inherit the reference count!

This copy assignment operator is protected because you almost never want to copy just a ReferenceCount object by itself, and it's probably a mistake if you try. Instead, this should only be called from a derived class that implements this operator and then calls up the inheritance chain.

Definition at line 66 of file nodeReferenceCount.I.

bool NodeReferenceCount::test_ref_count_integrity ( ) const [inline]

Does some easy checks to make sure that the reference count isn't completely bogus.

Reimplemented from ReferenceCount.

Definition at line 181 of file nodeReferenceCount.I.

References do_test_ref_count_integrity().

Referenced by get_node_ref_count(), node_ref(), and node_unref_only().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations