Add function headers in models

This commit is contained in:
Tinu Johnson
2026-04-17 10:26:33 +05:30
parent 133785dd3f
commit a0c499d78f
9 changed files with 79 additions and 33 deletions
+51 -11
View File
@@ -105,6 +105,16 @@ const leaveMap& Employee::getEmployeeLeaves() const
return m_leaves; return m_leaves;
} }
Enums::EmployeeType Employee::getEmployeeType() const
{
return m_employeeType;
}
std::string Employee::getHeaders()
{
return "EmployeeId,Email,Name,Phone,Password,TeamID,TeamStatus,AccountStatus,EmployeeType";
}
void Employee::setEmployeeId(const std::string& id) void Employee::setEmployeeId(const std::string& id)
{ {
m_id = id; m_id = id;
@@ -145,6 +155,14 @@ void Employee::setEmployeePayroll(Payroll* payroll)
m_payroll = payroll; m_payroll = payroll;
} }
/*
* Function: addPayslip
* Description : Adds a payslip to the employee's payslip records
* Parameters :
payslip - Pointer to the Payslip object to be added
* Returns :
void
*/
void Employee::addPayslip(Payslip* payslip) void Employee::addPayslip(Payslip* payslip)
{ {
if (payslip) if (payslip)
@@ -153,6 +171,14 @@ void Employee::addPayslip(Payslip* payslip)
} }
} }
/*
* Function: addAttendance
* Description: Adds an attendance record to the employee's attendance history
* Parameters:
* attendance - Pointer to the Attendance object containing login information
* Returns:
* void
*/
void Employee::addAttendance(Attendance* attendance) void Employee::addAttendance(Attendance* attendance)
{ {
if (attendance) if (attendance)
@@ -161,6 +187,14 @@ void Employee::addAttendance(Attendance* attendance)
} }
} }
/*
* Function: addLeave
* Description: Adds a leave record to the employee's leave history
* Parameters:
* leave - Pointer to the Leave object to be added
* Returns:
* void
*/
void Employee::addLeave(Leave* leave) void Employee::addLeave(Leave* leave)
{ {
if (leave) if (leave)
@@ -169,11 +203,14 @@ void Employee::addLeave(Leave* leave)
} }
} }
Enums::EmployeeType Employee::getEmployeeType() const /*
{ * Function: serialize
return m_employeeType; * Description: Serializes the employee object's core details into a comma-separated string
} * Parameters:
None
* Returns:
A string containing serialized employee data in CSV format
*/
std::string Employee::serialize() const std::string Employee::serialize() const
{ {
std::ostringstream serializedEmployee; std::ostringstream serializedEmployee;
@@ -189,6 +226,14 @@ std::string Employee::serialize() const
return serializedEmployee.str(); return serializedEmployee.str();
} }
/*
* Function: deserialize
* Description: Creates and returns an Employee object from a serialized comma-separated record string
* Parameters:
record - A string containing serialized employee data in CSV format
* Returns:
Pointer to a newly created Employee object based on the employee type
*/
Employee* Employee::deserialize(const std::string& record) Employee* Employee::deserialize(const std::string& record)
{ {
std::string id, name, phone, password, email; std::string id, name, phone, password, email;
@@ -279,9 +324,4 @@ Employee* Employee::deserialize(const std::string& record)
default: default:
return nullptr; return nullptr;
} }
} }
std::string Employee::getHeaders()
{
return "EmployeeId,Email,Name,Phone,Password,TeamID,TeamStatus,AccountStatus,EmployeeType";
}
+1 -1
View File
@@ -4,4 +4,4 @@
* Author: Trenser * Author: Trenser
* Created: 02-Apr-2026 * Created: 02-Apr-2026
*/ */
#include "Faq.h" #include "Faq.h"
+1 -2
View File
@@ -8,5 +8,4 @@
class Faq class Faq
{ {
}; };
@@ -35,5 +35,4 @@ public:
Enums::EmployeeType::FINANCE, Enums::EmployeeType::FINANCE,
accountStatus) {} accountStatus) {}
~FinanceExecutive() = default; ~FinanceExecutive() = default;
}; };
@@ -13,11 +13,24 @@ Enums::EmployeeDesignation GeneralEmployee::getDesignation() const
return m_designation; return m_designation;
} }
std::string GeneralEmployee::getHeaders()
{
return "EmployeeId,Email,Name,Phone,Password,TeamID,TeamStatus,AccountStatus,EmployeeType,EmployeeDesignation";
}
void GeneralEmployee::setDesignation(Enums::EmployeeDesignation designation) void GeneralEmployee::setDesignation(Enums::EmployeeDesignation designation)
{ {
m_designation = designation; m_designation = designation;
} }
/*
* Function: serialize
* Description: Serializes the general employee's details, including designation, into a comma-separated string
* Parameters:
None
* Returns:
A string containing serialized general employee data in CSV format
*/
std::string GeneralEmployee::serialize() const std::string GeneralEmployee::serialize() const
{ {
std::ostringstream serializedEmployee; std::ostringstream serializedEmployee;
@@ -34,6 +47,14 @@ std::string GeneralEmployee::serialize() const
return serializedEmployee.str(); return serializedEmployee.str();
} }
/*
* Function: deserialize
* Description: Creates and returns a GeneralEmployee object from a serialized comma-separated record string
* Parameters:
record - A string containing serialized general employee data in CSV format
* Returns:
Pointer to a newly created GeneralEmployee object
*/
GeneralEmployee* GeneralEmployee::deserialize(const std::string& record) GeneralEmployee* GeneralEmployee::deserialize(const std::string& record)
{ {
std::string id, name, phone, password, email; std::string id, name, phone, password, email;
@@ -64,9 +85,4 @@ GeneralEmployee* GeneralEmployee::deserialize(const std::string& record)
employeeDesignation, employeeDesignation,
accountStatus accountStatus
); );
}
std::string GeneralEmployee::getHeaders()
{
return "EmployeeId,Email,Name,Phone,Password,TeamID,TeamStatus,AccountStatus,EmployeeType,EmployeeDesignation";
} }
@@ -4,4 +4,4 @@
* Author: Trenser * Author: Trenser
* Created: 31-Mar-2026 * Created: 31-Mar-2026
*/ */
#include "HRManager.h" #include "HRManager.h"
@@ -35,5 +35,4 @@ public:
Enums::EmployeeType::HR, Enums::EmployeeType::HR,
accountStatus) {} accountStatus) {}
~HRManager() = default; ~HRManager() = default;
}; };
@@ -35,5 +35,4 @@ public:
Enums::EmployeeType::IT, Enums::EmployeeType::IT,
accountStatus) {} accountStatus) {}
~ITExecutive() = default; ~ITExecutive() = default;
}; };
+1 -7
View File
@@ -86,10 +86,4 @@ void Leave::setNumberOfMedicalLeave(int value)
void Leave::setLeaveType(Enums::LeaveType type) void Leave::setLeaveType(Enums::LeaveType type)
{ {
m_leaveType = type; m_leaveType = type;
} }
int Leave::m_numberOfGeneralLeave = 12;
int Leave::m_numberOfRestrictedLeave = 2;
int Leave::m_numberOfMedicalLeave = 6;