(*** 
   * This file defines the objects and operations related to the entire Schedule
   * See Sections 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9
   *
   *)

module ScheduleM;

	from Database import RoomDatabase, CourseDatabase, InstructorDatabase;	
	from ScheduledClass import ScheduledClass;
	from File import all;
	from Feedback import FeedbackObject;

	export all;

obj Schedule is 
	components: id:InstructorDatabase and cd:CourseDatabase and rd:RoomDatabase and
scheduledClasses:ScheduledClassList and t: Term and p: Phase and 
FairnessResults* and requires_saving:RequiresSaving and
file:File and l: Locked and fo: FeedbackObject*;
	description: (*
		This object holds everything related to the schedule so that it can be 
		displayed to the user and used to generate the schedule by either the
		administrator or the generate schedule algorithm.  
		*);
	end Schedule;
	
obj RequiresSaving is 
	components: boolean;
	description: (*a boolean*);
end RequiresSaving;


(* NOTE: all the indented files were added by Jonathan, so if they're a problem, talk to him. *)
	object ScheduleList is
	    components: s: Schedule*;
	    description: (* A list of schedules. *);
	end ScheduleList;

	object Term is
		components: y: Year and s: Season;
		description: (* A Term has both a year and a season *);
	end Term;

	object Year is
	    components: i: integer;
	    description: (* A Calendar Year *);
	end Year;


	object Season is
	    components: Winter or Spring or Summer or Fall;
	    description: (* Season represents a season of the year *);
	end Season;

	object Winter is
	    description: (* Enumeration for Winter *);
	end Winter;

	object Spring is
	    description: (* Enumeration for Spring *);
	end Spring;

	object Summer is
	    description: (* Enumeration for Summer *);
	end Summer;

	object Fall is
	    description: (* Enumeration for Fall *);
	end Fall;
	
	object Locked is
	    components: b: boolean and id: string;
	    description: (* Says whether the schedule is locked and cannot be edited and if it is locked, it has
	                    the user name of the admin that locked it.*);
	end Locked;



obj FairnessResults is 
	components: InstructorList and AlgorithmPointsList and TotalPointsPossibleList;
	description:(* 
		This object is used for the GenerateSchedule algorithm.  At the time when
		the algorithm is done running, the FairnessResults are stored in the 
		generated Schedule and can be viewed by the user by selecting the option
		in the menu.  Only an instructor list is necessary because when the user
		sees which instructors got the worst schedules, he can choose to go into
		that specific instructors preferences and edit them.  The whole Instructor
		object doesnt belong here because it would take up space and be useless.
		The InstructorList in conjunction with the AlgorithmPointsList and 
		TotalPointsPossibleList show the instructor name, points out of total.
		*);
	end FairnessResults;


obj TotalPointsPossibleList is 
	components: integer*;
	description:(*integer list*);
end TotalPointsPossible;

obj AlgorithmPointsList is 
	components: integer*;
	description: (*integer list*);
end AlgorithmPointsList;

obj InstructorList is 
	components: string*;
	description: (*string list*);
end InstructorList;

obj ScheduledClassList is 
	components: sc: ScheduledClass*;
	description:(*scheduledClasses list*);
end ScheduledClassList;

obj Phase is 
	components: integer;
	description: (*integer*);
end Phase;

op FairnessAlgorithmResults is 
	inputs: s:Schedule;
	outputs: s': Schedule and fr:FairnessResults*;
	description: (*
		This is a formality mostly.  With this operation the user will be able to 
		actually see the results of the GenerateSchedule algorithm's attack on the
		individual Instructors preference points.  This operation will be used in
		parallel with our user interface.  
		*);
	precondition:
		(*
		 *Schedule is not nil and has scheduledCLasses*
		 *)

			(s != nil) and (s.scheduledClasses != nil)

		;
	postcondition:
		(*
		 * the schedule is the same, unaltered.
		 *)
		
			(s' = s) 
		
			and
		
		(*
		 * FairnessResults is not nil
		 *)
		
			(fr != nil)
		;
	end FairnessAlgorithmResults;

end ScheduleM;