WWC snapshot of http://www.alw.nih.gov/Docs/NIHCL/nihcl_47.html taken on Sat Jun 10 19:14:02 1995

Go to the previous, next section.

StoreOnTbl--Tables used by Object Output

SYNOPSIS

#include <nihcl/OIOTbl.h>

BASE CLASS

NIHCL

DERIVED CLASSES

OIOofd, OIOout

RELATED CLASSES

ReadFromTbl

DESCRIPTION

The abstract class StoreOnTbl serves as the base class for classes OIOofd and OIOout, and maintains tables used by the storeOn(OIOofd&) and storeOn(OIOout&) member functions to perform object output.

If MI is defined, class StoreOnTbl also maintains an IdentSet to eliminate multiple calls to storer() for instances of classes used as virtual base classes.

The storeOn(OIOofd&) and storeOn(OIOout&) member functions reset the StoreOnTbl of their argument when first applied to an object to store it--recursive calls to storeOn() during an object store operation do not reset the StoreOnTbl. The information in the StoreOnTbl persists after the top-level call to storeOn() returns, and may be accessed via calls to classesStored(), objectsStored(), and membersStored().

ACCESSING STOREON TABLES

OrderedCltn classesStored()
OrderedCltn objectsStored()
OrderedCltn membersStored()
Returns an OrderedCltn containing pointers to all the class descriptors, objects, or member objects, respectively, stored by the most recent call to storeOn() with an instance derived from this StoreOnTbl as an argument.

The OrderedCltn returned by classesStored() is ordered by the class number assigned during the storeOn() operation, with index 0 corresponding to class number 1. The OrderedCltn returned by objectsStored() is ordered by the object number assigned during the storeOn() operation, with index 0 corresponding to object number 0, which is always the Nil object. The OrderedCltn of member objects returned by membersStored() is in no particular order, since member objects are not assigned numbers when stored.

unsigned long storeOnLevel()
Returns the current nesting depth of calls to storeOn() for this StoreOnTbl.

TESTING STOREON TABLES

bool _storeVBase(const void* p)
Returns NO if the (sub)object at address p has already been stored on this StoreOnTbl; otherwise, records the (sub)object at address p as having been stored and returns YES. Called by storeVBaseOn() to determine if storer() needs yet to be applied to an instance of a class used as a virtual base class.

PRINTING STOREON TABLES

virtual void dumpOn(ostream& strm =cerr) const
Prints the current storeOn() nesting level, highest assigned class and object numbers, and the stored class descriptor and object tables on the output stream strm.

PROTECTED MEMBERS

Constructors

StoreOnTbl(unsigned capacity =256)
Constructs a StoreOnTbl with an initial object dictionary capacity of capacity objects. If an attempt is made to store more than capacity objects, the object dictionary capacity is increased. Since this is an expensive operation, it is wise to supply a reasonable estimate for capacity.

Adding Objects

bool add(const Object& ob, int& num)
Returns NO if the argument object ob has already been added to this StoreOnTbl by a previous call to StoreOnTbl::add(). Raises an NIHCL_STREFMBR exception if ob was added to this StoreOnTbl by a previous call to addMember(). Otherwise, adds ob and returns YES. In either case num is set to the object's assigned number. The caller typically tests the return value and stores ob if it is YES, or stores a reference to the object's number if NO.

bool addClass(const Class* cl, unsigned short& num)
Returns NO if the argument class descriptor cl has already been added to this StoreOnTbl; otherwise, adds cl and returns YES. In either case num is set to the class's assigned number. The caller typically tests the return value and stores identification information for class cl if it is YES, or stores a reference to the class's number if NO.

void addMember(const Object& ob)
Tests this StoreOnTbl to check if the argument member object ob has already been added. If not, it adds ob and returns; otherwise, it raises an NIHCL_STMBRREF exception.

EXCEPTIONS RAISED

NIHCL_STMBRREF, NIHCL_STREFMBR

Go to the previous, next section.