Panda3D
Public Member Functions | Static Public Member Functions | Protected Member Functions
CachedTypedWritableReferenceCount Class Reference

This is a special extension to ReferenceCount that includes dual reference counts: the standard reference count number, which includes all references to the object, and a separate number (the cache reference count) that counts the number of references to the object just within its cache alone. More...

#include "cachedTypedWritableReferenceCount.h"

Inheritance diagram for CachedTypedWritableReferenceCount:
TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject MemoryBase MemoryBase CopyOnWriteObject NodeCachedReferenceCount AnimPreloadTable CollisionSolid CopyOnWriteObj< Base > CopyOnWriteObj1< Base, Param1 > Geom GeomPrimitive GeomVertexArrayData GeomVertexData TransformBlendTable RenderState TransformState

List of all members.

Public Member Functions

void cache_ref () const
 Explicitly increments the cache reference count and the normal reference count simultaneously.
bool cache_unref () const
 Explicitly decrements the cache reference count and the normal reference count simultaneously.
int get_cache_ref_count () const
 Returns the current reference count.
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

 CachedTypedWritableReferenceCount ()
 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.
 CachedTypedWritableReferenceCount (const CachedTypedWritableReferenceCount &copy)
 The copies of reference-counted objects do not themselves inherit the reference count!
 ~CachedTypedWritableReferenceCount ()
 The ReferenceCount destructor is protected to discourage users from accidentally trying to delete a ReferenceCount pointer directly.
void cache_unref_only () const
 Decrements the cache reference count without affecting the normal reference count.
bool do_test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus.
void operator= (const CachedTypedWritableReferenceCount &copy)
 The copies of reference-counted objects do not themselves inherit the reference count!

Detailed Description

This is a special extension to ReferenceCount that includes dual reference counts: the standard reference count number, which includes all references to the object, and a separate number (the cache reference count) that counts the number of references to the object just within its cache alone.

When get_ref_count() == get_cache_ref_count(), the object is not referenced outside the cache.

The cache refs must be explicitly maintained; there is no PointerTo<> class to maintain the cache reference counts automatically. The cache reference count is automatically included in the overall reference count: calling cache_ref() and cache_unref() automatically calls ref() and unref().

Definition at line 40 of file cachedTypedWritableReferenceCount.h.


Constructor & Destructor Documentation

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 30 of file cachedTypedWritableReferenceCount.I.

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 45 of file cachedTypedWritableReferenceCount.I.

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 90 of file cachedTypedWritableReferenceCount.I.


Member Function Documentation

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

Reimplemented in TransformState, and RenderState.

Definition at line 147 of file cachedTypedWritableReferenceCount.I.

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

Referenced by CopyOnWritePointer::get_write_pointer().

Explicitly decrements the cache 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.

Reimplemented in TransformState, and RenderState.

Definition at line 166 of file cachedTypedWritableReferenceCount.I.

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

void CachedTypedWritableReferenceCount::cache_unref_only ( ) const [inline, protected]

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

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

Definition at line 204 of file cachedTypedWritableReferenceCount.I.

References test_ref_count_integrity().

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

Reimplemented from ReferenceCount.

Reimplemented in NodeCachedReferenceCount.

Definition at line 26 of file cachedTypedWritableReferenceCount.cxx.

Referenced by test_ref_count_integrity().

void CachedTypedWritableReferenceCount::operator= ( const CachedTypedWritableReferenceCount 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 63 of file cachedTypedWritableReferenceCount.I.

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

Reimplemented from ReferenceCount.

Reimplemented in NodeCachedReferenceCount.

Definition at line 187 of file cachedTypedWritableReferenceCount.I.

References do_test_ref_count_integrity().

Referenced by cache_ref(), cache_unref(), cache_unref_only(), get_cache_ref_count(), and CopyOnWritePointer::test_ref_count_integrity().


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