21 _void_ptr = (To *)ptr;
23 _weak_ref = ptr->weak_ref();
24 #ifdef DO_MEMORY_USAGE 41 _weak_ref = ptr->weak_ref();
51 _void_ptr = copy._void_ptr;
57 if (weak_ref !=
nullptr) {
58 _weak_ref = copy._weak_ref;
69 this->_void_ptr = from._void_ptr;
70 this->_weak_ref = from._weak_ref;
71 from._void_ptr =
nullptr;
72 from._weak_ref =
nullptr;
84 To *ptr = (Y *)r._void_ptr;
86 this->_void_ptr = ptr;
89 if (weak_ref !=
nullptr) {
104 To *ptr = (Y *)r._void_ptr;
106 this->_void_ptr = ptr;
107 this->_weak_ref = r._weak_ref;
108 r._void_ptr =
nullptr;
109 r._weak_ref =
nullptr;
119 if (old_ref !=
nullptr && !old_ref->
unref()) {
131 if (ptr != (To *)_void_ptr) {
134 _void_ptr = (
void *)ptr;
135 if (ptr !=
nullptr) {
136 _weak_ref = ptr->weak_ref();
137 #ifdef DO_MEMORY_USAGE 145 if (old_ref !=
nullptr && !old_ref->
unref()) {
168 void *new_ptr = copy._void_ptr;
169 if (new_ptr != _void_ptr) {
177 if (weak_ref !=
nullptr) {
179 _weak_ref = weak_ref;
185 if (old_ref !=
nullptr && !old_ref->
unref()) {
198 if (from._void_ptr != this->_void_ptr) {
201 this->_void_ptr = from._void_ptr;
202 this->_weak_ref = from._weak_ref;
203 from._void_ptr =
nullptr;
204 from._weak_ref =
nullptr;
207 if (old_ref !=
nullptr && !old_ref->
unref()) {
222 To *new_ptr = (Y *)copy._void_ptr;
224 if (new_ptr != (To *)_void_ptr) {
230 if (new_ref !=
nullptr) {
235 if (old_ref !=
nullptr && !old_ref->
unref()) {
249 if (from._void_ptr != this->_void_ptr) {
254 To *new_ptr = (Y *)from._void_ptr;
256 this->_void_ptr = new_ptr;
257 this->_weak_ref = from._weak_ref;
258 from._void_ptr =
nullptr;
259 from._weak_ref =
nullptr;
262 if (old_ref !=
nullptr && !old_ref->
unref()) {
275 #ifdef DO_MEMORY_USAGE 278 if (type == TypeHandle::none()) {
280 type = get_type_handle(To);
282 if (type != TypeHandle::none()) {
286 #endif // DO_MEMORY_USAGE 300 if (weak_ref !=
nullptr) {
301 weak_ref->_lock.lock();
307 if (plain_ptr !=
nullptr && plain_ptr->ref_if_nonzero()) {
310 locked._void_ptr = plain_ptr;
313 weak_ref->_lock.unlock();
324 return (To *)_void_ptr == other;
333 return (To *)_void_ptr != other;
342 return (To *)_void_ptr > other;
351 return (To *)_void_ptr <= other;
360 return (To *)_void_ptr >= other;
368 return (To *)_void_ptr == other;
377 return (To *)_void_ptr != other;
386 return (To *)_void_ptr > other;
395 return (To *)_void_ptr <= other;
404 return (To *)_void_ptr >= other;
413 return _void_ptr ==
nullptr;
422 return _void_ptr !=
nullptr;
431 return _void_ptr !=
nullptr;
440 return _void_ptr ==
nullptr;
462 return (To *)_void_ptr == (To *)other._void_ptr;
471 return (To *)_void_ptr != (To *)other._void_ptr;
481 return (To *)_void_ptr > (To *)other._void_ptr;
491 return (To *)_void_ptr <= (To *)other._void_ptr;
501 return (To *)_void_ptr >= (To *)other._void_ptr;
555 return (To *)_void_ptr < other;
574 return (To *)_void_ptr < (To *)other._void_ptr;
598 return _weak_ref < other._weak_ref;
613 return (other._void_ptr !=
nullptr) &&
614 (_void_ptr ==
nullptr || _weak_ref < ((
const Y *)other._void_ptr)->get_weak_list());
629 if (old_ref !=
nullptr && !old_ref->
unref()) {
645 if (_void_ptr !=
nullptr) {
660 if (weak_ref !=
nullptr) {
661 weak_ref->_lock.lock();
663 out <<
":" << ((To *)_void_ptr)->get_ref_count();
667 weak_ref->_lock.unlock();
void refresh() const
Informs the WeakPointerTo object that its pointer is no longer deleted.
bool owner_before(const WeakPointerToBase< Y > &other) const noexcept
Defines an ordering that is guaranteed to remain consistent even after the weak pointers have expired...
void clear()
A convenient way to set the PointerTo object to NULL.
void ref() const
Increases the number of weak references.
This is the base class for PointerTo and ConstPointerTo.
bool was_deleted() const
Returns true if the object represented has been deleted, ie.
This is an object shared by all the weak pointers that point to the same ReferenceCount object.
static void update_type(ReferenceCount *ptr, TypeHandle type)
Associates the indicated type with the given pointer.
static bool get_track_memory_usage()
Returns true if the user has Configured the variable 'track-memory-usage' to true,...
void output(std::ostream &out) const
A handy function to output PointerTo's as a hex pointer followed by a reference count.
TypeHandle is the identifier used to differentiate C++ class types.
This is the base class for PointerTo and ConstPointerTo.
bool unref() const
Decreases the number of weak references.