#include <object.h>
Collaboration diagram for ucommon::auto_object:
Public Member Functions | |
auto_object (auto_object &pointer) | |
Construct an auto-pointer as a copy of another pointer. | |
auto_object (ObjectProtocol *object) | |
Construct an auto-pointer referencing an existing object. | |
operator bool () | |
Test if the pointer is referencing an object. | |
bool | operator! () |
Test if the pointer is not set. | |
bool | operator!= (ObjectProtocol *object) |
test if the object being referenced is not the same as the object we specify. | |
void | operator= (ObjectProtocol *object) |
Set our pointer to a specific object. | |
bool | operator== (ObjectProtocol *object) |
test if the object being referenced is the same as the object we specify. | |
void | release (void) |
Manually release the pointer. | |
~auto_object () | |
Delete auto pointer. | |
Protected Attributes | |
ObjectProtocol * | object |
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.
Definition at line 132 of file object.h.
ucommon::auto_object::auto_object | ( | ObjectProtocol * | object | ) |
Construct an auto-pointer referencing an existing object.
object | we point to. |
ucommon::auto_object::auto_object | ( | auto_object & | pointer | ) |
Construct an auto-pointer as a copy of another pointer.
The retention of the object being pointed to will be increased.
pointer | we are a copy of. |
ucommon::auto_object::~auto_object | ( | ) |
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.
ucommon::auto_object::operator bool | ( | ) |
Test if the pointer is referencing an object.
bool ucommon::auto_object::operator! | ( | ) |
Test if the pointer is not set.
bool ucommon::auto_object::operator!= | ( | ObjectProtocol * | object | ) |
test if the object being referenced is not the same as the object we specify.
object | we compare to. |
void ucommon::auto_object::operator= | ( | ObjectProtocol * | 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.
object | to assign to. |
bool ucommon::auto_object::operator== | ( | ObjectProtocol * | object | ) |
test if the object being referenced is the same as the object we specify.
object | we compare to. |
void ucommon::auto_object::release | ( | void | ) |
Manually release the pointer.
This reduces the retention level of the object and resets the pointer to point to nobody.