Data member definition. A data member definition describes a data member in a record type. It has the following interface:
initialize
: creates and initializes a data member
definition. The name of the data member definition should
be supplied at this point. If data members are typed, the
type should be specified at this point. The same logic applies
the any default value for a data member definition.
getName
: retrieves the name of the data member
definition. This
operation is useful when the containing record type needs to
list all of its data members, or to search for one based on
name.
getType
: retrieves the type of a data member definition.
getDefaultValue
: retrieves the default value of a data
member definition.
Record type. A record type is analogous to a named struct
in C, or a class
in C++ without methods. It has the following
interface:
initialize
: creates and initializes a record type. The
name of the record type should supplied at this point.
addDataMemberDefn
: add a data member definition to a
record type.
removeDataMemberDefn
: removes a data member definition from
a record type.
lookupDataMemberDefn
: looks up a data member definition from
a record type based on name. Returns a data member definition.
getDataMemberDefnNames
: returns a list of names of
data member definitions.
createInstance
: creates and initializes a record (instance)
from a record type.
Data member. A data member is a part of a record (instance). A data member has a particular value, and it must correspond to a data member definition. Its interface is as follows:
initialize
: creates and initializes a data member. The
parameter should include a data member definition so that the
data member can acquire a default value.
setValue
: sets the value of a data member.
getValue
: retrieves the value of a data member.
getDefinition
: retrieves the data member definition
that corresponds to a data member.
Record (instance). A record (instance) is an actual record with its own state. It has the following interface:
initialize
: creates and initializes a record. The
parameter should include a record type to indicate how to
create this record.
getRecordType
: retrieves the record type of a record.
getDataMemberValue
: retrieves the value of a data member by
name.
setDataMemberValue
: sets the value of a data member by name.
To make things a little easier to understand, here is an example using
the built-in struct
construct in C.
struct X // record type, name is X { int i; // data member defn, name is i, type is int float f; // data member defn, name is f, type is float }; { X myX; // record (instance) myX myX.i = 0; // record->setDataMember printf("%f\n",myX.f); // record->getDataMember }
Copyright © 2006-09-13 by Tak Auyeung