class HCL_Base

HCL_Base is the base class for all HCL classes

Inheritance:


Public Methods

int Count ()
Access to the reference count
void DecCount ()
Decrement reference count
HCL_Base ()
Default constructor
void IncCount ()
Increment reference count

Private Fields

int ReferenceCount
The integer ReferenceCount is the number of objects pointing at this object

Documentation

HCL_Base is the base class for all HCL classes. The purpose of having a common base class is to implement reference counting. HCL_Base contains an integer called ReferenceCount; whenever a programmer wants to copy a pointer to a HCL object rather than copying the object itself, he must call the method IncCount(), which increments ReferenceCount. The object cannot be deleted unless its ReferenceCount is 1; however, in order for this scheme to work, the function HCL_delete must be used in place of the operator delete. Note that the programmer who increments the reference count is responsible for calling HCL_delete for that object (just as a programmer who calls new is responsible for calling delete).

The most common situation in which one wants to copy a pointer to a HCL object is in a constructor. Suppose an object is constructed which depends on a HCL object. It may not be desirable to make a copy of the HCL object (due to time or space overhead). One can just copy the pointer to the object and increment its reference count; then the HCL object cannot be deleted until its reference count has be decremented by a call to HCL_delete.

Example:

MyObject::MyObject( HCL_Object * obj,... ) // constructor for MyObject
{
   hclobj = obj;   // hclobj is a data member of type HCL_Object*
   obj->IncCount();  // Increment obj's reference count
   // etc.
}

MyObject::~MyObject()  // destructor for MyObject
{
   HCL_delete( hclobj ); // Decrement obj's reference count
   // etc.
}

The point of HCL's reference counting is to provide protection against an object being deleted by one part of the code while another part of the code is still using it. In the above example, the object pointed to by hclobj will not disappear while the MyObject object still points to it.

int ReferenceCount
The integer ReferenceCount is the number of objects pointing at this object

HCL_Base()
Default constructor. This is called whenever a HCL object is constructed; it just sets ReferenceCount to 1.

void IncCount()
Increment reference count. This must be called whenever a pointer to a HCL object is copied. There must be a matching call to the global function HCL_delete; otherwise a memory leak will result.

void DecCount()
Decrement reference count. This is called by HCL_delete and need never be invoked directly.

int Count()
Access to the reference count. This is used by HCL_delete.


Direct child classes:
HCL_Vector_d
HCL_VectorSpace_d
HCL_Op_d
HCL_LinearOp_d
HCL_Functional_d
HCL_EvaluateOpDerivAdj_d
HCL_EvaluateFunctionalGrad_d
HCL_BiLinearOp_d
HCL_UMinHess_d
HCL_UMinGrad_d
HCL_UMinProductDomainHess_d
HCL_UMinProductDomainGrad_d
HCL_TrustRegionSolver_d
HCL_MatTR_d
HCL_LinearSolver_d
HCL_LineSearch_d
HCL_ItEigSolver_d
HCL_CMinALHess_d
HCL_CMinALGrad_d

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de