📄 rules.h
字号:
/*File rules.hCopyright 2002, 2003 Lalescu Liviu.This file is part of FET.FET is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or(at your option) any later version.FET is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with FET; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/#ifndef RULES_H#define RULES_H#include "genetictimetable_defs.h"#include "timeconstraint.h"#include "spaceconstraint.h"#include "activity.h"#include "studentsset.h"#include "teacher.h"#include "subject.h"#include "subjecttag.h"#include "equipment.h"#include "building.h"#include "room.h"#include <qstring.h>#include <qfile.h>#include <qtextstream.h>#include <qptrvector.h>/**This class contains the processed input (all the information regardingthe faculty: teachers, students, activities, constraints, etc.)<p>Or: Structure that keeps a representation of the requirements for thetimetable (all the input)*/class Rules{public: /** The name of the institution */ QString institutionName; /** The comments */ QString comments; /** The number of hours per day */ int nHoursPerDay; /** The number of days per week */ int nDaysPerWeek; /** The days of the week (names) */ QString daysOfTheWeek[MAX_DAYS_PER_WEEK]; /** The hours of the day (names). This includes also the last hour (+1) */ QString hoursOfTheDay[MAX_HOURS_PER_DAY+1]; /** The number of hours per week */ int nHoursPerWeek; /** The list of teachers */ TeachersList teachersList; /** The list of subjects */ SubjectsList subjectsList; /** The list of subject tags */ SubjectTagsList subjectTagsList; /** The list of students (groups and subgroups included). Remember that every identifier (year, group or subgroup) must be UNIQUE. */ StudentsYearsList yearsList; /** The list of activities */ ActivitiesList activitiesList; /** The list of equipments */ EquipmentsList equipmentsList; /** The list of buildings */ BuildingsList buildingsList; /** The list of rooms */ RoomsList roomsList; /** The list of time constraints */ TimeConstraintsList timeConstraintsList; /** The list of space constraints */ SpaceConstraintsList spaceConstraintsList; /** This is the array which specifies a fixed day for some activities. -1 means that this activity has no fixed day */ int16 fixedDay[MAX_ACTIVITIES]; /** This is the array which specifies a fixed hour for some activities. -1 means that this activity has no fixed hour */ int16 fixedHour[MAX_ACTIVITIES]; /** This array specifies, for each activity (1), a reference to another activity (2). The starting day of activity 1 is taken as the starting day of activity 2. -1 means that the activity is independent of other activities. */ int sameDay[MAX_ACTIVITIES]; /** This array specifies, for each activity (1), a reference to another activity (2). The starting hour of activity 1 is taken as the starting hour of activity 2. -1 means that the activity is independent of other activities. */ int sameHour[MAX_ACTIVITIES]; /** This is the array which specifies a fixed room for some activities. -1 means that this activity has no fixed room */ int16 fixedRoom[MAX_ACTIVITIES]; /** This array specifies, for each activity (1), a reference to another activity (2). The room of activity 1 is taken as the room of activity 2. -1 means that the activity is independent of other activities. */ int sameRoom[MAX_ACTIVITIES]; //The following variables contain redundant data and are used internally //////////////////////////////////////////////////////////////////////// int nInternalTeachers; Teacher* internalTeachersList[MAX_TEACHERS]; int nInternalSubjects; Subject* internalSubjectsList[MAX_SUBJECTS]; int nInternalSubgroups; StudentsSubgroup* internalSubgroupsList[MAX_TOTAL_SUBGROUPS]; /** Here will be only the active activities. For speed, I used here not pointers, but static copies. */ int nInternalActivities; Activity internalActivitiesList[MAX_ACTIVITIES]; int nInternalEquipments; Equipment* internalEquipmentsList[MAX_EQUIPMENTS]; int nInternalBuildings; Building* internalBuildingsList[MAX_BUILDINGS]; int nInternalRooms; Room* internalRoomsList[MAX_ROOMS]; int nInternalTimeConstraints; TimeConstraint* internalTimeConstraintsList[MAX_TIME_CONSTRAINTS]; int nInternalSpaceConstraints; SpaceConstraint* internalSpaceConstraintsList[MAX_SPACE_CONSTRAINTS]; bool roomHasEquipment[MAX_ROOMS][MAX_EQUIPMENTS]; //////////////////////////////////////////////////////////////////////// /** True if the rules have been initialized in some way (new or loaded). */ bool initialized; /** True if the internal structure was computed. */ bool internalStructureComputed; /** Initializes the rules (empty) */ void init(); /** Internal structure initializer. <p> After any modification of the activities or students or teachers or constraints, there is a need to call this subroutine */ bool computeInternalStructure(); /** Terminator - basically clears the memory for the constraints. */ void kill(); Rules(); ~Rules(); /** Adds a new teacher to the list of teachers (if not already in the list). Returns false/true (unsuccessful/successful). */ bool addTeacher(Teacher* teacher); /** Returns the index of this teacher in the teachersList, or -1 for inexistent teacher. */ int searchTeacher(const QString& teacherName); /** Removes this teacher and all related activities and constraints. It returns false on failure. If successful, returns true. */ bool removeTeacher(const QString& teacherName); /** Modifies (renames) this teacher and takes care of all related activities and constraints. Returns true on success, false on failure (if not found) */ bool modifyTeacher(const QString& initialTeacherName, const QString& finalTeacherName); /** A function to sort the teachers alphabetically */ void sortTeachersAlphabetically(); /** Adds a new subject to the list of subjects (if not already in the list). Returns false/true (unsuccessful/successful). */ bool addSubject(Subject* subject); /** Returns the index of this subject in the subjectsList, or -1 if not found. */ int searchSubject(const QString& subjectName); /** Removes this subject and all related activities and constraints. It returns false on failure. If successful, returns true. */ bool removeSubject(const QString& subjectName); /** Modifies (renames) this subject and takes care of all related activities and constraints. Returns true on success, false on failure (if not found) */ bool modifySubject(const QString& initialSubjectName, const QString& finalSubjectName); /** A function to sort the subjects alphabetically */ void sortSubjectsAlphabetically(); /** Adds a new subject tag to the list of subject tags (if not already in the list). Returns false/true (unsuccessful/successful). */ bool addSubjectTag(SubjectTag* subjectTag); /** Returns the index of this subject tag in the subjectTagsList,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -