From a8d50c29f8d29a4fdb2eec28959d674fbd9ce82f Mon Sep 17 00:00:00 2001 From: Joel Mathew Thomas Date: Fri, 17 Apr 2026 10:27:27 +0530 Subject: [PATCH] Add function headers in Controller, DataStore, and Utilities --- .../controllers/ZenvyController.cpp | 130 ++++++++++++++- .../Trenser.Zenvy/datastores/DataStore.cpp | 47 ++++-- .../Trenser.Zenvy/factories/Factory.h | 22 +-- Trenser.Zenvy/Trenser.Zenvy/utilities/Enums.h | 157 ++++++++++++++---- .../Trenser.Zenvy/utilities/InputHelper.h | 4 - .../Trenser.Zenvy/utilities/OutputHelper.cpp | 2 - .../Trenser.Zenvy/utilities/OutputHelper.h | 1 - .../Trenser.Zenvy/utilities/StringHelper.cpp | 16 +- .../Trenser.Zenvy/utilities/StringHelper.h | 6 + .../Trenser.Zenvy/utilities/Timestamp.cpp | 56 ++++--- .../Trenser.Zenvy/utilities/Timestamp.h | 1 - .../Trenser.Zenvy/utilities/Validator.cpp | 57 +++++-- 12 files changed, 390 insertions(+), 109 deletions(-) diff --git a/Trenser.Zenvy/Trenser.Zenvy/controllers/ZenvyController.cpp b/Trenser.Zenvy/Trenser.Zenvy/controllers/ZenvyController.cpp index e4d91bb..26e3df4 100644 --- a/Trenser.Zenvy/Trenser.Zenvy/controllers/ZenvyController.cpp +++ b/Trenser.Zenvy/Trenser.Zenvy/controllers/ZenvyController.cpp @@ -4,7 +4,6 @@ * Author: Trenser * Created : 01-Apr-2026 */ - #include "ZenvyController.h" /* @@ -25,14 +24,13 @@ AuthenticationDTO ZenvyController::login(const std::string& email, const std::st } /* - * Function: changePassword - * Description: updates the password of the currently authenticated employee. + * Function: logout + * Description: logs out the currently authenticated employee * Parameters: - * password - the new password to be set for the employee + * None * Returns: * void - no return value */ - void ZenvyController::logout() { m_authenticationManagementService->logout(); @@ -40,65 +38,153 @@ void ZenvyController::logout() /* * Function: changePassword - * Description: updates the password of the currently authenticated employee. + * Description: updates the password of the currently authenticated employee * Parameters: * password - the new password to be set for the employee * Returns: * void - no return value */ - void ZenvyController::changePassword(const std::string& password) { m_authenticationManagementService->changePassword(password); } -//Employee Management +/* + * Function: createEmployee + * Description: creates a new employee with the given details + * Parameters: + * employeeType - type of employee to be created + * employeeDesignation - designation of the employee + * email - email address of the employee + * name - name of the employee + * phone - phone number of the employee + * Returns: + * void - no return value + */ void ZenvyController::createEmployee(Enums::EmployeeType employeeType, Enums::EmployeeDesignation employeeDesignation, const std::string& email, const std::string& name, const std::string& phone) const { m_employeeManagementService->createEmployee(employeeType, employeeDesignation, email, name, phone); } +/* + * Function: deactivateEmployee + * Description: deactivates an employee based on employee ID + * Parameters: + * id - unique employee ID + * Returns: + * bool - true if deactivated successfully, false otherwise + */ bool ZenvyController::deactivateEmployee(const std::string& id) const { return m_employeeManagementService->deactivateEmployee(id); } +/* + * Function: updateProfile + * Description: updates the profile of the currently authenticated employee + * Parameters: + * name - updated name of the employee + * phone - updated phone number + * Returns: + * void - no return value + */ void ZenvyController::updateProfile(const std::string& name, const std::string& phone) { m_employeeManagementService->updateProfile(name, phone); } +/* + * Function: searchEmployee + * Description: searches employees based on name + * Parameters: + * name - name or partial name of the employee + * Returns: + * Pair of employee type and list of matching employees + */ std::pair> ZenvyController::searchEmployee(const std::string& name) { return m_employeeManagementService->searchEmployee(name); } +/* + * Function: getCurrentEmployee + * Description: retrieves the currently authenticated employee + * Parameters: + * None + * Returns: + * Pointer to the authenticated employee + */ const Employee* ZenvyController::getCurrentEmployee() const { return m_employeeManagementService->getCurrentEmployee(); } +/* + * Function: updateDesignation + * Description: updates the designation of an employee + * Parameters: + * id - unique employee ID + * designation - new designation to be assigned + * Returns: + * bool - true if update is successful, false otherwise + */ bool ZenvyController::updateDesignation(const std::string& id, Enums::EmployeeDesignation designation) { return m_employeeManagementService->updateDesignation(id, designation); } +/* + * Function: getShorlistedCandidates + * Description: retrieves the list of shortlisted candidates + * Parameters: + * None + * Returns: + * Vector of shortlisted candidate pointers + */ std::vector ZenvyController::getShorlistedCandidates() const { return m_employeeManagementService->getShorlistedCandidates(); } -//Payslip Management +/* + * Function: updateSalary + * Description: updates salary details of an employee + * Parameters: + * employeeId - unique employee ID + * basicSalary - basic salary amount + * houseRentAllowance - HRA amount + * foodAllowance - food allowance amount + * employeePFContribution - employee PF contribution + * employerPFContribution - employer PF contribution + * Returns: + * void - no return value + */ void ZenvyController::updateSalary(const std::string& employeeId, double basicSalary, double houseRentAllowance, double foodAllowance, double employeePFContribution, double employerPFContribution) { m_payslipManagementService->updateSalary(employeeId, basicSalary, houseRentAllowance, foodAllowance, employeePFContribution, employerPFContribution); } +/* + * Function: generatePayslips + * Description: generates payslips for all eligible employees + * Parameters: + * None + * Returns: + * void - no return value + */ void ZenvyController::generatePayslips() { m_payslipManagementService->generatePayslips(); } +/* + * Function: loadStates + * Description: loads persisted application data into memory + * Parameters: + * None + * Returns: + * void - no return value + */ void ZenvyController::loadStates() { m_employeeManagementService->loadEmployees(); @@ -106,6 +192,14 @@ void ZenvyController::loadStates() m_payslipManagementService->loadPayslips(); } +/* + * Function: persistStates + * Description: saves current application data to storage + * Parameters: + * None + * Returns: + * void - no return value + */ void ZenvyController::persistStates() { m_employeeManagementService->saveEmployees(); @@ -113,11 +207,29 @@ void ZenvyController::persistStates() m_payslipManagementService->savePayslips(); } +/* + * Function: getPayslipForMonth + * Description: retrieves payroll and payslip details for a specific month + * Parameters: + * employeeId - unique employee ID + * year - year of the payslip + * month - month of the payslip + * Returns: + * Pair of payroll and payslip pointers + */ std::pair ZenvyController::getPayslipForMonth(const std::string& employeeId, int year, int month) { return m_payslipManagementService->getPayslipForMonth(employeeId, year, month); } +/* + * Function: ~ZenvyController + * Description: cleans up dynamically allocated service objects + * Parameters: + * None + * Returns: + * void - no return value + */ ZenvyController::~ZenvyController() { delete m_authenticationManagementService; diff --git a/Trenser.Zenvy/Trenser.Zenvy/datastores/DataStore.cpp b/Trenser.Zenvy/Trenser.Zenvy/datastores/DataStore.cpp index 4495e9d..fa5610d 100644 --- a/Trenser.Zenvy/Trenser.Zenvy/datastores/DataStore.cpp +++ b/Trenser.Zenvy/Trenser.Zenvy/datastores/DataStore.cpp @@ -16,7 +16,6 @@ * Returns: * DataStore& - reference to the single DataStore object. */ - DataStore& DataStore::getInstance() { static DataStore dataStore; @@ -31,7 +30,6 @@ DataStore& DataStore::getInstance() * Returns: * logMap& - reference to the log map. */ - logMap& DataStore::getLogs() { return m_logs; @@ -39,13 +37,12 @@ logMap& DataStore::getLogs() /* * Function: getAuthenticatedEmployee - * Description: returns the currently authenticated employee. + * Description: retrieves the currently authenticated employee. * Parameters: * None * Returns: - * std::shared_ptr& - reference to the authenticated employee object. + * Employee*& - reference to the authenticated employee pointer. */ - Employee*& DataStore::getAuthenticatedEmployee() { return m_authenticatedEmployee; @@ -55,11 +52,10 @@ Employee*& DataStore::getAuthenticatedEmployee() * Function: setAuthenticatedEmployee * Description: sets the currently authenticated employee. * Parameters: - * authenticatedEmployee - shared pointer to the employee object to be set as authenticated. + * authenticatedEmployee - pointer to the employee to be set as authenticated. * Returns: * void - no return value. */ - void DataStore::setAuthenticatedEmployee(Employee* authenticatedEmployee) { m_authenticatedEmployee = authenticatedEmployee; @@ -67,33 +63,64 @@ void DataStore::setAuthenticatedEmployee(Employee* authenticatedEmployee) /* * Function: getEmployees - * Description: retrieves the employee map containing all employees. + * Description: retrieves the map containing all employees. * Parameters: * None * Returns: * employeeMap& - reference to the employee map. */ - employeeMap& DataStore::getEmployees() { return m_employees; } +/* + * Function: getPayrolls + * Description: retrieves the map containing all payroll records. + * Parameters: + * None + * Returns: + * payrollMap& - reference to the payroll map. + */ payrollMap& DataStore::getPayrolls() { return m_payrolls; } +/* + * Function: getPayslips + * Description: retrieves the map containing all payslip records. + * Parameters: + * None + * Returns: + * payslipMap& - reference to the payslip map. + */ payslipMap& DataStore::getPayslips() { return m_payslips; } +/* + * Function: getCandidates + * Description: retrieves the map containing all shortlisted candidates. + * Parameters: + * None + * Returns: + * candidateMap& - reference to the candidate map. + */ candidateMap& DataStore::getCandidates() { return m_candidates; } +/* + * Function: ~DataStore + * Description: releases all dynamically allocated objects stored in the DataStore. + * Parameters: + * None + * Returns: + * void - no return value. + */ DataStore::~DataStore() { for (auto& pair : m_employees) @@ -122,4 +149,4 @@ DataStore::~DataStore() } m_candidates.clear(); m_authenticatedEmployee = nullptr; -} +} \ No newline at end of file diff --git a/Trenser.Zenvy/Trenser.Zenvy/factories/Factory.h b/Trenser.Zenvy/Trenser.Zenvy/factories/Factory.h index 15b829d..40eaf40 100644 --- a/Trenser.Zenvy/Trenser.Zenvy/factories/Factory.h +++ b/Trenser.Zenvy/Trenser.Zenvy/factories/Factory.h @@ -1,7 +1,7 @@ /* * File: Factory.h - * Description: Provides a generic factory utility to create shared_ptr instances of objects. - * Author: Ajmal J S + * Description: Provides a generic factory utility to create objects. + * Author: Trenser * Created: 01-Apr-2026 */ @@ -13,17 +13,17 @@ class Factory public: /* - * Function: getObject - * Description: Creates and returns a shared_ptr to an object of type T. - * Parameters: - * T - the type of object to be created - * Args - constructor arguments forwarded to T's constructor - * Returns: - * std::shared_ptr - a shared pointer managing the newly created object - */; + * Function: getObject + * Description: Creates and returns a dynamically allocated object of type T. + * Parameters: + * T - the type of object to be created + * Args - constructor arguments forwarded to T's constructor + * Returns: + * T* - pointer to the newly created object + */ template static T* getObject(Args&&... args) { return new T(std::forward(args)...); } -}; \ No newline at end of file +}; \ No newline at end of file diff --git a/Trenser.Zenvy/Trenser.Zenvy/utilities/Enums.h b/Trenser.Zenvy/Trenser.Zenvy/utilities/Enums.h index 6f939e4..1bef70f 100644 --- a/Trenser.Zenvy/Trenser.Zenvy/utilities/Enums.h +++ b/Trenser.Zenvy/Trenser.Zenvy/utilities/Enums.h @@ -10,19 +10,19 @@ namespace Enums { - enum class AccountStatus + enum class AccountStatus { ACTIVE, INACTIVE }; - enum class TeamStatus + enum class TeamStatus { IN_TEAM, NOT_IN_TEAM }; - enum class CandidateStatus + enum class CandidateStatus { PENDING, SHORTLISTED, @@ -116,6 +116,14 @@ namespace Enums { INVALID }; + /* + * Function: getAccountStatusString + * Description: Converts AccountStatus enum value to string. + * Parameters: + * status - account status enum + * Returns: + * std::string - string representation of status + */ inline std::string getAccountStatusString(AccountStatus status) { switch (status) @@ -129,6 +137,14 @@ namespace Enums { } } + /* + * Function: getEmployeeTypeString + * Description: Converts EmployeeType enum value to string. + * Parameters: + * type - employee type enum + * Returns: + * std::string - string representation of employee type + */ inline std::string getEmployeeTypeString(EmployeeType type) { switch (type) @@ -154,6 +170,14 @@ namespace Enums { } } + /* + * Function: getTeamStatusString + * Description: Converts TeamStatus enum value to string. + * Parameters: + * status - team status enum + * Returns: + * std::string - string representation of team status + */ inline std::string getTeamStatusString(TeamStatus status) { switch (status) @@ -167,6 +191,14 @@ namespace Enums { } } + /* + * Function: getEmployeeDesignationString + * Description: Converts EmployeeDesignation enum value to string. + * Parameters: + * designation - employee designation enum + * Returns: + * std::string - string representation of designation + */ inline std::string getEmployeeDesignationString(EmployeeDesignation designation) { switch (designation) @@ -184,9 +216,17 @@ namespace Enums { } } - inline std::string getCandidateStatusString(CandidateStatus status) + /* + * Function: getCandidateStatusString + * Description: Converts CandidateStatus enum value to string. + * Parameters: + * status - candidate status enum + * Returns: + * std::string - string representation of candidate status + */ + inline std::string getCandidateStatusString(CandidateStatus status) { - switch (status) + switch (status) { case CandidateStatus::PENDING: return "Pending"; case CandidateStatus::SHORTLISTED: return "Shortlisted"; @@ -195,41 +235,57 @@ namespace Enums { } } + /* + * Function: getMonthString + * Description: Converts Month enum value to month name. + * Parameters: + * month - month enum + * Returns: + * std::string - month name + */ inline std::string getMonthString(Month month) { switch (month) { - case Month::JANUARY : + case Month::JANUARY: return "January"; - case Month::FEBRUARY: + case Month::FEBRUARY: return "February"; - case Month::MARCH: + case Month::MARCH: return "March"; - case Month::APRIL: + case Month::APRIL: return "April"; - case Month::MAY: + case Month::MAY: return "May"; - case Month::JUNE: + case Month::JUNE: return "June"; - case Month::JULY: + case Month::JULY: return "July"; - case Month::AUGUST: + case Month::AUGUST: return "August"; - case Month::SEPTEMBER: + case Month::SEPTEMBER: return "September"; - case Month::OCTOBER: + case Month::OCTOBER: return "October"; - case Month::NOVEMBER: + case Month::NOVEMBER: return "November"; - case Month::DECEMBER: + case Month::DECEMBER: return "December"; - case Month::INVALID: + case Month::INVALID: return "Invalid Month"; - default: + default: return "Unknown"; } } + /* + * Function: getAccountStatus + * Description: Converts string to AccountStatus enum. + * Parameters: + * input - string representation of account status + * Returns: + * AccountStatus - enum value + */ inline AccountStatus getAccountStatus(const std::string& input) { if (input == "ACTIVE") @@ -243,6 +299,14 @@ namespace Enums { return AccountStatus::INACTIVE; } + /* + * Function: getEmployeeType + * Description: Converts string to EmployeeType enum. + * Parameters: + * input - string representation of employee type + * Returns: + * EmployeeType - enum value + */ inline EmployeeType getEmployeeType(const std::string& input) { if (input == "GENERAL") @@ -276,6 +340,14 @@ namespace Enums { return EmployeeType::INVALID; } + /* + * Function: getTeamStatus + * Description: Converts string to TeamStatus enum. + * Parameters: + * str - string representation of team status + * Returns: + * TeamStatus - enum value + */ inline TeamStatus getTeamStatus(const std::string& str) { if (str == "IN_TEAM") @@ -289,6 +361,14 @@ namespace Enums { return TeamStatus::NOT_IN_TEAM; } + /* + * Function: getEmployeeDesignation + * Description: Converts string to EmployeeDesignation enum. + * Parameters: + * input - string representation of designation + * Returns: + * EmployeeDesignation - enum value + */ inline EmployeeDesignation getEmployeeDesignation(const std::string& input) { if (input == "JUNIOR") @@ -305,39 +385,46 @@ namespace Enums { } return EmployeeDesignation::INVALID; } - + + /* + * Function: getMonth + * Description: Converts integer to Month enum. + * Parameters: + * inputMonth - month number (1–12) + * Returns: + * Month - enum value + */ inline Month getMonth(const int inputMonth) { switch (inputMonth) { - case 1: + case 1: return Month::JANUARY; - case 2: + case 2: return Month::FEBRUARY; - case 3: + case 3: return Month::MARCH; - case 4: + case 4: return Month::APRIL; - case 5: + case 5: return Month::MAY; - case 6: + case 6: return Month::JUNE; - case 7: + case 7: return Month::JULY; - case 8: + case 8: return Month::AUGUST; - case 9: + case 9: return Month::SEPTEMBER; - case 10: + case 10: return Month::OCTOBER; - case 11: + case 11: return Month::NOVEMBER; - case 12: + case 12: return Month::DECEMBER; - default: + default: return Month::INVALID; } } -} - +} \ No newline at end of file diff --git a/Trenser.Zenvy/Trenser.Zenvy/utilities/InputHelper.h b/Trenser.Zenvy/Trenser.Zenvy/utilities/InputHelper.h index 245ea34..eb23b24 100644 --- a/Trenser.Zenvy/Trenser.Zenvy/utilities/InputHelper.h +++ b/Trenser.Zenvy/Trenser.Zenvy/utilities/InputHelper.h @@ -4,7 +4,6 @@ * Author: Smitha * Created: 08-Apr-2026 */ - #pragma once #include #include @@ -21,7 +20,6 @@ namespace util * Returns: * void - throws runtime_error if input is invalid */ - template inline void read(T& value) { @@ -41,7 +39,6 @@ namespace util * Returns: * void - no return value */ - inline void read(std::string& value) { std::getline(std::cin >> std::ws, value); @@ -53,7 +50,6 @@ namespace util * Parameters: None * Returns: void - no return value */ - inline void pressEnter() { std::cout << std::endl; diff --git a/Trenser.Zenvy/Trenser.Zenvy/utilities/OutputHelper.cpp b/Trenser.Zenvy/Trenser.Zenvy/utilities/OutputHelper.cpp index ce37ac4..e113f4f 100644 --- a/Trenser.Zenvy/Trenser.Zenvy/utilities/OutputHelper.cpp +++ b/Trenser.Zenvy/Trenser.Zenvy/utilities/OutputHelper.cpp @@ -4,7 +4,6 @@ * Author: Trenser * Created: 01-04-2026 */ - #include "outputHelper.h" /* @@ -14,7 +13,6 @@ * Returns: * void - no return value */ - void util::clear() { std::cout << "\x1B[2J\x1B[H" << std::flush; diff --git a/Trenser.Zenvy/Trenser.Zenvy/utilities/OutputHelper.h b/Trenser.Zenvy/Trenser.Zenvy/utilities/OutputHelper.h index 08a5b5f..0c17c57 100644 --- a/Trenser.Zenvy/Trenser.Zenvy/utilities/OutputHelper.h +++ b/Trenser.Zenvy/Trenser.Zenvy/utilities/OutputHelper.h @@ -4,7 +4,6 @@ * Author: Trenser * Created: 01-04-2026 */ - #pragma once #include diff --git a/Trenser.Zenvy/Trenser.Zenvy/utilities/StringHelper.cpp b/Trenser.Zenvy/Trenser.Zenvy/utilities/StringHelper.cpp index 00af011..2f32a39 100644 --- a/Trenser.Zenvy/Trenser.Zenvy/utilities/StringHelper.cpp +++ b/Trenser.Zenvy/Trenser.Zenvy/utilities/StringHelper.cpp @@ -1,6 +1,20 @@ +/* + * File: StringHelper.cpp + * Description: Provides functions to help with string manipulation. + * Author: Trenser + * Created: 10-04-2026 +*/ #include "StringHelper.h" #include +/* + * Function: extractNumber + * Description: Extracts and returns the numeric value formed by digits in the input string. + * Parameters: + * input - string containing numeric and non-numeric characters + * Returns: + * int - number extracted from the input string + */ int util::extractNumber(const std::string& input) { int result = 0; @@ -12,4 +26,4 @@ int util::extractNumber(const std::string& input) } } return result; -} +} \ No newline at end of file diff --git a/Trenser.Zenvy/Trenser.Zenvy/utilities/StringHelper.h b/Trenser.Zenvy/Trenser.Zenvy/utilities/StringHelper.h index 12df49a..cc6e74a 100644 --- a/Trenser.Zenvy/Trenser.Zenvy/utilities/StringHelper.h +++ b/Trenser.Zenvy/Trenser.Zenvy/utilities/StringHelper.h @@ -1,3 +1,9 @@ +/* + * File: StringHelper.h + * Description: Provides functions to help with string manipulation. + * Author: Trenser + * Created: 10-04-2026 +*/ #pragma once #include diff --git a/Trenser.Zenvy/Trenser.Zenvy/utilities/Timestamp.cpp b/Trenser.Zenvy/Trenser.Zenvy/utilities/Timestamp.cpp index 6172503..ba581db 100644 --- a/Trenser.Zenvy/Trenser.Zenvy/utilities/Timestamp.cpp +++ b/Trenser.Zenvy/Trenser.Zenvy/utilities/Timestamp.cpp @@ -6,21 +6,19 @@ * Author: Trenser * Created: 01-Apr-2026 */ - #include #include #include #include "Timestamp.h" -/* -* Function: Timestamp -* Description: Default constructor that initializes the timestamp to the current system time. -* Parameters: -* None -* Returns: -* Timestamp object -*/ - + /* + * Function: Timestamp + * Description: Default constructor that initializes the timestamp to the current system time. + * Parameters: + * None + * Returns: + * Timestamp object + */ util::Timestamp::Timestamp() { m_time = std::time(nullptr); @@ -34,7 +32,6 @@ util::Timestamp::Timestamp() * Returns: * Timestamp object */ - util::Timestamp::Timestamp(std::time_t timeValue) { m_time = timeValue; @@ -50,7 +47,6 @@ util::Timestamp::Timestamp(std::time_t timeValue) * Throws: * runtime_error if the string format is invalid */ - util::Timestamp util::Timestamp::fromString(const std::string& timeString) { std::tm timeStruct = {}; @@ -72,7 +68,6 @@ util::Timestamp util::Timestamp::fromString(const std::string& timeString) * Returns: * string - formatted as "YYYY-MM-DD HH:MM:SS" */ - std::string util::Timestamp::toString() const { std::tm timeStruct = {}; @@ -91,7 +86,6 @@ std::string util::Timestamp::toString() const * Returns: * double - duration in seconds */ - double util::Timestamp::getDurationInSeconds(const Timestamp& startTimestamp, const Timestamp& endTimestamp) { return std::difftime(endTimestamp.m_time, startTimestamp.m_time); @@ -105,7 +99,6 @@ double util::Timestamp::getDurationInSeconds(const Timestamp& startTimestamp, co * Returns: * int - date as YYYYMMDD */ - int util::Timestamp::getDateAsInt() const { std::tm timeStruct{}; @@ -116,6 +109,14 @@ int util::Timestamp::getDateAsInt() const return year * 10000 + month * 100 + day; } +/* +* Function: getMonth +* Description: Extracts the month value from the timestamp. +* Parameters: +* None +* Returns: +* int - month value (1 to 12) +*/ int util::Timestamp::getMonth() const { std::tm timeStruct{}; @@ -123,6 +124,14 @@ int util::Timestamp::getMonth() const return timeStruct.tm_mon + 1; } +/* +* Function: getYear +* Description: Extracts the year value from the timestamp. +* Parameters: +* None +* Returns: +* int - year value +*/ int util::Timestamp::getYear() const { std::tm timeStruct{}; @@ -130,6 +139,14 @@ int util::Timestamp::getYear() const return timeStruct.tm_year + 1900; } +/* +* Function: getDay +* Description: Extracts the day value from the timestamp. +* Parameters: +* None +* Returns: +* int - day of the month +*/ int util::Timestamp::getDay() const { std::tm timeStruct{}; @@ -146,7 +163,6 @@ int util::Timestamp::getDay() const * Returns: * double - duration in minutes */ - double util::Timestamp::getDurationInMinutes(const Timestamp& startTimestamp, const Timestamp& endTimestamp) { return getDurationInSeconds(startTimestamp, endTimestamp) / 60.0; @@ -161,7 +177,6 @@ double util::Timestamp::getDurationInMinutes(const Timestamp& startTimestamp, co * Returns: * double - duration in hours */ - double util::Timestamp::getDurationInHours(const Timestamp& startTimestamp, const Timestamp& endTimestamp) { return getDurationInSeconds(startTimestamp, endTimestamp) / 3600.0; @@ -175,7 +190,6 @@ double util::Timestamp::getDurationInHours(const Timestamp& startTimestamp, cons * Returns: * bool - true if current timestamp is earlier */ - bool util::Timestamp::operator<(const Timestamp& other) const { return m_time < other.m_time; @@ -189,7 +203,6 @@ bool util::Timestamp::operator<(const Timestamp& other) const * Returns: * bool - true if current timestamp is later */ - bool util::Timestamp::operator>(const Timestamp& other) const { return m_time > other.m_time; @@ -203,7 +216,6 @@ bool util::Timestamp::operator>(const Timestamp& other) const * Returns: * bool - true if current timestamp is earlier or equal */ - bool util::Timestamp::operator<=(const Timestamp& other) const { return m_time <= other.m_time; @@ -217,7 +229,6 @@ bool util::Timestamp::operator<=(const Timestamp& other) const * Returns: * bool - true if current timestamp is later or equal */ - bool util::Timestamp::operator>=(const Timestamp& other) const { return m_time >= other.m_time; @@ -231,8 +242,7 @@ bool util::Timestamp::operator>=(const Timestamp& other) const * Returns: * bool - true if both timestamps are equal */ - bool util::Timestamp::operator==(const Timestamp& other) const { return m_time == other.m_time; -} +} \ No newline at end of file diff --git a/Trenser.Zenvy/Trenser.Zenvy/utilities/Timestamp.h b/Trenser.Zenvy/Trenser.Zenvy/utilities/Timestamp.h index b55b7a8..56a6a0b 100644 --- a/Trenser.Zenvy/Trenser.Zenvy/utilities/Timestamp.h +++ b/Trenser.Zenvy/Trenser.Zenvy/utilities/Timestamp.h @@ -6,7 +6,6 @@ * Author: Trenser * Created: 01-Apr-2026 */ - #pragma once #include #include diff --git a/Trenser.Zenvy/Trenser.Zenvy/utilities/Validator.cpp b/Trenser.Zenvy/Trenser.Zenvy/utilities/Validator.cpp index f06a860..5b1631c 100644 --- a/Trenser.Zenvy/Trenser.Zenvy/utilities/Validator.cpp +++ b/Trenser.Zenvy/Trenser.Zenvy/utilities/Validator.cpp @@ -11,15 +11,14 @@ #include "Employee.h" #include "ApplicationConfig.h" - /* - * Function: isPhoneNumberValid - * Description: Validates whether the given string is a valid phone number. - * Parameters: - * phoneNumber - string containing the phone number to validate - * Returns: - * bool - true if the phone number is valid (10 digits, all numeric), false otherwise - */ - +/* + * Function: isPhoneNumberValid + * Description: Validates whether the given string is a valid phone number. + * Parameters: + * phoneNumber - string containing the phone number to validate + * Returns: + * bool - true if the phone number is valid (10 digits, all numeric), false otherwise + */ bool util::isPhoneNumberValid(const std::string& phoneNumber) { if (phoneNumber.size() != 10) { @@ -41,7 +40,6 @@ bool util::isPhoneNumberValid(const std::string& phoneNumber) { * Returns: * bool - true if the email contains exactly one '@' character and is not at the start or end, false otherwise */ - bool util::isEmailValid(const std::string& email) { size_t index = email.find('@'); if (index == std::string::npos) @@ -72,7 +70,6 @@ bool util::isEmailValid(const std::string& email) { * - Must contain at least one uppercase letter, one lowercase letter, one digit, and one special character * - Must not contain whitespace */ - bool util::isPasswordValid(const std::string& password) { if (password == Config::Authentication::DEFAULT_PASSWORD) @@ -112,7 +109,16 @@ bool util::isPasswordValid(const std::string& password) return hasUpper && hasLower && hasDigit && hasSpecial; } -bool util::hasActiveEmployeeOfType(Enums::EmployeeType employeeType, const std::map & employees) +/* + * Function: hasActiveEmployeeOfType + * Description: Checks whether there is any active employee of the given employee type. + * Parameters: + * employeeType - the type of employee to check against + * employees - map of employee ID to Employee* objects + * Returns: + * bool - true if an active employee of the given type exists, otherwise false + */ +bool util::hasActiveEmployeeOfType(Enums::EmployeeType employeeType, const std::map& employees) { for (const auto& employeePair : employees) { @@ -125,6 +131,15 @@ bool util::hasActiveEmployeeOfType(Enums::EmployeeType employeeType, const std:: return false; } +/* + * Function: isEmailDuplicate + * Description: Checks if an email already exists among the given employees. + * Parameters: + * email - the email address to check + * employees - map of employee ID to Employee* objects + * Returns: + * bool - true if a duplicate email is found, otherwise false + */ bool util::isEmailDuplicate(const std::string& email, const std::map& employees) { for (const auto& employeePair : employees) @@ -138,6 +153,15 @@ bool util::isEmailDuplicate(const std::string& email, const std::map& employees) { for (const auto& employeePair : employees) @@ -151,6 +175,15 @@ bool util::isPhoneDuplicate(const std::string& phone, const std::map& employees) { for (const auto& employee : employees)