5.7. File.rsl






(****
 *
 * Module File defines the objects and operations related to files
 *  (courtesy of Dr. Gene Fisher)
 *)

module File;

  from ProjectModule import ProjectDB;
  from Edit import Clipboard, Selection, SelectionContext;
  export PreviousState, WorkSpace, FileSpace, File;

  object FileSpace is File
    description: (*
        A FileSpace is an abstract model of a file space in the operating
        environment in which the Scheduler is run.  The FileSpace is simply
        a collection of one File, with no other properties modeled here.
     *);
  end;

  object File is
    components: name:FileName and permissions:FilePermissions and
        file_type:FileType and data:FileData;
    description: (*
        A File is an abstraction of a file stored in the file space.  It has a
        name, permissions, type, and data.
    *);
  end File;

  object FileName is string
    description: (*
        The name of a file.  The string representation here is an abstraction
        of file names used in specific operating environments.
    *);
  end;

  object FilePermissions is is_readable:IsReadable and is_writable:IsWritable
    description: (*
        FilePermissions indicate whether a file is readable and/or writable.
    *);
  end;

  object IsReadable is boolean
    description: (*
        Flag indicating whether a file is readable, which is required to be
        true by the FileOpen operation.
    *);
  end;

  object IsWritable is boolean
    description: (*
        Flag indicating whether a file is writable, which is required to be
        true by the FileSave operation.
    *);
  end;

  object FileType is schedule_type:ScheduleType or other_type:OtherType
    description: (*
        The type of file data is either ScheduleType data (which we care about)
        or any other type of data that can be stored in a file, which we don't
        care about.
    *);
  end FileType;

  object ScheduleType
    description: (*
        File data typing tag indicating that a file contains a schedule project
    *);
  end ScheduleType;

  object OtherType
    description: (*
        File data typing tag indicating that a file contains data other than
        a schedule project
    *);
  end OtherType;

  object FileData is ProjectDB
    description: (*
        The abstract representation of ScheduleType FileData is a ProjectDB
        object.  System implementors may use any concrete file data
        representation that accurately holds all schedule components.
    *);
  end FileData;

  object WorkSpace is
    components: project:ProjectDB and
        previous_state:PreviousState and
        clipboard:Clipboard and selection:Selection and
        context:SelectionContext;
    description: (*
        The UserWorkSpace contains the active project upon which the user is
        working.  The project component is the active project. The
        previous_state component is used to support one level of command undo.
        The Clipboard is used with the Edit cut, copy, and paste operations.
    *);
  end;

  object PreviousState is
    components: prev:ProjectDB;
    description: (*
        PreviousState is the snapshot of the schedule before the most
        recently performed operation used by Edit->Undo.
    *);
  end PreviousState;

  operation FileOpen is
    inputs: fs:FileSpace, fn:FileName, uws:WorkSpace;
    outputs: fs':FileSpace, uws':WorkSpace;

    description: (*
        Open an existing scheduler project file of the given name and put the data from
        that file in the workspace.
    *);

  end FileOpen;

  operation FileClose is
    inputs: fs:FileSpace, uws:WorkSpace;
    outputs: fs':FileSpace, uws':WorkSpace;

    description: (*
        Close the current project if it does not require saving.
    *);

  end FileClose;

  operation FileSave is
    inputs: fs:FileSpace, uws:WorkSpace;
    outputs: fs':FileSpace, uws':WorkSpace;

    description: (*
        If the project in the given workspace requires saving, save it in the
        given file space.
    *);
  end FileSave;

end File;




Prev: Students | Next: Edit Commands | Up: Specification | Top: index