14#ifndef REFERENCECOUNT_H
15#define REFERENCECOUNT_H
38class EXPCL_PANDA_EXPRESS ReferenceCount :
public MemoryBase {
40 INLINE ReferenceCount();
41 INLINE ReferenceCount(
const ReferenceCount &);
42 INLINE
void operator = (
const ReferenceCount &);
45 virtual INLINE ~ReferenceCount();
49 INLINE
void ref()
const;
50 virtual INLINE
bool unref()
const;
70 bool do_test_ref_count_integrity()
const;
71 bool do_test_ref_count_nonzero()
const;
74 void create_weak_list();
82 local_ref_count = 10000000,
89 deleted_ref_count = -100,
92 mutable AtomicAdjust::Integer _ref_count;
93 AtomicAdjust::Pointer _weak_list;
99 static void init_type() {
104 static TypeHandle _type_handle;
107template<
class RefCountType>
121class RefCountProxy :
public ReferenceCount {
123 INLINE RefCountProxy();
124 INLINE RefCountProxy(
const Base ©);
126 INLINE
operator Base &();
127 INLINE
operator const Base &()
const;
132 static void init_type();
147class RefCountObj :
public ReferenceCount,
public Base {
149 INLINE RefCountObj();
150 INLINE RefCountObj(
const Base ©);
151 ALLOC_DELETED_CHAIN(RefCountObj<Base>);
156 static void init_type();
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class is intended to be the base class of all objects in Panda that might be allocated and delet...
void ref() const
Explicitly increments the reference count.
WeakReferenceList * get_weak_list() const
Returns the WeakReferenceList associated with this ReferenceCount object.
bool test_ref_count_integrity() const
Does some easy checks to make sure that the reference count isn't completely bogus.
void local_object()
This function should be called, once, immediately after creating a new instance of some ReferenceCoun...
bool ref_if_nonzero() const
Atomically increases the reference count of this object if it is not zero.
bool unref_if_one() const
Atomically decreases the reference count of this object if it is one.
get_ref_count
Returns the current reference count.
virtual bool unref() const
Explicitly decrements the reference count.
WeakReferenceList * weak_ref()
Adds the indicated PointerToVoid as a weak reference to this object.
bool has_weak_list() const
Returns true if this particular ReferenceCount object has a WeakReferenceList created,...
bool test_ref_count_nonzero() const
Does some easy checks to make sure that the reference count isn't zero, or completely bogus.
void weak_unref()
Removes the indicated PointerToVoid as a weak reference to this object.
TypeHandle is the identifier used to differentiate C++ class types.
This is an object shared by all the weak pointers that point to the same ReferenceCount object.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void unref_delete(RefCountType *ptr)
This global helper function will unref the given ReferenceCount object, and if the reference count re...
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.