Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::base::WeakReferentPtr< T > Class Template Reference

A WeakReferentPtr is a weak reference to an instance of some class derived from Referent. More...

#include "weakreferent.h"

Inheritance diagram for ion::base::WeakReferentPtr< T >:

Public Types

typedef ReferentPtr< T >::Type ReferentPtrType
 

Public Member Functions

 WeakReferentPtr ()
 
 WeakReferentPtr (T *ptr)
 
 WeakReferentPtr (const ReferentPtrType &ref_ptr)
 
 WeakReferentPtr (const WeakReferentPtr &other)
 Copy constructor. More...
 
ReferentPtrType Acquire () const
 Attempts to construct a ReferentPtr of the reference. More...
 
void Reset ()
 Set this WeakPointer to not refer to anything. More...
 
WeakReferentPtr< T > & operator= (const ReferentPtrType &p)
 Allow assignment from a SharedPtr of the same type. More...
 
bool operator== (const WeakReferentPtr &p) const
 The equality operator returns true if the proxies are the same. More...
 
bool operator!= (const WeakReferentPtr &p) const
 The inequality operator returns true if the proxies differ. More...
 
int GetUnderlyingRefCountUnsynchronized () const
 This function returns the reference count of the underlying referent that points to. More...
 

Detailed Description

template<typename T>
class ion::base::WeakReferentPtr< T >

A WeakReferentPtr is a weak reference to an instance of some class derived from Referent.

It returns a ReferentPtr instance through the Acquire() call, which is the only way to access the underlying instance. This ReferentPtr will only be valid (non-NULL) if there are valid ReferentPtrs that still point to the underlying instance. Note that a WeakReferentPtr requires a ReferentPtr to the instance to already exist; WeakReferentPtrs are useless on their own, and will free any non-ref'd pointers passed to them (see Reset(), below).

Like SharedPtr, WeakReferentPtr is not thread-safe; synchronization must be used to ensure that an instance can only be accessed by one thread at a time.

Definition at line 182 of file weakreferent.h.

Member Typedef Documentation

template<typename T>
typedef ReferentPtr<T>::Type ion::base::WeakReferentPtr< T >::ReferentPtrType

Definition at line 184 of file weakreferent.h.

Constructor & Destructor Documentation

template<typename T>
ion::base::WeakReferentPtr< T >::WeakReferentPtr ( )
inline

Definition at line 186 of file weakreferent.h.

template<typename T>
ion::base::WeakReferentPtr< T >::WeakReferentPtr ( T ptr)
inlineexplicit

Definition at line 187 of file weakreferent.h.

template<typename T>
ion::base::WeakReferentPtr< T >::WeakReferentPtr ( const ReferentPtrType ref_ptr)
inlineexplicit

Definition at line 188 of file weakreferent.h.

template<typename T>
ion::base::WeakReferentPtr< T >::WeakReferentPtr ( const WeakReferentPtr< T > &  other)
inline

Copy constructor.

Definition at line 192 of file weakreferent.h.

Member Function Documentation

template<typename T>
ReferentPtrType ion::base::WeakReferentPtr< T >::Acquire ( ) const
inline

Attempts to construct a ReferentPtr of the reference.

This is required to perform operations on the pointer. The construction is successful only if there are already existing ReferentPtrs to the instance. If successful, the returned ReferentPtr will have the normal lifetime guarantees. If it fails, it returns a NULL ReferentPtr, meaning that the Referent has already been deleted.

Definition at line 201 of file weakreferent.h.

template<typename T>
int ion::base::WeakReferentPtr< T >::GetUnderlyingRefCountUnsynchronized ( ) const
inline

This function returns the reference count of the underlying referent that points to.

This function performs no synchronization, and should only be considered accurate when called from the underlying referent's destructor.

Definition at line 273 of file weakreferent.h.

template<typename T>
bool ion::base::WeakReferentPtr< T >::operator!= ( const WeakReferentPtr< T > &  p) const
inline

The inequality operator returns true if the proxies differ.

Definition at line 266 of file weakreferent.h.

template<typename T>
WeakReferentPtr<T>& ion::base::WeakReferentPtr< T >::operator= ( const ReferentPtrType p)
inline

Allow assignment from a SharedPtr of the same type.

Definition at line 255 of file weakreferent.h.

template<typename T>
bool ion::base::WeakReferentPtr< T >::operator== ( const WeakReferentPtr< T > &  p) const
inline

The equality operator returns true if the proxies are the same.

Definition at line 261 of file weakreferent.h.

template<typename T>
void ion::base::WeakReferentPtr< T >::Reset ( )
inline

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