A general purpose smart pointer helper class.
More...
#include <object.h>
|
| operator bool () const |
| Test if the pointer is referencing an object.
|
|
bool | operator! () const |
| Test if the pointer is not set.
|
|
void | release (void) |
| Manually release the pointer.
|
|
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.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org
Definition at line 137 of file object.h.
◆ AutoObject() [1/2]
Construct an auto-pointer referencing an existing object.
- Parameters
-
◆ AutoObject() [2/2]
ucommon::AutoObject::AutoObject |
( |
const AutoObject & | pointer | ) |
|
|
protected |
Construct an auto-pointer as a copy of another pointer.
The retention of the object being pointed to will be increased.
- Parameters
-
◆ ~AutoObject()
ucommon::AutoObject::~AutoObject |
( |
| ) |
|
|
protected |
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.
◆ operator bool()
ucommon::AutoObject::operator bool |
( |
| ) |
const |
Test if the pointer is referencing an object.
- Returns
- true if the pointer is currently referencing an object.
◆ operator!()
bool ucommon::AutoObject::operator! |
( |
| ) |
const |
Test if the pointer is not set.
- Returns
- true if the pointer is not referencing anything.
◆ release()
void ucommon::AutoObject::release |
( |
void | | ) |
|
Manually release the pointer.
This reduces the retention level of the object and resets the pointer to point to nobody.
◆ set()
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
The documentation for this class was generated from the following file:
- /builddir/build/BUILD/ucommon-7.0.0-build/ucommon-7.0.0/inc/ucommon/object.h