Honeycomb  0.1
Component-Model Framework
Public Member Functions | Friends | List of all members
honey::WeakPtr< T > Class Template Reference

Point to a shared object without holding a reference. The object is accessible through a lock, which prevents unexpected destruction. More...

#include <SharedPtr.h>

Inheritance diagram for honey::WeakPtr< T >:
Inheritance graph
[legend]
Collaboration diagram for honey::WeakPtr< T >:
Collaboration graph
[legend]

Public Member Functions

 WeakPtr ()
 
 WeakPtr (nullptr_t)
 
template<class U >
 WeakPtr (const SharedPtr< U > &rhs)
 Must construct from a shared pointer. More...
 
 WeakPtr (const WeakPtr &rhs)
 
template<class U >
 WeakPtr (const WeakPtr< U > &rhs)
 
 ~WeakPtr ()
 
WeakPtroperator= (const WeakPtr &rhs)
 
template<class U >
WeakPtroperator= (const WeakPtr< U > &rhs)
 
template<class U >
WeakPtroperator= (const SharedPtr< U > &rhs)
 
void set (nullptr_t)
 Set to null, release reference. More...
 
SharedPtr< T > lock () const
 Acquire access to object. Shared ptr prevents object from being destroyed while in use. Returns null if object has been destroyed. More...
 
int refCount () const
 Get strong reference (SharedPtr) count. More...
 
bool expired () const
 Check whether the object has already been destroyed. More...
 

Friends

template<class >
class WeakPtr
 
template<class >
class SharedPtr
 

Detailed Description

template<class T>
class honey::WeakPtr< T >

Point to a shared object without holding a reference. The object is accessible through a lock, which prevents unexpected destruction.

Weak pointers can be used to break cyclic references.
If an outside user releases a reference to one object that internally is also referenced by its members, then the object will not be destroyed as the user expects. This problem can be solved by replacing internal shared pointers with weak pointers until the cycle is broken.

See also
SharedPtr

Constructor & Destructor Documentation

template<class T>
honey::WeakPtr< T >::WeakPtr ( )
inline
template<class T>
honey::WeakPtr< T >::WeakPtr ( nullptr_t  )
inline
template<class T>
template<class U >
honey::WeakPtr< T >::WeakPtr ( const SharedPtr< U > &  rhs)
inline

Must construct from a shared pointer.

template<class T>
honey::WeakPtr< T >::WeakPtr ( const WeakPtr< T > &  rhs)
inline
template<class T>
template<class U >
honey::WeakPtr< T >::WeakPtr ( const WeakPtr< U > &  rhs)
inline
template<class T>
honey::WeakPtr< T >::~WeakPtr ( )
inline

Member Function Documentation

template<class T>
bool honey::WeakPtr< T >::expired ( ) const
inline

Check whether the object has already been destroyed.

template<class T>
SharedPtr<T> honey::WeakPtr< T >::lock ( ) const
inline

Acquire access to object. Shared ptr prevents object from being destroyed while in use. Returns null if object has been destroyed.

template<class T>
WeakPtr& honey::WeakPtr< T >::operator= ( const WeakPtr< T > &  rhs)
inline
template<class T>
template<class U >
WeakPtr& honey::WeakPtr< T >::operator= ( const WeakPtr< U > &  rhs)
inline
template<class T>
template<class U >
WeakPtr& honey::WeakPtr< T >::operator= ( const SharedPtr< U > &  rhs)
inline
template<class T>
int honey::WeakPtr< T >::refCount ( ) const
inline

Get strong reference (SharedPtr) count.

template<class T>
void honey::WeakPtr< T >::set ( nullptr_t  )
inline

Set to null, release reference.

Friends And Related Function Documentation

template<class T>
template<class >
friend class SharedPtr
friend
template<class T>
template<class >
friend class WeakPtr
friend

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