module Navigation; from Lecture import all; from Layers import all; export all; object SlideDB components: sli:Slide*; description: (* The database of slides. *); end SlideDB; object Slide components: leclay:LectureLayer and num:Number; operations: Next, Previous; description: (* Used to keep track of the position of the base layer, the lecture layer. *); end Slide; object Number components: integer; description: (* The number of a specific slide in the Slide Database. *); end Number; object CurrentSlide components: sli:Slide; description: (* The current slide being shown. *); end CurrentSlide; object Jump components: integer; description: (* Used to store the slide number to jump to using the GoTo function. *); end Jump; object Broadcast components: boolean; description: (* Whether the presentation is being broadcasted to student machines or not. *); end Broadcast; object SlideControl operations: Previous, First, Start, Last, Next, Goto; description: (* The slide control bar is the window from where the slides are controlled. *); end SlideControl; operation First inputs: slidb:SlideDB, cursli:CurrentSlide; outputs: slidb':SlideDB, cursli':CurrentSlide; precondition:(* There is at least one slide available. *) #slidb >= 1; postcondition:(* The LectureScreen displays the first slide. *) cursli.sli = slidb[1]; end First; operation Start inputs: lecscr:LectureScreen; outputs: lecscr':LectureScreen; precondition:(* A lecture is loaded. *) lecscr != nil; postcondition:(* The lecture is broadcast to logged in student machines. *) lecscr.bro; end Start; operation Previous inputs: slidb:SlideDB, cursli:CurrentSlide; outputs: slidb':SlideDB, cursli':CurrentSlide; precondition:(* There is a previous slide available. *) cursli.sli.num > 1; postcondition:(* The LectureScreen displays the previous slide. *) cursli.sli = slidb[cursli.sli.num - 1]; end Previous; operation Next inputs: slidb:SlideDB, cursli:CurrentSlide; outputs: slidb':SlideDB, cursli':CurrentSlide; precondition:(* There is a next slide available. *) cursli.sli.num < #slidb - 1; postcondition:(* The LectureScreen displays the next slide. *) cursli.sli = slidb[cursli.sli.num + 1]; end Next; operation Goto inputs: slidb:SlideDB, cursli:CurrentSlide, jum:Jump; outputs: slidb':SlideDB, cursli':CurrentSlide; precondition:(* There is at least one slide available and the integer is within range. *) #slidb >= 1 and jum < #slidb and jum >= 1; postcondition:(* The LectureScreen displays the selected slide; *) cursli.sli = slidb[jum]; end Goto; end Navigation;