5.3. Room DB fsml

(****
 *
 * Module TempRoomDB defines the major Room database objects of the scheduling tool.
 *
 *)

module RoomDB;

	export RoomDB;

  object RoomDB
    components: RoomEntry*;
    description: (*
        The TempRoomDB is the temporary databses for each schedule.  The contain all
        of the avaiable rooms for the quarters schedule, along with the times that they are
        avaiable.
    *);
  end;

  object RoomEntry
  	 components: timeslot:TimeSlot, building:Building, roomnumber:RoomNumber, type:Type, maxocc:MaxOcc, equipment:Equipment, disability:Disability;
    description: (*
        The Rooms object consists of building, room #, type, max occupancy, equipment, and disability
    *);
  end;
  
  object TimeSlot
  	 components: TimePref, Date, Time;
  	 description: (*
        The Timeslot onject contains all of the information about what time the room is avaiable to the 
        department for use.
    *);
  end;
  
  object TimePref
  	 components: Availability;
  	 description: (*
        For the time and date, is the class avaiable or not 
    *);
  end;
  
  object Availability = boolean;
  object Building = integer;
  object RoomNumber = integer;
  object Type = string;
  object MaxOcc = integer;
  object Equipment = string;
  object Disability = string;
  
  object Date = string;
  object Time = string;

operation AddEntry
    inputs: rdb:RoomDB, re:RoomEntry;
    outputs: rdb':RoomDB;
    description: (* This operation adds an entry to the 
    database.*);

    precondition:
        (*
         * There is no record in the input RoomDB with the same Building and Room Number as the
         * record to be added.  The Building, Room Number, and Type must not be empty.
         *)
        (not (exists (re' in rdb) re'.building = re.building and re'.roomnumber = re.roomnumber))
	and
	re.building != nil and re.roomnumber != nil and re.type != nil;

    postcondition:
        (*
         * There is no user record in the input RoomDB with the same Department and Course Number as the
         * record to be added.
         *
         * A course entry is in the output db if and only if it is the new
         * record to be added or it is in the input db.
         *)
        forall (re':RoomEntry)
           (re' in rdb') iff ((re' = re) or (re' in rdb));

  end;

  operation RemoveEntry
    inputs: rdb:RoomDB, re:RoomEntry;
    outputs: rdb':RoomDB;
    description: (* This operation removes an entry from the 
    database by building and number.*);
    precondition: (* The entry is in the database*)
    (re in rdb);
    postcondition: (* The entry is not in the database, but all other entries are still there *)
    (forall (re':RoomEntry)
            (re' in rdb') iff ((re' != re) and (re' in rdb)));

  end;

  operation ChangeEntry
    inputs: rdb:RoomDB, oldre:RoomEntry, newre:RoomEntry;
    outputs: rdb':RoomDB;
    description: (* This operation removes the old entry and adds a new entry to the database.*);

    precondition: (* Old entry must exist in the database, don't care if the new entry is the same as the old one.*)
      (oldre in rdb) and newre.building != nil and newre.roomnumber != nil;

    postcondition:
                 (*The old entry does not exist and the new entry does exist*)
    (newre in rdb') and not(oldre in rdb');
  end;



end RoomDB;




Prev: Attributes FMSL | Next: Instructor DB FMSL | Up: Specs | Top: index