diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..273cf912b Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index 4b2dc5ec7..664a78f54 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ IndividualMiniprojectC++/.vscode/ -IndividualMiniprojectC++/external_libraries/boost_1_85_0 -IndividualMiniprojectC++/external_libraries/Crow-1.2.0-Darwin +IndividualMiniprojectC++/external_libraries/boost_1_86_0 +IndividualMiniprojectC++/external_libraries/Crow-1.2.0 IndividualMiniprojectC++/build/* +build/* !IndividualMiniprojectC++/build/README.txt !IndividualMiniprojectC++/external_libraries/README.txt \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..7970fff03 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "C/C++: clang build and debug active file", + "type": "cppdbg", + "request": "launch", + "program": "${fileDirname}/${fileBasenameNoExtension}", + "args": [], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "environment": [], + "externalConsole": false, + "MIMode": "lldb", + "preLaunchTask": "C/C++: clang build active file" + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..37569fc7d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "cmake.sourceDirectory": "/Users/virgilemison/Documents/Columbia/Fall24/adv_swe/4156-Miniproject-2024-Students-Cplusplus/IndividualMiniprojectC++", + "files.associations": { + "string": "cpp" + } +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..429d57d2e --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,50 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: clang build active file", + "command": "/usr/bin/clang", + "args": [ + "-fcolor-diagnostics", + "-fansi-escape-codes", + "-g", + "${file}", + "-o", + "${fileDirname}/${fileBasenameNoExtension}" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": "build", + "detail": "Task generated by Debugger." + }, + { + "type": "cppbuild", + "label": "C/C++: clang++ build active file", + "command": "/usr/bin/clang++", + "args": [ + "-fcolor-diagnostics", + "-fansi-escape-codes", + "-g", + "${file}", + "-o", + "${fileDirname}/${fileBasenameNoExtension}" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/IndividualMiniprojectC++/.DS_Store b/IndividualMiniprojectC++/.DS_Store index ace1005ed..2c56371b3 100644 Binary files a/IndividualMiniprojectC++/.DS_Store and b/IndividualMiniprojectC++/.DS_Store differ diff --git a/IndividualMiniprojectC++/CMakeLists.txt b/IndividualMiniprojectC++/CMakeLists.txt index ed2cd10fe..4c7b6ef92 100644 --- a/IndividualMiniprojectC++/CMakeLists.txt +++ b/IndividualMiniprojectC++/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.15) project(IndividualMiniproject) -set(INCLUDE_PATHS external_libraries/boost_1_85_0 external_libraries/Crow-1.2.0-Darwin/include) +set(INCLUDE_PATHS external_libraries/boost_1_86_0 external_libraries/Crow-1.2.0/include) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -19,9 +19,8 @@ add_executable(IndividualMiniproject include(FetchContent) FetchContent_Declare( - googletest - URL https://github.com/google/googletest/archive/ff233bdd4cac0a0bf6e5cd45bda3406814cb2796.zip - DOWNLOAD_EXTRACT_TIMESTAMP TRUE + googletest + URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip ) FetchContent_MakeAvailable(googletest) @@ -30,7 +29,7 @@ FetchContent_MakeAvailable(googletest) target_include_directories(IndividualMiniproject PUBLIC ${INCLUDE_PATHS} include - /opt/homebrew/Cellar/asio/1.30.2/include + /usr/local/Cellar/asio/1.30.2/include ) target_link_libraries(IndividualMiniproject PRIVATE @@ -52,7 +51,7 @@ add_executable(IndividualMiniprojectTests target_include_directories(IndividualMiniprojectTests PRIVATE ${INCLUDE_PATHS} include - /opt/homebrew/Cellar/asio/1.30.2/include + /usr/local/Cellar/asio/1.30.2/include ) target_link_libraries(IndividualMiniprojectTests PRIVATE diff --git a/IndividualMiniprojectC++/external_libraries/.DS_Store b/IndividualMiniprojectC++/external_libraries/.DS_Store new file mode 100644 index 000000000..a9131574f Binary files /dev/null and b/IndividualMiniprojectC++/external_libraries/.DS_Store differ diff --git a/IndividualMiniprojectC++/include/Course.h b/IndividualMiniprojectC++/include/Course.h index 7900730d1..397c7dd79 100644 --- a/IndividualMiniprojectC++/include/Course.h +++ b/IndividualMiniprojectC++/include/Course.h @@ -1,17 +1,20 @@ +// Copyright 2024 vcm2114 #include -#ifndef COURSE_H -#define COURSE_H + +#ifndef _USERS_VIRGILEMISON_DOCUMENTS_COLUMBIA_FALL24_ADV_SWE_4156_MINIPROJECT_2024_STUDENTS_CPLUSPLUS_INDIVIDUALMINIPROJECTCPP_INCLUDE_COURSE_H_ +#define _USERS_VIRGILEMISON_DOCUMENTS_COLUMBIA_FALL24_ADV_SWE_4156_MINIPROJECT_2024_STUDENTS_CPLUSPLUS_INDIVIDUALMINIPROJECTCPP_INCLUDE_COURSE_H_ class Course { - private: + private: int enrollmentCapacity; int enrolledStudentCount; std::string courseLocation; std::string instructorName; std::string courseTimeSlot; - - public: - Course(int count, const std::string &instructorName, const std::string &courseLocation, const std::string &timeSlot); + + public: + Course(int count, const std::string &instructorName, + const std::string &courseLocation, const std::string &timeSlot); Course(); std::string getCourseLocation() const; @@ -32,4 +35,4 @@ class Course { void deserialize(std::istream& in); }; -#endif \ No newline at end of file +#endif // _USERS_VIRGILEMISON_DOCUMENTS_COLUMBIA_FALL24_ADV_SWE_4156_MINIPROJECT_2024_STUDENTS_CPLUSPLUS_INDIVIDUALMINIPROJECTCPP_INCLUDE_COURSE_H_" diff --git a/IndividualMiniprojectC++/include/Department.h b/IndividualMiniprojectC++/include/Department.h index 4a5fd699a..e5cfc6403 100644 --- a/IndividualMiniprojectC++/include/Department.h +++ b/IndividualMiniprojectC++/include/Department.h @@ -1,15 +1,14 @@ +// Copyright 2024 vcm2114 #include #include #include "Course.h" -#ifndef DEPARTMENT_H -#define DEPARTMENT_H +#ifndef _USERS_VIRGILEMISON_DOCUMENTS_COLUMBIA_FALL24_ADV_SWE_4156_MINIPROJECT_2024_STUDENTS_CPLUSPLUS_INDIVIDUALMINIPROJECTCPP_INCLUDE_DEPARTMENT_H_ +#define _USERS_VIRGILEMISON_DOCUMENTS_COLUMBIA_FALL24_ADV_SWE_4156_MINIPROJECT_2024_STUDENTS_CPLUSPLUS_INDIVIDUALMINIPROJECTCPP_INCLUDE_DEPARTMENT_H_ -#include -#include #include class Department { - public: + public: Department(std::string deptCode, std::map> courses, std::string departmentChair, int numberOfMajors); @@ -27,7 +26,7 @@ class Department { std::string getDepartmentChair() const; std::map> getCourseSelection() const; - private: + private: int numberOfMajors; std::string deptCode; std::string departmentChair; @@ -36,4 +35,4 @@ class Department { -#endif \ No newline at end of file +#endif // _USERS_VIRGILEMISON_DOCUMENTS_COLUMBIA_FALL24_ADV_SWE_4156_MINIPROJECT_2024_STUDENTS_CPLUSPLUS_INDIVIDUALMINIPROJECTCPP_INCLUDE_DEPARTMENT_H_" diff --git a/IndividualMiniprojectC++/include/Globals.h b/IndividualMiniprojectC++/include/Globals.h index 9b33c19db..b789ccf28 100644 --- a/IndividualMiniprojectC++/include/Globals.h +++ b/IndividualMiniprojectC++/include/Globals.h @@ -1,9 +1,10 @@ +// Copyright 2024 vcm2114 #include "MyFileDatabase.h" -#ifndef GLOBALS_H -#define GLOBALS_H +#ifndef _USERS_VIRGILEMISON_DOCUMENTS_COLUMBIA_FALL24_ADV_SWE_4156_MINIPROJECT_2024_STUDENTS_CPLUSPLUS_INDIVIDUALMINIPROJECTCPP_INCLUDE_GLOBALS_H_ +#define _USERS_VIRGILEMISON_DOCUMENTS_COLUMBIA_FALL24_ADV_SWE_4156_MINIPROJECT_2024_STUDENTS_CPLUSPLUS_INDIVIDUALMINIPROJECTCPP_INCLUDE_GLOBALS_H_ -extern MyFileDatabase* globalDatabase; +extern MyFileDatabase* globalDatabase; -#endif +#endif // _USERS_VIRGILEMISON_DOCUMENTS_COLUMBIA_FALL24_ADV_SWE_4156_MINIPROJECT_2024_STUDENTS_CPLUSPLUS_INDIVIDUALMINIPROJECTCPP_INCLUDE_GLOBALS_H_" diff --git a/IndividualMiniprojectC++/include/MyApp.h b/IndividualMiniprojectC++/include/MyApp.h index 9c5240f2a..96b55ed0a 100644 --- a/IndividualMiniprojectC++/include/MyApp.h +++ b/IndividualMiniprojectC++/include/MyApp.h @@ -1,5 +1,6 @@ -#ifndef MYAPP_H -#define MYAPP_H +// Copyright 2024 vcm2114 +#ifndef _USERS_VIRGILEMISON_DOCUMENTS_COLUMBIA_FALL24_ADV_SWE_4156_MINIPROJECT_2024_STUDENTS_CPLUSPLUS_INDIVIDUALMINIPROJECTCPP_INCLUDE_MYAPP_H_ +#define _USERS_VIRGILEMISON_DOCUMENTS_COLUMBIA_FALL24_ADV_SWE_4156_MINIPROJECT_2024_STUDENTS_CPLUSPLUS_INDIVIDUALMINIPROJECTCPP_INCLUDE_MYAPP_H_ #include #include @@ -8,13 +9,13 @@ #include "MyFileDatabase.h" class MyApp { - public: + public: static void run(const std::string& mode); static void onTermination(); static void overrideDatabase(MyFileDatabase* testData); static MyFileDatabase* getDatabase(); - private: + private: static void setupDatabase(); static void resetDataFile(); @@ -22,4 +23,4 @@ class MyApp { static bool saveData; }; -#endif +#endif // _USERS_VIRGILEMISON_DOCUMENTS_COLUMBIA_FALL24_ADV_SWE_4156_MINIPROJECT_2024_STUDENTS_CPLUSPLUS_INDIVIDUALMINIPROJECTCPP_INCLUDE_MYAPP_H_" diff --git a/IndividualMiniprojectC++/include/MyFileDatabase.h b/IndividualMiniprojectC++/include/MyFileDatabase.h index 208a3b2e0..ce4981d39 100644 --- a/IndividualMiniprojectC++/include/MyFileDatabase.h +++ b/IndividualMiniprojectC++/include/MyFileDatabase.h @@ -1,24 +1,25 @@ +// Copyright 2024 vcm2114 #include "Department.h" #include #include -#ifndef MYFILEDATABASE_H -#define MYFILEDATABASE_H +#ifndef _USERS_VIRGILEMISON_DOCUMENTS_COLUMBIA_FALL24_ADV_SWE_4156_MINIPROJECT_2024_STUDENTS_CPLUSPLUS_INDIVIDUALMINIPROJECTCPP_INCLUDE_MYFILEDATABASE_H_ +#define _USERS_VIRGILEMISON_DOCUMENTS_COLUMBIA_FALL24_ADV_SWE_4156_MINIPROJECT_2024_STUDENTS_CPLUSPLUS_INDIVIDUALMINIPROJECTCPP_INCLUDE_MYFILEDATABASE_H_ class MyFileDatabase { - public: + public: MyFileDatabase(int flag, const std::string& filePath); void setMapping(const std::map& mapping); void saveContentsToFile() const; void deSerializeObjectFromFile(); - + std::map getDepartmentMapping() const; std::string display() const; - private: + private: std::map departmentMapping; std::string filePath; }; -#endif \ No newline at end of file +#endif // _USERS_VIRGILEMISON_DOCUMENTS_COLUMBIA_FALL24_ADV_SWE_4156_MINIPROJECT_2024_STUDENTS_CPLUSPLUS_INDIVIDUALMINIPROJECTCPP_INCLUDE_MYFILEDATABASE_H_" diff --git a/IndividualMiniprojectC++/include/RouteController.h b/IndividualMiniprojectC++/include/RouteController.h index f4acd96d8..8cde7d828 100644 --- a/IndividualMiniprojectC++/include/RouteController.h +++ b/IndividualMiniprojectC++/include/RouteController.h @@ -1,34 +1,35 @@ -#ifndef ROUTECONTROLLER_H -#define ROUTECONTROLLER_H +// Copyright 2024 vcm2114 +#ifndef _USERS_VIRGILEMISON_DOCUMENTS_COLUMBIA_FALL24_ADV_SWE_4156_MINIPROJECT_2024_STUDENTS_CPLUSPLUS_INDIVIDUALMINIPROJECTCPP_INCLUDE_ROUTECONTROLLER_H_ +#define _USERS_VIRGILEMISON_DOCUMENTS_COLUMBIA_FALL24_ADV_SWE_4156_MINIPROJECT_2024_STUDENTS_CPLUSPLUS_INDIVIDUALMINIPROJECTCPP_INCLUDE_ROUTECONTROLLER_H_ -#include "crow.h" +#include "../external_libraries/Crow-1.2.0/include/crow.h" #include "Globals.h" #include "MyFileDatabase.h" class RouteController { - private: + private: MyFileDatabase* myFileDatabase; - public: - void initRoutes(crow::App<>& app); + public: + void initRoutes(const crow::App<>& app); void setDatabase(MyFileDatabase* db); - void index(crow::response& res); - void retrieveDepartment(const crow::request& req, crow::response& res); - void retrieveCourse(const crow::request& req, crow::response& res); - void isCourseFull(const crow::request& req, crow::response& res); - void getMajorCountFromDept(const crow::request& req, crow::response& res); - void identifyDeptChair(const crow::request& req, crow::response& res); - void findCourseLocation(const crow::request& req, crow::response& res); - void findCourseInstructor(const crow::request& req, crow::response& res); - void findCourseTime(const crow::request& req, crow::response& res); - void addMajorToDept(const crow::request& req, crow::response& res); - void removeMajorFromDept(const crow::request& req, crow::response& res); - void setEnrollmentCount(const crow::request& req, crow::response& res); - void setCourseLocation(const crow::request& req, crow::response& res); - void setCourseInstructor(const crow::request& req, crow::response& res); - void setCourseTime(const crow::request& req, crow::response& res); - void dropStudentFromCourse(const crow::request&, crow::response& res); + void index(const crow::response& res); + void retrieveDepartment(const crow::request& req, const crow::response& res); + void retrieveCourse(const crow::request& req, const crow::response& res); + void isCourseFull(const crow::request& req, const crow::response& res); + void getMajorCountFromDept(const crow::request& req, const crow::response& res); + void identifyDeptChair(const crow::request& req, const crow::response& res); + void findCourseLocation(const crow::request& req, const crow::response& res); + void findCourseInstructor(const crow::request& req, const crow::response& res); + void findCourseTime(const crow::request& req, const crow::response& res); + void addMajorToDept(const crow::request& req, const crow::response& res); + void removeMajorFromDept(const crow::request& req, const crow::response& res); + void setEnrollmentCount(const crow::request& req, const crow::response& res); + void setCourseLocation(const crow::request& req, const crow::response& res); + void setCourseInstructor(const crow::request& req, const crow::response& res); + void setCourseTime(const crow::request& req, const crow::response& res); + void dropStudentFromCourse(const crow::request&, const crow::response& res); }; -#endif +#endif // _USERS_VIRGILEMISON_DOCUMENTS_COLUMBIA_FALL24_ADV_SWE_4156_MINIPROJECT_2024_STUDENTS_CPLUSPLUS_INDIVIDUALMINIPROJECTCPP_INCLUDE_ROUTECONTROLLER_H_" diff --git a/IndividualMiniprojectC++/src/Course.cpp b/IndividualMiniprojectC++/src/Course.cpp index d2eb5aa12..29b9178d0 100644 --- a/IndividualMiniprojectC++/src/Course.cpp +++ b/IndividualMiniprojectC++/src/Course.cpp @@ -1,8 +1,8 @@ +// Copyright 2024 vcm2114 #include "Course.h" #include #include - /** * Constructs a new Course object with the given parameters. Initial count starts at 0. * @@ -11,15 +11,18 @@ * @param timeSlot The time slot of the course. * @param capacity The maximum number of students that can enroll in the course. */ -Course::Course(int capacity, const std::string& instructorName, const std::string& courseLocation, const std::string& timeSlot) - : enrollmentCapacity(capacity), enrolledStudentCount(500), courseLocation(courseLocation), instructorName(instructorName), courseTimeSlot(timeSlot) {} +Course::Course(int capacity, const std::string &instructorName, + const std::string &courseLocation, const std::string &timeSlot) + : enrollmentCapacity(capacity), enrolledStudentCount(500), + courseLocation(courseLocation), instructorName(instructorName), + courseTimeSlot(timeSlot) {} /** * Constructs a default Course object with the default parameters. * */ -Course::Course() : enrollmentCapacity(0), enrolledStudentCount(0), courseLocation(""), instructorName(""), courseTimeSlot("") {} - +Course::Course() : enrollmentCapacity(0), enrolledStudentCount(0), +courseLocation(""), instructorName(""), courseTimeSlot("") {} /** * Enrolls a student in the course if there is space available. @@ -28,7 +31,7 @@ Course::Course() : enrollmentCapacity(0), enrolledStudentCount(0), courseLocatio */ bool Course::enrollStudent() { enrolledStudentCount++; - return false; + return false; } /** @@ -38,11 +41,11 @@ bool Course::enrollStudent() { */ bool Course::dropStudent() { enrolledStudentCount--; - return false; + return false; } std::string Course::getCourseLocation() const { - return courseLocation; + return courseLocation; } std::string Course::getInstructorName() const { @@ -57,17 +60,17 @@ std::string Course::display() const { return "\nInstructor: " + instructorName + "; Location: " + courseLocation + "; Time: " + courseTimeSlot; } -void Course::reassignInstructor(const std::string& newInstructorName) { +void Course::reassignInstructor(const std::string &newInstructorName) { std::cout << "Old Instructor: " << instructorName << std::endl; - this->instructorName = newInstructorName; // Ensure the class member is being updated + this->instructorName = newInstructorName; // Ensure the class member is being updated std::cout << "New Instructor: " << this->instructorName << std::endl; } -void Course::reassignLocation(const std::string& newLocation) { +void Course::reassignLocation(const std::string &newLocation) { courseLocation = newLocation; } -void Course::reassignTime(const std::string& newTime) { +void Course::reassignTime(const std::string &newTime) { courseTimeSlot = newTime; } @@ -79,39 +82,39 @@ bool Course::isCourseFull() const { return enrollmentCapacity > enrolledStudentCount; } -void Course::serialize(std::ostream& out) const { - out.write(reinterpret_cast(&enrollmentCapacity), sizeof(enrollmentCapacity)); - out.write(reinterpret_cast(&enrolledStudentCount), sizeof(enrolledStudentCount)); +void Course::serialize(std::ostream &out) const { + out.write(reinterpret_cast(&enrollmentCapacity), sizeof(enrollmentCapacity)); + out.write(reinterpret_cast(&enrolledStudentCount), sizeof(enrolledStudentCount)); size_t locationLen = courseLocation.length(); - out.write(reinterpret_cast(&locationLen), sizeof(locationLen)); + out.write(reinterpret_cast(&locationLen), sizeof(locationLen)); out.write(courseLocation.c_str(), locationLen); size_t instructorLen = instructorName.length(); - out.write(reinterpret_cast(&instructorLen), sizeof(instructorLen)); + out.write(reinterpret_cast(&instructorLen), sizeof(instructorLen)); out.write(instructorName.c_str(), instructorLen); size_t timeSlotLen = courseTimeSlot.length(); - out.write(reinterpret_cast(&timeSlotLen), sizeof(timeSlotLen)); + out.write(reinterpret_cast(&timeSlotLen), sizeof(timeSlotLen)); out.write(courseTimeSlot.c_str(), timeSlotLen); } -void Course::deserialize(std::istream& in) { - in.read(reinterpret_cast(&enrollmentCapacity), sizeof(enrollmentCapacity)); - in.read(reinterpret_cast(&enrolledStudentCount), sizeof(enrolledStudentCount)); +void Course::deserialize(std::istream &in) { + in.read(reinterpret_cast(&enrollmentCapacity), sizeof(enrollmentCapacity)); + in.read(reinterpret_cast(&enrolledStudentCount), sizeof(enrolledStudentCount)); size_t locationLen; - in.read(reinterpret_cast(&locationLen), sizeof(locationLen)); + in.read(reinterpret_cast(&locationLen), sizeof(locationLen)); courseLocation.resize(locationLen); in.read(&courseLocation[0], locationLen); size_t instructorLen; - in.read(reinterpret_cast(&instructorLen), sizeof(instructorLen)); + in.read(reinterpret_cast(&instructorLen), sizeof(instructorLen)); instructorName.resize(instructorLen); in.read(&instructorName[0], instructorLen); size_t timeSlotLen; - in.read(reinterpret_cast(&timeSlotLen), sizeof(timeSlotLen)); + in.read(reinterpret_cast(&timeSlotLen), sizeof(timeSlotLen)); courseTimeSlot.resize(timeSlotLen); in.read(&courseTimeSlot[0], timeSlotLen); } diff --git a/IndividualMiniprojectC++/src/Department.cpp b/IndividualMiniprojectC++/src/Department.cpp index f4aa51860..e2b80a9ee 100644 --- a/IndividualMiniprojectC++/src/Department.cpp +++ b/IndividualMiniprojectC++/src/Department.cpp @@ -1,3 +1,4 @@ +// Copyright 2024 vcm2114 #include "Department.h" #include "Course.h" #include @@ -35,7 +36,7 @@ int Department::getNumberOfMajors() const { * @return The name of the department chair. */ std::string Department::getDepartmentChair() const { - return "departmentChair"; + return "departmentChair"; } /** @@ -82,7 +83,8 @@ void Department::addCourse(std::string courseId, std::shared_ptr course) */ void Department::createCourse(std::string courseId, std::string instructorName, std::string courseLocation, std::string courseTimeSlot, int capacity) { - std::shared_ptr newCourse = std::make_shared(capacity, instructorName, courseLocation, courseTimeSlot); + std::shared_ptr newCourse = std::make_shared(capacity, instructorName, + courseLocation, courseTimeSlot); addCourse(courseId, newCourse); } @@ -96,7 +98,7 @@ std::string Department::display() const { for (const auto& it : courses) { result << deptCode << " " << it.first << ": " << it.second->display() << "\n"; } - return result.str(); + return result.str(); } void Department::serialize(std::ostream& out) const { diff --git a/IndividualMiniprojectC++/src/Globals.cpp b/IndividualMiniprojectC++/src/Globals.cpp index ebf157ff8..1b7c329e2 100644 --- a/IndividualMiniprojectC++/src/Globals.cpp +++ b/IndividualMiniprojectC++/src/Globals.cpp @@ -1,3 +1,4 @@ +// Copyright 2024 vcm2114 #include "Globals.h" -MyFileDatabase* globalDatabase = nullptr; \ No newline at end of file +MyFileDatabase* globalDatabase = nullptr; diff --git a/IndividualMiniprojectC++/src/MyApp.cpp b/IndividualMiniprojectC++/src/MyApp.cpp index a815436d2..258989179 100644 --- a/IndividualMiniprojectC++/src/MyApp.cpp +++ b/IndividualMiniprojectC++/src/MyApp.cpp @@ -1,3 +1,4 @@ +// Copyright 2024 vcm2114 #include "MyApp.h" #include diff --git a/IndividualMiniprojectC++/src/MyFileDatabase.cpp b/IndividualMiniprojectC++/src/MyFileDatabase.cpp index 034049f92..a74d1db92 100644 --- a/IndividualMiniprojectC++/src/MyFileDatabase.cpp +++ b/IndividualMiniprojectC++/src/MyFileDatabase.cpp @@ -1,3 +1,4 @@ +// Copyright 2024 vcm2114 #include "MyFileDatabase.h" #include #include @@ -64,7 +65,7 @@ void MyFileDatabase::deSerializeObjectFromFile() { inFile.read(reinterpret_cast(&keyLen), sizeof(keyLen)); std::string key(keyLen, ' '); inFile.read(&key[0], keyLen); - Department dept; + Department dept; dept.deserialize(inFile); departmentMapping[key] = dept; } diff --git a/IndividualMiniprojectC++/src/RouteController.cpp b/IndividualMiniprojectC++/src/RouteController.cpp index c183c2a79..1a95926e8 100644 --- a/IndividualMiniprojectC++/src/RouteController.cpp +++ b/IndividualMiniprojectC++/src/RouteController.cpp @@ -1,11 +1,12 @@ -#include "RouteController.h" -#include "Globals.h" -#include "MyFileDatabase.h" -#include "crow.h" +// Copyright 2024 vcm2114 #include #include #include #include +#include "RouteController.h" +#include "Globals.h" +#include "MyFileDatabase.h" +#include "../external_libraries/Crow-1.2.0/include/crow.h" // Utility function to handle exceptions crow::response handleException(const std::exception& e) { @@ -44,7 +45,7 @@ void RouteController::retrieveDepartment(const crow::request& req, crow::respons res.write("Department Not Found"); } else { res.code = 200; - res.write(it->second.display()); // Use dot operator to access method + res.write(it->second.display()); // Use dot operator to access method } res.end(); } catch (const std::exception& e) { @@ -86,7 +87,7 @@ void RouteController::retrieveCourse(const crow::request& req, crow::response& r res.write("Course Not Found"); } else { res.code = 200; - res.write(courseIt->second->display()); // Use dot operator to access method + res.write(courseIt->second->display()); // Use dot operator to access method } } res.end(); @@ -129,7 +130,7 @@ void RouteController::isCourseFull(const crow::request& req, crow::response& res } else { auto course = courseIt->second; res.code = 200; - res.write(course->isCourseFull() ? "true" : "false"); // Use dot operator to call method + res.write(course->isCourseFull() ? "true" : "false"); // Use dot operator to call method } } res.end(); @@ -160,7 +161,8 @@ void RouteController::getMajorCountFromDept(const crow::request& req, crow::resp res.write("Department Not Found"); } else { res.code = 200; - res.write("There are: " + std::to_string(deptIt->second.getNumberOfMajors()) + " majors in the department"); // Use dot operator to call method + res.write("There are: " + std::to_string(deptIt->second.getNumberOfMajors()) + + " majors in the department"); // Use dot operator to call method } res.end(); } catch (const std::exception& e) { @@ -190,7 +192,8 @@ void RouteController::identifyDeptChair(const crow::request& req, crow::response res.write("Department Not Found"); } else { res.code = 200; - res.write(deptIt->second.getDepartmentChair() + " is the department chair."); // Use dot operator to call method + res.write(deptIt->second.getDepartmentChair() + + " is the department chair."); // Use dot operator to call method } res.end(); } catch (const std::exception& e) { @@ -232,7 +235,8 @@ void RouteController::findCourseLocation(const crow::request& req, crow::respons } else { auto course = courseIt->second; res.code = 200; - res.write(course->getCourseLocation() + " is where the course is located."); // Use dot operator to call method + res.write(course->getCourseLocation() + + " is where the course is located."); // Use dot operator to call method } } res.end(); @@ -275,7 +279,8 @@ void RouteController::findCourseInstructor(const crow::request& req, crow::respo } else { auto course = courseIt->second; res.code = 200; - res.write(course->getInstructorName() + " is the instructor for the course."); // Use dot operator to call method + res.write(course->getInstructorName() + + " is the instructor for the course."); // Use dot operator to call method } } res.end(); @@ -318,7 +323,7 @@ void RouteController::findCourseTime(const crow::request& req, crow::response& r } else { auto course = courseIt->second; res.code = 200; - res.write("The course meets at: " + course->getCourseTimeSlot()); + res.write("The course meets at: " + course->getCourseTimeSlot()); } } res.end(); @@ -347,7 +352,7 @@ void RouteController::addMajorToDept(const crow::request& req, crow::response& r res.code = 404; res.write("Department Not Found"); } else { - deptIt->second.addPersonToMajor(); // Use dot operator to call method + deptIt->second.addPersonToMajor(); // Use dot operator to call method res.code = 200; res.write("Attribute was updated successfully"); } @@ -428,7 +433,7 @@ void RouteController::setCourseInstructor(const crow::request& req, crow::respon auto instructor = req.url_params.get("instructor"); int courseCode = std::stoi(courseCodeStr); - + auto departmentMapping = myFileDatabase->getDepartmentMapping(); auto deptIt = departmentMapping.find(deptCode); @@ -551,10 +556,10 @@ void RouteController::dropStudentFromCourse(const crow::request& req, crow::resp bool isStudentDropped = courseIt->second->dropStudent(); if (isStudentDropped) { res.code = 200; - res.write("Student has been dropped"); + res.write("Student has been dropped"); } else { res.code = 400; - res.write("Student has not been dropped"); + res.write("Student has not been dropped"); } } } diff --git a/IndividualMiniprojectC++/src/main.cpp b/IndividualMiniprojectC++/src/main.cpp index bdce13c03..08370be2a 100644 --- a/IndividualMiniprojectC++/src/main.cpp +++ b/IndividualMiniprojectC++/src/main.cpp @@ -1,14 +1,15 @@ -#include "crow.h" +// Copyright 2024 vcm2114 +#include +#include +#include +#include +#include "../external_libraries/Crow-1.2.0/include/crow.h" #include "Course.h" #include "Department.h" #include "MyFileDatabase.h" #include "RouteController.h" #include "Globals.h" #include "MyApp.h" -#include -#include -#include -#include /** * Method to handle proper termination protocols @@ -16,7 +17,7 @@ void signalHandler(int signal) { if (signal == SIGINT || signal == SIGTERM) { MyApp::onTermination(); - std::exit(signal); + std::exit(signal); } } @@ -31,7 +32,7 @@ int main(int argc, char* argv[]) { app.signal_clear(); std::signal(SIGINT, signalHandler); std::signal(SIGTERM, signalHandler); - + RouteController routeController; routeController.initRoutes(app); routeController.setDatabase(MyApp::getDatabase()); diff --git a/IndividualMiniprojectC++/test/CourseUnitTests.cpp b/IndividualMiniprojectC++/test/CourseUnitTests.cpp index eb2e2d5f7..6d00fe7a0 100644 --- a/IndividualMiniprojectC++/test/CourseUnitTests.cpp +++ b/IndividualMiniprojectC++/test/CourseUnitTests.cpp @@ -1,8 +1,9 @@ +// Copyright 2024 vcm2114 #include -#include "Course.h" +#include "Course.h" class CourseUnitTests : public ::testing::Test { -protected: + protected: static Course* testCourse; static void SetUpTestSuite() { diff --git a/IndividualMiniprojectC++/test/sample.cpp b/IndividualMiniprojectC++/test/sample.cpp index 5a57e138f..4f536917f 100644 --- a/IndividualMiniprojectC++/test/sample.cpp +++ b/IndividualMiniprojectC++/test/sample.cpp @@ -1,3 +1,4 @@ +// Copyright 2024 vcm2114 #include // Demonstrate some basic assertions.