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::SparseObjects Class Referenceabstract

A sparse array of managed objects. More...

#include <object.h>

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

Public Member Functions

unsigned count (void)
 Get count of array elements. More...
 

Protected Member Functions

virtual ObjectProtocolcreate (void)=0
 Object factory for creating members of the spare array when they are initially requested. More...
 
void purge (void)
 Purge the array by deleting all created objects. More...
 
virtual ObjectProtocolinvalid (void) const
 
ObjectProtocolget (unsigned offset)
 Get (reference) an object at a specified offset in the array. More...
 
 SparseObjects (unsigned size)
 Create a sparse array of known size. More...
 
virtual ~SparseObjects ()
 Destroy sparse array and delete all generated objects. More...
 

Private Member Functions

 __DELETE_DEFAULTS (SparseObjects)
 

Private Attributes

ObjectProtocol ** vector
 
unsigned max
 

Detailed Description

A sparse array of managed objects.

This might be used as a simple array class for reference counted objects. This class assumes that objects in the array exist when assigned, and that gaps in the array are positions that do not reference any object. Objects are automatically created (create on access/modify when an array position is referenced for the first time. This is an abstract class because it is a type factory for objects who's derived class form constructor is not known in advance and is a helper class for the sarray template.

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

Definition at line 204 of file object.h.

Constructor & Destructor Documentation

◆ SparseObjects()

ucommon::SparseObjects::SparseObjects ( unsigned  size)
protected

Create a sparse array of known size.

No member objects are created until they are referenced.

Parameters
sizeof array.

Definition at line 111 of file object.cpp.

References max, and vector.

◆ ~SparseObjects()

ucommon::SparseObjects::~SparseObjects ( )
protectedvirtual

Destroy sparse array and delete all generated objects.

Definition at line 119 of file object.cpp.

References purge().

Here is the call graph for this function:

Member Function Documentation

◆ __DELETE_DEFAULTS()

ucommon::SparseObjects::__DELETE_DEFAULTS ( SparseObjects  )
private

◆ count()

unsigned ucommon::SparseObjects::count ( void  )

Get count of array elements.

Returns
array elements.

Definition at line 137 of file object.cpp.

References max, and vector.

◆ create()

virtual ObjectProtocol * ucommon::SparseObjects::create ( void  )
protectedpure virtual

Object factory for creating members of the spare array when they are initially requested.

Returns
new object.

Implemented in ucommon::sarray< T >.

Referenced by get().

◆ get()

ObjectProtocol * ucommon::SparseObjects::get ( unsigned  offset)
protected

Get (reference) an object at a specified offset in the array.

Parameters
offsetin array.
Returns
new or existing object.

Definition at line 152 of file object.cpp.

References create(), invalid(), max, ucommon::ObjectProtocol::retain(), and vector.

Referenced by ucommon::sarray< T >::at(), and ucommon::sarray< T >::get().

Here is the call graph for this function:

◆ invalid()

ObjectProtocol * ucommon::SparseObjects::invalid ( void  ) const
protectedvirtual

Definition at line 147 of file object.cpp.

Referenced by get().

◆ purge()

void ucommon::SparseObjects::purge ( void  )
protected

Purge the array by deleting all created objects.

Definition at line 124 of file object.cpp.

References max, ucommon::ObjectProtocol::release(), and vector.

Referenced by ~SparseObjects().

Here is the call graph for this function:

Member Data Documentation

◆ max

unsigned ucommon::SparseObjects::max
private

Definition at line 208 of file object.h.

Referenced by count(), get(), purge(), and SparseObjects().

◆ vector

ObjectProtocol** ucommon::SparseObjects::vector
private

Definition at line 207 of file object.h.

Referenced by count(), get(), purge(), and SparseObjects().


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