wptr Class Template Reference

#include <support/Atom.h>

List of all members.


Detailed Description

template<class TYPE>
class wptr< TYPE >

Smart-pointer template that maintains a weak reference on an SAtom class.

You should always use this class when working with weak SAtom pointers, because it restricts what you can do with the referenced objects to only those things that are safe. For example, you can't call any methods on the object; to call a method, you must first call promote() to get a valid sptr<> from which you can then call the method.


Public Member Functions

void dec_weak (const void *id) const
 Explicitly decrement reference count of this atom.
SAtom::weak_atom_ptrget_weak_atom_ptr () const
 Retrieve the internal weak pointer object.
void inc_weak (const void *id) const
 Explicitly increment reference count of this atom.
template<class NEWTYPE>
wptr< TYPE > & operator= (const wptr< NEWTYPE > &p)
 Assigment from another weak pointer.
template<class NEWTYPE>
wptr< TYPE > & operator= (const sptr< NEWTYPE > &p)
 Assignment from a strong pointer.
wptr< TYPE > & operator= (const sptr< TYPE > &p)
 Assignment from a sptr.
wptr< TYPE > & operator= (const wptr< TYPE > &p)
 Assignment from another wptr.
wptr< TYPE > & operator= (TYPE *p)
 Assignment from a raw pointer.
const sptr< TYPE > promote () const
 Attempt to promote this secondary reference to a primary reference.
void set_weak_atom_ptr (SAtom::weak_atom_ptr *weak)
 Manually set the internal weak pointer object.
TYPE * unsafe_ptr_access () const
 Retrieve raw pointer.
template<class NEWTYPE>
 wptr (const sptr< NEWTYPE > &p)
 Initialization from a strong pointer to another type of SAtom subclass.
template<class NEWTYPE>
 wptr (const wptr< NEWTYPE > &p)
 Initialization from a weak pointer to another type of SAtom subclass.
 wptr (const sptr< TYPE > &p)
 Initialize from a sptr.
 wptr (const wptr< TYPE > &p)
 Initialize from another wptr.
 wptr (TYPE *p)
 Initialize to given pointer.
 wptr ()
 Initialize to NULL pointer.
 ~wptr ()
 Release weak reference on object.

Friends

class sptr< TYPE >


Constructor & Destructor Documentation

wptr  )  [inline]
 

Initialize to NULL pointer.

wptr TYPE *  p  )  [inline]
 

Initialize to given pointer.

wptr const wptr< TYPE > &  p  )  [inline]
 

Initialize from another wptr.

wptr const sptr< TYPE > &  p  )  [inline]
 

Initialize from a sptr.

wptr const wptr< NEWTYPE > &  p  )  [inline]
 

Initialization from a weak pointer to another type of SAtom subclass.

wptr const sptr< NEWTYPE > &  p  )  [inline]
 

Initialization from a strong pointer to another type of SAtom subclass.

~wptr  )  [inline]
 

Release weak reference on object.


Member Function Documentation

void dec_weak const void *  id  )  const [inline]
 

Explicitly decrement reference count of this atom.

Should very rarely be used -- normally you want to let wptr<> take care of the reference count for you.

Note:
This function directly modifies the weak reference count of the object by calling SAtom::DecWeak(). It does not change the reference count of the SAtom::weak_atom_ptr being held by the wptr<>.

SAtom::weak_atom_ptr * get_weak_atom_ptr  )  const [inline]
 

Retrieve the internal weak pointer object.

Should very rarely be used.

void inc_weak const void *  id  )  const [inline]
 

Explicitly increment reference count of this atom.

Should very rarely be used -- normally you want to let wptr<> take care of the reference count for you.

Note:
This function directly modifies the weak reference count of the object by calling SAtom::IncWeak(). It does not change the reference count of the SAtom::weak_atom_ptr being held by the wptr<>.

wptr< TYPE > & operator= const wptr< NEWTYPE > &  p  )  [inline]
 

Assigment from another weak pointer.

wptr< TYPE > & operator= const sptr< NEWTYPE > &  p  )  [inline]
 

Assignment from a strong pointer.

wptr< TYPE > & operator= const sptr< TYPE > &  p  )  [inline]
 

Assignment from a sptr.

wptr< TYPE > & operator= const wptr< TYPE > &  p  )  [inline]
 

Assignment from another wptr.

wptr< TYPE > & operator= TYPE *  p  )  [inline]
 

Assignment from a raw pointer.

const sptr< TYPE > promote  )  const [inline]
 

Attempt to promote this secondary reference to a primary reference.

The returned sptr<> will be NULL if it failed.

void set_weak_atom_ptr SAtom::weak_atom_ptr weak  )  [inline]
 

Manually set the internal weak pointer object.

Should very rarely be used.

TYPE * unsafe_ptr_access  )  const [inline]
 

Retrieve raw pointer.

Attention:
This is ONLY safe if you know that the atom is designed to remain valid after all strong pointers are removed, or that you will only access the safe parts of SAtom.


Friends And Related Function Documentation

friend class sptr< TYPE > [friend]
 


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