--PhoneRegistry.mesa
--Created By: El Abbadi, June 7, 1983 2:09 pm
-- Last Edited by: Cattell, January 16, 1984 3:51 pm

DIRECTORY
 Rope USING [ROPE],
 DB
 ;

PhoneRegistry: CEDAR DEFINITIONS = BEGIN

--General Comments

--A person is registered by associating with him a Name or a Phone Number, not necessarily
--both. A person may have more than one Phone Number, each serving similar or different
--functions........TO BE CONTINUED

--Procedures

RegisterPerson: PROC [name: Rope.ROPENIL, rName: Rope.ROPENIL]
       RETURNS[person: DB.Entity];
 -- If Rname exists check first and last names , update them to new values and change Person        Entity name. If it doesn't exist, check if last, first names exist, check and create person if required (Bad, rewrite this). if rName specified override any existing entries.

RegisterPhone: PROC [rName: Rope.ROPE←NIL, name: Rope.ROPE←NIL,
         phone: Rope.ROPE, phoneKind: Rope.ROPE];
-- Create person with given RName if one doesn't already exist.
 -- Register Phone, and its type in PhoneRelation.
 -- Check validity of Phone Number

GetPhoneNumber: PROC[rName: Rope.ROPE← NIL,
            last: Rope.ROPE← NIL, first: Rope.ROPE← NIL,
            phoneKind: Rope.ROPENIL]
         RETURNS [Rope.ROPE];
-- If RName/last name/firstname exists return associated PhoneNumber
-- of the requested type. Return "None" if none exist.
 -- At Least one of
rName, last, first must not be NIL
 -- If more than one person exists corresponding to given RName/last name/
firstname
 -- (in both segments) return list of persons names
 -- Give all phone numbers associated with a person irrispective of duplication

GetName: PROC[rName:Rope.ROPE] RETURNS [Rope.ROPE] ;
-- If RName exists return associated Name
-- Return "None" if none exist.
 -- If RName doesn't exist raise error
.
GetRName: PROC[last: Rope.ROPE←NIL, first: Rope.ROPE← NIL]
       RETURNS [Rope.ROPE] ;
-- If last/first names exist return associated RName
-- Return "None" if none exist.
 -- If RName doesn't exist raise error
.
MakeList: PROC[lowLName, highLName: Rope.ROPENIL,
           phoneKind: Rope.ROPE← NIL] ;
-- Make a list of RNames with their associated phone numbers of the kind noted,
-- in the specified range from lowRName to highRName in lexicographical order.
-- If no range is specified list the entire phone registry particular order.
-- If no phone kind is given list all phones associated.
    
AddFileToDB: PROC[newList:Rope.ROPE];
-- Register all entries in NewList in the DB. Entries have to be of the same format
-- as WhitePages.CNF is. as specified before.
-- Errors still have to be handled
Initialization: PROC ;
-- Set up the DataBase with:
-- Domain: Person,
 -- Relations: Phone, Name.
   

--Signals

Failed: ERROR[why:Failure, reason:Rope.ROPE];

Failure: TYPE = {NoSuchRName, NoSuchPhone, NoInputFile, Error};
-- Explain different error messages

END.