(**** * * Module StudentFile defines the objects and operations related to file processing * in the Student Application system. * *) module StudentFile; from StudentEdit import UserWorkSpace; from StudentApp import FeedbackEntry; export FileSpace, File, Server, UserID; object FileSpace is File* description: (* A FileSpace is an abstract model of a file space in the operating environment. The FileSpace is simply a collection of zero or more Files, with no other properties modeled here. *); end FileSpace; 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. Implementations may obey any syntactic or semantic constraints imposed by a particular environment. *); end FileName; object FilePermissions is is_readable:IsReadable and is_writable:IsWritable description: (* FilePermissions indicate whether a file is readable and/or writable. *); end FilePermissions; object IsReadable is boolean description: (* Flag indicating whether a file is readable, which is required to be true by the FileOpen operation. *); end IsReadable; object IsWritable is boolean description: (* Flag indicating whether a file is writable, which is required to be true by the FileSave operation. *); end IsWritable; object FileType is myplan_type:MyPlanType or other_type:OtherType description: (* The type of file data is either MyPlan data (which we care about) or any other type of data (which we don't care about). *); end FileType; object MyPlanType description: (* File data typing tag indicating that a file contains MyPlan data created by the Student Application *); end MyPlanType; object OtherType description: (* File data typing tag indicating that a file contains data other than MyPlan data created by the Student Application *); end OtherType; object FileData is StudentPlan description: (* The abstract representation of MyPlan-type FileData is a StudentPlan object. Student Application implementors may use any concrete file data representation that accurately holds all StudentPlan components. *); end FileData; object StudentPlan description: (* Opaque object representing the data in a file of a Student Plan *); end StudentPlan; operation FileNew is inputs: uws:UserWorkSpace; outputs: uws':UserWorkSpace; description: (* Add a new student plan to the workspace and make it current. *); end FileNew; operation FileOpen is inputs: fs:FileSpace, fn:FileName, uws:UserWorkSpace; outputs: uws':UserWorkSpace; description: (* Open an existing student plan of the given name and put the data from that file in the workspace. *); end FileOpen; operation FileSave is inputs: fs:FileSpace, uws:UserWorkSpace; outputs: fs':FileSpace, uws':UserWorkSpace; description: (* If the student plan in the given workspace requires saving, save it in the given file space. *); end FileSave; operation Login inputs: s:Server, uid:UserID, passwd:Password; outputs: il:IsLoggedIn; description: (* Login to the given server to access its database. If the user name and password exist on the server's user list, then IsLoggedIn is true. *); end; object Server components: users:Users and sfe:FeedbackEntry*; description: (* A server has a list of authentic users. Note that we are abstracting out server access via some form of network address. Think about how this would be modeled. Student feedback entries are also on the server *); end Server; operation FileSaveServer inputs: fs:FileSpace, uws:UserWorkSpace, s:Server, il:IsLoggedIn; outputs: fs':FileSpace, uws':UserWorkSpace, s':Server; precondition: il; description: (* If the student plan in the given workspace requires saving, save it in the given file space. *); end FileSaveServer; operation FileOpenServer inputs: fs:FileSpace, uws:UserWorkSpace, s:Server, il:IsLoggedIn; outputs: uws':UserWorkSpace, s':Server; precondition: il; description: (* Open an existing MyPlan file of the given name and put the data from that file in the workspace. *); end FileOpenServer; operation Print inputs: fs:FileSpace, uws:UserWorkSpace; outputs: od':OutputDevice; description: (* Given the student plan and filespace, output the student plan to a output device for printing *); end FileSaveServer; object OutputDevice description: (* Opaque object for a printer *); end OutputDevice; object Users components: UserRecord*; description: (* The databank of students on the server *); end Users; object UserRecord components: uid:UserID and passwd:Password; description: (* Each user defined by a UserID has a password *); end UserRecord; object UserID components: string; description: (* Username for logging into server *); end UserID; object Password components: string; description: (* User password for logging into server *); end Password; object IsLoggedIn is components: boolean; description: (* Determines if the current user is logged into the server *); end IsLoggedIn; end StudentFile;