|
|
|
A base class for all things that want to be reference-counted.
More...
#include "referenceCount.h"
List of all members.
Detailed Description
A base class for all things that want to be reference-counted.
ReferenceCount works in conjunction with PointerTo to automatically delete objects when the last pointer to them goes away.
Definition at line 41 of file referenceCount.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 35 of file referenceCount.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 54 of file referenceCount.I.
Member Function Documentation
Returns the current reference count.
Definition at line 155 of file referenceCount.I.
References test_ref_count_integrity().
Referenced by RenderState::clear_cache(), TransformState::clear_cache(), RenderEffect::finalize(), InternalName::finalize(), RenderEffects::finalize(), RenderAttrib::finalize(), RenderState::finalize(), Texture::finalize(), RenderAttrib::garbage_collect(), RenderState::garbage_collect(), TransformState::garbage_collect(), RenderState::get_num_unused_states(), TransformState::get_num_unused_states(), RenderState::list_cycles(), TransformState::list_cycles(), GeomVertexFormat::remove_column(), RenderState::unref(), TransformState::unref(), RenderState::~RenderState(), and TransformState::~TransformState().
This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack.
This allows the object to be passed to functions that will increment and decrement the object's reference count temporarily, and it will prevent the object from being deleted (inappropriately), when the reference count returns to zero. It actually achieves this by setting a large positive value in the reference count field.
Definition at line 276 of file referenceCount.I.
Referenced by BoundingSphere::around_finite(), PGTop::cull_callback(), Texture::do_clear(), BoundingSphere::extend_by_finite(), BoundingSphere::extend_by_hexahedron(), AsyncTaskManager::find_task(), AsyncTaskManager::find_tasks(), and AsyncTaskManager::find_tasks_matching().
| void ReferenceCount::operator= |
( |
const ReferenceCount & |
| ) |
[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 76 of file referenceCount.I.
Explicitly increments the reference count.
User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.
This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.
Definition at line 179 of file referenceCount.I.
References test_ref_count_integrity().
Referenced by CachedTypedWritableReferenceCount::cache_ref(), TypedWritable::decode_raw_from_bam_stream(), Texture::make_this_from_bam(), NodeReferenceCount::node_ref(), NodeCachedReferenceCount::node_ref(), BamCacheRecord::set_data(), CullableObject::set_draw_callback(), and ModelRoot::set_reference().
Does some easy checks to make sure that the reference count isn't completely bogus.
Returns true if ok, false otherwise.
Reimplemented in NodeCachedReferenceCount, NodeReferenceCount, and CachedTypedWritableReferenceCount.
Definition at line 236 of file referenceCount.I.
References do_test_ref_count_integrity().
Referenced by EggGroupNode::add_child(), InternalName::find_ancestor(), InternalName::get_ancestor(), get_ref_count(), InternalName::get_top(), ref(), MouseWatcher::throw_event_pattern(), unref(), and EggNode::update_under().
Explicitly decrements the reference count.
Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic.) However, see the helper function unref_delete().
User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.
This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.
The return value is true if the new reference count is nonzero, false if it is zero.
Reimplemented in TransformState, RenderState, RenderEffects, RenderAttrib, GeomVertexArrayFormat, GeomVertexFormat, and InternalName.
Definition at line 214 of file referenceCount.I.
References test_ref_count_integrity().
Referenced by CachedTypedWritableReferenceCount::cache_unref(), TypedWritable::decode_raw_from_bam_stream(), RenderEffect::finalize(), Texture::finalize(), NodeReferenceCount::node_unref(), NodeCachedReferenceCount::node_unref(), RocketRenderInterface::ReleaseTexture(), InternalName::unref(), GeomVertexFormat::unref(), GeomVertexArrayFormat::unref(), RenderAttrib::unref(), RenderEffects::unref(), RenderState::unref(), and TransformState::unref().
The documentation for this class was generated from the following files:
| | |