WWC snapshot of http://www.alw.nih.gov/Docs/NIHCL/nihcl_41.html taken on Sat Jun 10 19:13:58 1995

Go to the previous, next section.

ReadFromTbl--Tables used by Object Input

SYNOPSIS

#include <nihcl/OIOTbl.h>

BASE CLASS

NIHCL

DERIVED CLASSES

OIOifd, OIOin

RELATED CLASSES

StoreOnTbl

DESCRIPTION

The abstract class ReadFromTbl serves as the base class for classes OIOifd and OIOin, and maintains tables used by the readFrom(OIOifd&) and readFrom(OIOin&) member functions to perform object input.

The readFrom(OIOifd&) and readFrom(OIOin&) member functions reset the ReadFromTbl of their argument when first applied to an object to store it--recursive calls to readFrom() during an object store operation do not reset the ReadFromTbl. The information in the ReadFromTbl persists after the top-level call to readFrom() returns, and may be accessed via calls to classesRead() and objectsRead().

ACCESSING READFROM TABLES

const Class* classAt(int n)
Returns a pointer to the class descriptor with class number n, as assigned by the most recent call to readFrom() with this ReadFromTbl as an argument.

Object* objectAt(int n)
Returns a pointer to the object with object number n, as assigned by the most recent call to readFrom() with this ReadFromTbl as an argument.

const Class* readFromClass()
Returns a pointer to the class descriptor of the class of the object currently being read. Usually called from a readFrom() constructor to determine if it has been called to initialize an instance of a base class (readFromClass() != isA()), or if it is the constructor of the most-derived class of an object (readFromClass() == isA()). This is useful when a readFrom() constructor must call virtual functions, to assure that it calls the intended implementations of these virtual functions.

OrderedCltn classesRead()
OrderedCltn objectsRead()
Returns an OrderedCltn containing pointers to all the class descriptors or objects, respectively, read by the most recent call to readFrom() with an instance derived from this ReadFromTbl as an argument.

The OrderedCltn returned by classesRead() is ordered by the class number assigned during the readFrom() operation, with index 0 corresponding to class number 1. The OrderedCltn returned by objectsRead() is ordered by the object number assigned during the readFrom() operation, with index 0 corresponding to object number 0, which is always the Nil object.

unsigned long readFromLevel()
Returns the current nesting depth of calls to readFrom() for this ReadFromTbl.

PRINTING READFROM TABLES

virtual void dumpOn(ostream& strm =cerr) const
Prints the current readFrom() nesting level, add object enable flag, and the read class descriptor and object tables on the output stream strm.

PROTECTED MEMBERS

Constructors

ReadFromTbl(unsigned capacity =1024)
Constructs a ReadFromTbl with an initial object capacity of capacity objects. If an attempt is made to read more than capacity objects, the object dictionary capacity is increased.

Adding Objects

void addObjectEnable()
Enables the next call to add(Object&) applied to this ReadFromTbl to be effective. Called from Class::readObject().

void add(Object& ob)
If addObjectEnable() has just been invoked, adds the argument object ob to this ReadFromTbl so that its address can be retrieved by calling objectAt(). Objects must be added in the order they are read from the object input stream so that add() assigns them the correct object number. Subsequent calls to add(Object&) are disabled until addObjectEnable() is called again.

int add(const Class* cl)
Adds the argument class descriptor cl to this ReadFromTbl so that its address can be retrieved by calling classAt(). Returns the assigned class number. Classes must be added in the order they are read from the object input stream so that add() assigns them the correct class number.

Accessing ReadFrom Tables

const Class* readFromClass(const Class* cl)
Returns a pointer to the class descriptor of the class of the object currently being read, and sets cl as the new current class descriptor pointer.

EXCEPTIONS RAISED

NIHCL_STMBRREF, NIHCL_STREFMBR

Go to the previous, next section.