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::TypeRef Class Reference

Smart pointer base class for auto-retained objects. More...

#include <typeref.h>

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

Classes

class  Counted
 Heap base-class container for typeref objects. More...
 

Public Member Functions

virtual ~TypeRef ()
 Destroy pointer when falling out of scope. More...
 
void set (const TypeRef &pointer)
 Set our smart pointer based on another pointer instance. More...
 
void clear (void)
 Manually release the current container. More...
 
size_t size (void) const
 Get size of referenced heap object. More...
 
unsigned copies () const
 Get number of references to container. More...
 
 operator bool () const
 Check if pointer currently has a heap container. More...
 
bool operator! () const
 Check if we are currently not pointing to anything. More...
 
bool is_released (void)
 

Static Public Member Functions

static void put (TypeRef &target, Counted *object)
 Special weak-public means to copy a container reference. More...
 

Protected Member Functions

 TypeRef (Counted *object)
 Create a smart pointer referencing an existing heap object. More...
 
 TypeRef (const TypeRef &pointer)
 Create a smart pointer based on another pointer. More...
 
 TypeRef ()
 Create a smart pointer referencing nothing. More...
 
void set (Counted *object)
 Set our smart pointer to a specific heap container. More...
 
void assign (const typeref_guard &ref)
 Assign from a guarded typeref. More...
 

Static Protected Member Functions

static caddr_t mem (caddr_t address)
 Adjust memory pointer to atomic boundry. More...
 

Protected Attributes

Countedref
 

Friends

class ArrayRef
 
class SharedRef
 
class MapRef
 
class TypeRelease
 

Detailed Description

Smart pointer base class for auto-retained objects.

The underlying container is heap allocated and page aligned. A heap object is automatically de-referenced by release during destruction. The smart pointer is a protected base class used to derive strongly typed templates.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 68 of file typeref.h.

Constructor & Destructor Documentation

◆ TypeRef() [1/3]

ucommon::TypeRef::TypeRef ( TypeRef::Counted object)
protected

Create a smart pointer referencing an existing heap object.

Parameters
objectto reference.

Definition at line 70 of file typeref.cpp.

References ref, and ucommon::TypeRef::Counted::retain().

Here is the call graph for this function:

◆ TypeRef() [2/3]

ucommon::TypeRef::TypeRef ( const TypeRef pointer)
protected

Create a smart pointer based on another pointer.

Both pointers then reference the same object.

Parameters
pointerinstance to share reference with.

Definition at line 77 of file typeref.cpp.

References ucommon::copy(), ref, and ucommon::TypeRef::Counted::retain().

Here is the call graph for this function:

◆ TypeRef() [3/3]

ucommon::TypeRef::TypeRef ( )
protected

Create a smart pointer referencing nothing.

Definition at line 65 of file typeref.cpp.

References ref.

◆ ~TypeRef()

ucommon::TypeRef::~TypeRef ( )
virtual

Destroy pointer when falling out of scope.

This de-references the heap container.

Definition at line 84 of file typeref.cpp.

References clear().

Here is the call graph for this function:

Member Function Documentation

◆ assign()

void ucommon::TypeRef::assign ( const typeref_guard ref)
protected

Assign from a guarded typeref.

Definition at line 115 of file typeref.cpp.

References ucommon::Mutex::acquire(), clear(), ref, ucommon::Mutex::release(), ucommon::TypeRef::Counted::retain(), and ucommon::typeref_guard::sync.

Referenced by ucommon::typeref< T, R >::operator=(), ucommon::typeref< T, R >::typeref(), ucommon::typeref< const char * >::typeref(), and ucommon::typeref< const uint8_t * >::typeref().

Here is the call graph for this function:

◆ clear()

void ucommon::TypeRef::clear ( void  )

Manually release the current container.

Definition at line 89 of file typeref.cpp.

References ref, and ucommon::TypeRef::Counted::release().

Referenced by assign(), set(), ucommon::typeref< T, R >::set(), and ~TypeRef().

Here is the call graph for this function:

◆ copies()

unsigned ucommon::TypeRef::copies ( ) const

Get number of references to container.

Returns
total number of pointers referencing container.

Definition at line 512 of file typeref.cpp.

References ucommon::TypeRef::Counted::copies(), and ref.

Here is the call graph for this function:

◆ is_released()

bool ucommon::TypeRef::is_released ( void  )

Definition at line 96 of file typeref.cpp.

References ucommon::TypeRef::Counted::autorelease, and ref.

◆ mem()

caddr_t ucommon::TypeRef::mem ( caddr_t  address)
staticprotected

Adjust memory pointer to atomic boundry.

Parameters
addressthat was allocated.
Returns
address for actual atomic aligned object.

Definition at line 133 of file typeref.cpp.

References ucommon::addr(), and ucommon::Thread::cache().

Referenced by ucommon::ArrayRef::create(), ucommon::MapRef::create(), ucommon::typeref< T, R >::set(), and ucommon::typeref< T, R >::typeref().

Here is the call graph for this function:

◆ operator bool()

ucommon::TypeRef::operator bool ( ) const
inline

Check if pointer currently has a heap container.

Returns
true if we are referencing a container.

Definition at line 238 of file typeref.h.

◆ operator!()

bool ucommon::TypeRef::operator! ( ) const
inline

Check if we are currently not pointing to anything.

Returns
true if not referencing a container.

Definition at line 246 of file typeref.h.

◆ put()

static void ucommon::TypeRef::put ( TypeRef target,
Counted object 
)
inlinestatic

Special weak-public means to copy a container reference.

This uses the base class container which is not public, so only derived type specific smart pointers can actually use this method. It is made public because making it protected actually makes it inaccessible to template derived classes.

Parameters
targetsmart pointer object to set.
objectto have it reference.

Definition at line 259 of file typeref.h.

References set().

Referenced by ucommon::arrayref< T >::put().

Here is the call graph for this function:

◆ set() [1/2]

void ucommon::TypeRef::set ( const TypeRef pointer)

Set our smart pointer based on another pointer instance.

If we are already referencing, we release the current container.

Parameters
pointerinstance to share reference with.

Definition at line 107 of file typeref.cpp.

References clear(), ref, and ucommon::TypeRef::Counted::retain().

Here is the call graph for this function:

◆ set() [2/2]

void ucommon::TypeRef::set ( TypeRef::Counted object)
protected

Set our smart pointer to a specific heap container.

If we were pointing to something already we release that.

Parameters
objectto reference.

Definition at line 125 of file typeref.cpp.

References clear(), and ref.

Referenced by ucommon::arrayref< T >::operator=(), ucommon::listref< T >::operator=(), ucommon::mapref< K, V >::operator=(), ucommon::queueref< T >::operator=(), ucommon::stackref< T >::operator=(), ucommon::typeref< T, R >::operator=(), put(), ucommon::ArrayRef::realloc(), ucommon::stackref< T >::release(), ucommon::queueref< T >::release(), ucommon::arrayref< T >::release(), ucommon::ArrayRef::resize(), ucommon::typeref_guard::set(), ucommon::typeref< T, R >::set(), and ucommon::typeref< T, R >::typeref().

Here is the call graph for this function:

◆ size()

Friends And Related Function Documentation

◆ ArrayRef

friend class ArrayRef
friend

Definition at line 71 of file typeref.h.

◆ MapRef

friend class MapRef
friend

Definition at line 73 of file typeref.h.

◆ SharedRef

friend class SharedRef
friend

Definition at line 72 of file typeref.h.

◆ TypeRelease

friend class TypeRelease
friend

Definition at line 74 of file typeref.h.

Member Data Documentation

◆ ref


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