Loading...
Searching...
No Matches
TfRefBase Class Reference

Enable a concrete base class for use with TfRefPtr. More...

#include <refBase.h>

+ Inheritance diagram for TfRefBase:

Public Types

typedef void(* UniqueChangedFuncPtr) (TfRefBase const *, bool)
 

Public Member Functions

 TfRefBase (TfRefBase const &)
 
TfRefBaseoperator= (TfRefBase const &)
 
size_t GetCurrentCount () const
 Return the current reference count of this object.
 
bool IsUnique () const
 Return true if only one TfRefPtr points to this object.
 
void SetShouldInvokeUniqueChangedListener (bool shouldCall)
 

Static Public Member Functions

static TF_API void SetUniqueChangedListener (UniqueChangedListener listener)
 

Friends

template<typename T >
class TfRefPtr
 
template<typename T >
TfRefPtr< T > TfCreateRefPtrFromProtectedWeakPtr (TfWeakPtr< T > const &)
 Thread-safe creation of a Tf ref pointer from a Tf weak pointer.
 

Detailed Description

Enable a concrete base class for use with TfRefPtr.

You should be familiar with the TfRefPtr type before reading further.

A class (but not an interface class) is enabled for reference counting via the TfRefPtr type by publicly deriving from TfRefBase.

For example,

class Simple : public TfRefBase {
public:
return TfCreateRefPtr(new Simple);
}
private:
Simple();
};
Enable a concrete base class for use with TfRefPtr.
Definition: refBase.h:73
Reference-counted smart pointer utility class.
Definition: refPtr.h:601
Reference counting.

The class Simple can now only be manipulated in terms of a TfRefPtr<Simple>.

To disable the cost of the "unique changed" system, derive from TfSimpleRefBase instead.

Definition at line 73 of file refBase.h.

Member Typedef Documentation

◆ UniqueChangedFuncPtr

typedef void(* UniqueChangedFuncPtr) (TfRefBase const *, bool)

Definition at line 76 of file refBase.h.

Constructor & Destructor Documentation

◆ TfRefBase() [1/2]

TfRefBase ( )
inline

Definition at line 85 of file refBase.h.

◆ TfRefBase() [2/2]

TfRefBase ( TfRefBase const &  )
inline

Definition at line 89 of file refBase.h.

Member Function Documentation

◆ GetCurrentCount()

size_t GetCurrentCount ( ) const
inline

Return the current reference count of this object.

Definition at line 98 of file refBase.h.

◆ IsUnique()

bool IsUnique ( ) const
inline

Return true if only one TfRefPtr points to this object.

Definition at line 105 of file refBase.h.

◆ operator=()

TfRefBase & operator= ( TfRefBase const &  )
inline

Definition at line 93 of file refBase.h.

◆ SetShouldInvokeUniqueChangedListener()

void SetShouldInvokeUniqueChangedListener ( bool  shouldCall)
inline

Definition at line 109 of file refBase.h.

Friends And Related Function Documentation

◆ TfCreateRefPtrFromProtectedWeakPtr

TfRefPtr< T > TfCreateRefPtrFromProtectedWeakPtr ( TfWeakPtr< T > const &  p)
friend

Thread-safe creation of a Tf ref pointer from a Tf weak pointer.

This is thread-safe in the sense that the result will be either a ref pointer to a live object with non-zero ref-count, or a NULL ref pointer. However, this depends on the client to provide a guarantee to protect the pointed-to object.

Specifically, the caller must guarantee that the TfRefBase part of the pointed-to object is not destroyed during this call. It is fine if the destruction process for the object begins (due to the ref-count going to zero as another thread drops the last ref) as long as the TfRefBase portion is not destroyed. If object destruction begins because the ref-count goes to zero before this call completes, this function will reliably return a NULL ref pointer.

Note that this is not a general mechanism for safely converting weak pointers to ref pointers, because it relies on the type T to provide the above guarantee.

Definition at line 277 of file weakPtr.h.

◆ TfRefPtr

friend class TfRefPtr
friend

Definition at line 139 of file refBase.h.


The documentation for this class was generated from the following file: