Solid Fluid System Solutions  
Home Software About Hardware Firmware
Folder Icon MemMgr
 
Our ANSI style memory management module.

Document Icon VCore (Library)
Document Icon Memory Manager
Document Icon Run-time Type
Document Icon Object Creation
Document Icon Constructor / Destructor
Document Icon Error Handling
Current Document Icon Verification
Document Icon Serialisation
Document Icon Synchronisation
Document Icon Thread Completion

Verification

Verification is an extended scheme for working with run-time type, and as such it is loosely linked to the actual run-time type stored in the VObject base class.

Verify() is a virtual function declared in VObject. Implementation on a derived class is mandatory.

This function checks the type, as opposed to the run-time type, of the class in which the Verify() implementation exists. This function can perform one of two general roles;

  • Verification
  • Intermediate type evaluation

Verification typically occurs when one expects an object to be of a given type as it is passed to, say, FunctionA(). Often such an object will be passed anonymously, and so there is no implicit certainty that it's type is correct. In this situation the programmer would usually be happy to make an assumption about the type, but would also want to flag an error or make an assertion if the type was not correct. This verification scenario could be satisfied using the VObject::GetType() function making a direct comparison of it's result against the expected type, in FunctionA().

One of the problems with this scheme is that one might receive an object with partial anonymity. This would occur when, say, FunctionB() is intended to work on an intermediate base class of the object. Typically FunctionB() already knows that the intermediate base is intended as a candidate for subclassing, but it makes no difference. FunctionB() must still do it's thing. The trouble is that the run-time type of the object, available through GetType(), is unknown at the time of coding. The actual object type passed into FunctionB() may not yet have been created, even though it's intermediate base class of interest has. Verify() solves this problem.

All implementations of verify follow the same three line format. The verify() function takes a run-time type id, and an abort flag. Each implementation of verify will check the passed run-time type id against the id of the associated class in which the verify function resides. If there is a match, then Verify() returns true. If not Subclass::Verify() will call SuperClass::Verify() with the arguments it was passed. By this scheme it is possible to test the class and all of it's bases for a run-time type identifier match.

This solves the partial anonymity problem, because FunctionB() can now determine whether the partially anonymous object is based on a known intermediate class.

This example reflects both of the general roles for type checking. In some circumstances, it might be an error for FunctionB() not to receive the correct intermediate type. This is the verification/assertion role. Equally it might be the the case that FunctionB() is searching a list of objects by a particular intermediate type. This is the type evaluation role. In either case the abort flag, passed to Verify() in the first instance, controls the role.

In the absolute base class, VObject, Verify() is the only implementation in the chain to actually inspect the abort flag. If VObject::Verify() is called and the run-time type id passed to it is not VOBJ_Object, then the abort parameter will determine if Verify() returns false, or calls ExitObject().

Copyright © Solid Fluid 2007-2022
Last modified: SolFlu  Sat, 13 Jun 2009 01:39:45 GMT