-- File: DBModel.mesa
-- Contents: Internal versions of DBModel procs, imported by DBImpl
-- and exported to DBModel.
-- Last edited by:
-- Cattell on: July 21, 1983 2:05 pm
-- Willie-sue, February 3, 1983 10:51 am

DIRECTORY
Rope,
DB;


DBModel: DEFINITIONS IMPORTS DB

= BEGIN OPEN DB;

QInitialize: PROC[
nCachePages: NAT, nFreeTuples: NAT, cacheFileName: ROPE, augments: BOOL];

QOpenTransaction: PROC[
segment: Segment, useTrans: Transaction← NIL, noLog: BOOL];

QMarkTransaction: PROC[trans: Transaction];

QAbortTransaction: PROC[trans: Transaction];

QCloseTransaction: PROC[trans: Transaction];

QDeclareSegment: PROC[
filePath: ROPE, segment: Segment← NIL, number: NAT← 0, readonly: BOOL← FALSE,
createIfNotFound: BOOL← TRUE, nBytesInitial, nBytesPerExtent: INT← 32768 ];

QEraseSegment: PROC[segment: Segment];

QGetSegmentInfo: PROC[segment: Segment] RETURNS [
filePath: ROPE, number: NAT, trans: Transaction,
readOnly: BOOL, nBytesInitial, nBytesPerExtent: INT];

QGetSegments: PUBLIC PROC RETURNS [LIST OF Segment];


-- *** Part 2: Schema-definition operations [DBModelGlobalImpl]

QDeclareDomain: PROC [
name: ROPE, segment: Segment,
version: Version← NewOrOld, estRelships: INT← 5] RETURNS [d: Domain];

QDeclareRelation: PROC [
name: ROPE, segment: Segment, version: Version← NewOrOld] RETURNS [r: Relation];

QDeclareAttribute: PROC [
r: Relation, name: ROPE, type: DataType← AnyDomainType,
uniqueness: Uniqueness ← None, length: INT← 0, link: LinkType← Linked,
version: Version← NewOrOld]
RETURNS[a: Attribute];  

QDeclareSubType: PROC [of, is: Domain];

QDeclareIndex: PROC [r: Relation, order: AttributeList, version: Version] RETURNS[Index];

QDestroyDomain: PROC [d: Domain];

QDestroyRelation: PROC [r: Relation];

QDestroySubType: PROC [of, is: Domain];


-- *** Part 3: Primitive operations [DBModelBasicImpl]

QDeclareEntity: PROC[d: Domain, name: ROPE← NIL, version: Version← NewOrOld]
RETURNS [e: Entity];

QFetchEntity: PROC[d: Domain, name: ROPE← NIL, segment: Segment← NIL]
RETURNS [e: Entity];

QDeclareRelship: PROC[r: Relation, init: AttributeValueList← NIL, version: Version← NewOrOld]
RETURNS[t: Relship];

QDestroyEntity: PROC[e: Entity];

QDestroyRelship: PROC[t: Relship];

QSetF: PROC[t: Relship, a: Attribute, v: Value, updateIndices: BOOL← TRUE];
-- Special updateIndices argument => update associated indices

QSetFS: PROC [t: Relship, a: Attribute, v: ROPE];

QGetF: PROC[t: Relship, a: Attribute, string: BOOL← FALSE] RETURNS [Value];
-- Special string argument => fetch attribute as string regardless of actual type.

QGetFS: PROC[t: Relship, a: Attribute] RETURNS [ROPE];

QNameOf: PROC [e: Entity] RETURNS [s: ROPE];

QChangeName: PROC [e: Entity, s: ROPE];

QDomainOf: PROC[e: Entity] RETURNS [Domain];

QRelationOf: PROC[t: Relship] RETURNS [Relation];

QSegmentOf: PROC[x: EntityOrRelship] RETURNS [Segment];


-- *** Part 4: Aggregate operations [DBModelSetImpl]

QRelationSubset: PROC[
r: Relation, constraint: AttributeValueList← NIL,
start: FirstLast← First, searchSegment: Segment← NIL] RETURNS [RelshipSet];

QNextRelship: PROC[t: RelshipSet] RETURNS [Relship];

QPrevRelship: PROC[t: RelshipSet] RETURNS [Relship];

QReleaseRelshipSet: PROC [rs: RelshipSet];

QDomainSubset: PROC[
d: Domain, lowName, highName: ROPE← NIL, start: FirstLast← First,
searchSubDomains: BOOL← TRUE, segment: Segment← NIL] RETURNS [EntitySet];

QNextEntity: PROC[es: EntitySet] RETURNS [Entity];

QPrevEntity: PROC[es: EntitySet] RETURNS [Entity];

QReleaseEntitySet: PROC[es: EntitySet];

QGetAllRefAttributes: PROC [e: Entity] RETURNS [AttributeList];

QGetDomainRefAttributes: PROC[d: Domain] RETURNS[al: AttributeList];

-- *** Part 5: Miscellaneous operations [DBModelBasicImpl]

-- Properties

QDeclareProperty: PROC [
relationName: ROPE, of: Domain, is: DataType, segment: Segment,
uniqueness: Uniqueness← None, version: Version← NewOrOld] RETURNS [aIs: Attribute];

QGetP: PROC [e: Entity, aIs: Attribute, aOf: Attribute← NIL] RETURNS [v: Value];

QSetP: PROC [e: Entity, aIs: Attribute, v: Value, aOf: Attribute← NIL] RETURNS [Relship];

QGetPList: PROC [e: Entity, aIs: Attribute, aOf: Attribute← NIL] RETURNS [vl: LIST OF Value];

QSetPList: PROC [e: Entity, aIs: Attribute, vl: LIST OF Value, aOf: Attribute← NIL];

QEntitySetToList: PROC[es: EntitySet] RETURNS [el: LIST OF Entity];

QRelshipSetToList: PROC[rs: RelshipSet] RETURNS [rl: LIST OF Relship];

END.

Change log:

By Cattell October 22, 1982 12:43 pm: use "Q" instead of "Internal" to save characters. Modified for new view level, properties.

By Willie-Sue on February 3, 1983
-- added noLog arg to QOpenTransaction