ucc::auto_pointer Class Reference

A general purpose smart pointer helper class. More...

#include <object.h>

Collaboration diagram for ucc::auto_pointer:

Collaboration graph
[legend]

Public Member Functions

 auto_pointer (Object *object)
 Construct an auto-pointer referencing an existing object.
 auto_pointer (const auto_pointer &pointer)
 Construct an auto-pointer as a copy of another pointer.
 ~auto_pointer ()
 Delete auto pointer.
void release (void)
 Manually release the pointer.
bool operator! () const
 Test if the pointer is not set.
 operator bool () const
 Test if the pointer is referencing an object.
bool operator== (Object *object) const
 test if the object being referenced is the same as the object we specify.
bool operator!= (Object *object) const
 test if the object being referenced is not the same as the object we specify.
void operator= (Object *object)
 Set our pointer to a specific object.

Protected Attributes

Objectobject

Detailed Description

A general purpose smart pointer helper class.

This is particularly useful in conjunction with reference counted objects which can be managed and automatically removed from the heap when they are no longer being referenced by a smart pointer. The smart pointer itself would normally be constructed and initialized as an auto variable in a method call, and will dereference the object when the pointer falls out of scope. This is actually a helper class for the typed pointer template.

Author:
David Sugar <dyfet@gnutelephony.org>

Definition at line 193 of file object.h.


Constructor & Destructor Documentation

ucc::auto_pointer::auto_pointer ( Object object  ) 

Construct an auto-pointer referencing an existing object.

Parameters:
object we point to.

ucc::auto_pointer::auto_pointer ( const auto_pointer pointer  ) 

Construct an auto-pointer as a copy of another pointer.

The retention of the object being pointed to will be increased.

Parameters:
pointer we are a copy of.

ucc::auto_pointer::~auto_pointer (  ) 

Delete auto pointer.

When it falls out of scope, the retention of the object it references is reduced. If it falls to zero in a reference counted object, then the object is auto-deleted.


Member Function Documentation

ucc::auto_pointer::operator bool (  )  const

Test if the pointer is referencing an object.

Returns:
true if the pointer is currently referencing an object.

bool ucc::auto_pointer::operator! (  )  const

Test if the pointer is not set.

Returns:
true if the pointer is not referencing anything.

bool ucc::auto_pointer::operator!= ( Object object  )  const

test if the object being referenced is not the same as the object we specify.

Parameters:
object we compare to.
Returns:
true if this is not the object our pointer references.

void ucc::auto_pointer::operator= ( Object object  ) 

Set our pointer to a specific object.

If the pointer currently references another object, that object is released. The pointer references our new object and that new object is retained.

Parameters:
object to assign to.

bool ucc::auto_pointer::operator== ( Object object  )  const

test if the object being referenced is the same as the object we specify.

Parameters:
object we compare to.
Returns:
true if this is the object our pointer references.

void ucc::auto_pointer::release ( void   ) 

Manually release the pointer.

This reduces the retention level of the object and resets the pointer to point to nobody.


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

Generated on Tue Jul 28 21:43:31 2009 for UCommon by  doxygen 1.5.9