ucommon  7.0.0
About: GNU uCommon C++ is a portable and optimized class framework for writing C++ applications that need to use threads and support concurrent synchronization, and that use sockets, XML parsing, object serialization, thread-optimized string and data structure classes, etc..
  Fossies Dox: ucommon-7.0.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Loading...
Searching...
No Matches
ucommon::AutoObject Class Reference

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

#include <object.h>

Inheritance diagram for ucommon::AutoObject:
[legend]
Collaboration diagram for ucommon::AutoObject:
[legend]

Public Member Functions

void release (void)
 Manually release the pointer. More...
 
bool operator! () const
 Test if the pointer is not set. More...
 
 operator bool () const
 Test if the pointer is referencing an object. More...
 

Protected Member Functions

 AutoObject ()
 
 AutoObject (ObjectProtocol *object)
 Construct an auto-pointer referencing an existing object. More...
 
 AutoObject (const AutoObject &pointer)
 Construct an auto-pointer as a copy of another pointer. More...
 
 ~AutoObject ()
 Delete auto pointer. More...
 
void set (ObjectProtocol *object)
 Set our pointer to a specific object. More...
 

Protected Attributes

ObjectProtocolobject
 

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.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 137 of file object.h.

Constructor & Destructor Documentation

◆ AutoObject() [1/3]

ucommon::AutoObject::AutoObject ( )
protected

Definition at line 65 of file object.cpp.

◆ AutoObject() [2/3]

ucommon::AutoObject::AutoObject ( ObjectProtocol object)
protected

Construct an auto-pointer referencing an existing object.

Parameters
objectwe point to.

Definition at line 57 of file object.cpp.

References ucommon::ObjectProtocol::retain().

Here is the call graph for this function:

◆ AutoObject() [3/3]

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
pointerwe are a copy of.

Definition at line 82 of file object.cpp.

References object, and ucommon::ObjectProtocol::retain().

Here is the call graph for this function:

◆ ~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.

Definition at line 77 of file object.cpp.

References release().

Here is the call graph for this function:

Member Function Documentation

◆ 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.

Definition at line 94 of file object.cpp.

◆ operator!()

bool ucommon::AutoObject::operator! ( ) const

Test if the pointer is not set.

Returns
true if the pointer is not referencing anything.

Definition at line 89 of file object.cpp.

◆ 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.

Definition at line 70 of file object.cpp.

Referenced by ~AutoObject().

◆ set()

void ucommon::AutoObject::set ( ObjectProtocol object)
protected

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
objectto assign to.

Definition at line 99 of file object.cpp.

References ucommon::ObjectProtocol::retain().

Referenced by ucommon::object_pointer< T >::operator=().

Here is the call graph for this function:

Member Data Documentation

◆ object

ObjectProtocol* ucommon::AutoObject::object
protected

Definition at line 140 of file object.h.

Referenced by AutoObject(), and ucommon::object_pointer< T >::operator=().


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