ClassRef Class Template Reference

A data type that manages the reference counting for unspecified data elements. More...

#include <ClassRef.h>

Inheritance diagram for ClassRef::

List of all members.

Public Methods

 ClassRef ()
 The default constructor.

virtual ~ClassRef ()
 Destructor.

void update_refs ()
 Update the data in the arrays sharing this object.

void acquire (V *array)
 Add a new array to the list of arrays sharing this object.

bool release (V *array)
 Remove an array from the list of arrays sharing this object.

void resize_ref_ptrs (const int)
 Resize the list of reference pointers.

virtual void copy_data (V *array)=0
 Copy the class' data to array.

virtual void reset_data (V *array)=0
 Reset the data in array.

virtual void delete_data ()=0
 Delete the data in the ArrayRef object.

void freeze ()
 Set a flag to share a fixed data array (e.g. that is not resized).


Public Attributes

EnumDataOwned own
 The ownership category.

int ref
 Number of arrays that are referencing this ClassRef instance.

int const_ref
 If true, references share a 'constant' array.


Static Public Attributes

int num_refs_limit = 32
 Max number of shared references.


Protected Attributes

int ptrlen
 Length of the ref_ptrs array.

V ** ref_ptrs
 Array of pointers to array objects that share this object.


Detailed Description

template<class V>
class ClassRef< V >

A data type that manages the reference counting for unspecified data elements.

This is a rather non-standard form of memory referencing, in which the reference object knows about all of the objects for which it is sharing memory. This is not a scalable form of reference management. However, it facilitates the use of reference sharing on an as-needed basis. Further, it facilitates the fast access of data in the main objects. See the BasicArray class for an example of how this reference sharing is used.

The variable ClassRef<V>::num_refs_limit can be used to set the maximum number of references allowed in a code. When this is exceeded, this code aborts.

If the flag ClassRef<V>::const_ref is true, then these references are assumed to share a 'constant' array, for which resize operations are not permited. This value is set by the 'freeze()' method. Note that there seems to be no reasonable way to 'unfreeze' references, since the back references are not updated for frozen ClassRef objects.


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