#pragma once #include "ListDisplay.hpp" #include "ListE.hpp" #include "Record.hpp" #include #include #include namespace infoManagerCommand { namespace home { enum cmd { newRecord = 1, removeRecord, modifyRecord, setFilter, unsetFilter, setSortBy, flipSortOrder, help, saveFile, closeFile, quit }; } namespace promptFileName { enum cmd { openFile = 1, newFile }; } namespace promptSaveBeforeClose { enum cmd { save = 1, noSave }; } namespace promptNewRecord { enum cmd { lateRecord = 1, absentRecord, PersonalLeaveRecord }; } namespace promptNewInfo { enum cmd { date = 1, courseName, studentInfo }; } namespace filterSettings { enum cmd { recordID = 1, fromDate, toDate, courseName, studentID, studentName, recordType, }; } namespace sortbySettings { enum cmd { recordID = 1, date, courseName, studentID, studentName, recordType }; } } // namespace infoManagerCommand class StudentInfoManager { private: List recordPtrList; std::filesystem::directory_entry file; ListDisplay displayer; bool hasChangePendingSave; // Open the file in this->file. Assumes that the file exists. void readFile(); // Save the file to this->file. If the file does not exists, create one; if // such exists, overwrite. void saveFile(); // Reset this->file, and reset BaseRecord::nextRecordID void closeFile(); // Prompt for "open file name" or "new file name". Returns true if user // selected open file and needs to call readFile(); returns false if user // selects new file and no call to readFile() is needed. bool promptForFileName(); // The following functions are for handling commands user typed in. Returns // true when user goes deeper and finally selected a command. Returns false // if user typed 'esc' to quit. // The base for listening command. bool cmdNew(); bool cmdRemove(); bool cmdModify(); bool cmdSetFilter(); bool cmdSetSortby(); void displayHelp(); public: // Use when no command line argument exists StudentInfoManager(); // Use when has command line argument StudentInfoManager(const std::string _fileName); void mainloop(); ~StudentInfoManager(); };