-- File: NutDump.mesa
-- Implemented by: NutDumpImpl, NutLoadImpl
-- Last edited by: John Maxwell on: June 3, 1982 9:36 am
-- Willie-Sue on: February 22, 1983 3:46 pm
-- Donahue on: January 20, 1983 9:58 am
-- Last Edited by: Cattell, April 28, 1983 2:28 pm

DIRECTORY
DB USING [Domain, Entity, Relation, Relship],
IO USING [STREAM],
Rope USING [ROPE];

NutDump: CEDAR DEFINITIONS =
BEGIN OPEN DB, IO, Rope;

--**************************************************
-- for gross dumping of the data base
--**************************************************

DumpToFile: PROC[
segment: ROPE,  -- segment cannot be defaulted
fileName: ROPENIL,
dl: LIST OF Domain ← NIL,
rl: LIST OF Relation ← NIL,
complement: BOOLEANFALSE,
entityCentric: BOOLEANFALSE];
-- dumps only the domains and relations given
-- if complement = TRUE, dumps everything but the domains and relations given

-- if entityCentric = TRUE, dumps entities with relships reffing them in first attribute

DumpAll: PROC[segment: ROPE, fileName: ROPENIL] =
INLINE {DumpToFile[segment, fileName, NIL, NIL, TRUE]};

LoadFromFile: PROC[dumpFile: ROPENIL, DBFile: ROPENIL];
-- Loads whatever is in the
dumpFile into the DBFile; uses same dump format as DumpToFile.
-- the segment name is given in the dumpFile; if the DBFile does not exist, it is created

--**************************************************
-- for selective dumping of the data base
--**************************************************

OpenFile: PROC[fileName: ROPE] RETURNS[STREAM];
CloseFile: PROC[fileStream: STREAM];
-- you may use a different type of stream if you choose

WriteSchema: PROC[s: STREAM, dl: LIST OF Domain, rl: LIST OF Relation];
WriteDomain
: PROC[s: STREAM, d: Domain, refs: BOOL← FALSE]; -- writes entities in domain
WriteEntity: PROC[s: STREAM, e: Entity]; -- writes a particular entity
WriteRelation: PROC[s: STREAM, r: Relation]; -- writes all the relships of the relation
WriteRelship: PROC[s: STREAM, r: Relship]; -- writes a particular relship

END . . .