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
+50 -10
View File
@@ -105,6 +105,16 @@ const leaveMap& Employee::getEmployeeLeaves() const
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)
{
m_id = id;
@@ -145,6 +155,14 @@ void Employee::setEmployeePayroll(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)
{
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)
{
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)
{
if (leave)
@@ -169,11 +203,14 @@ void Employee::addLeave(Leave* leave)
}
}
Enums::EmployeeType Employee::getEmployeeType() const
{
return m_employeeType;
}
/*
* Function: serialize
* 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::ostringstream serializedEmployee;
@@ -189,6 +226,14 @@ std::string Employee::serialize() const
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)
{
std::string id, name, phone, password, email;
@@ -280,8 +325,3 @@ Employee* Employee::deserialize(const std::string& record)
return nullptr;
}
}
std::string Employee::getHeaders()
{
return "EmployeeId,Email,Name,Phone,Password,TeamID,TeamStatus,AccountStatus,EmployeeType";
}
-1
View File
@@ -9,4 +9,3 @@
class Faq
{
};
@@ -36,4 +36,3 @@ public:
accountStatus) {}
~FinanceExecutive() = default;
};
@@ -13,11 +13,24 @@ Enums::EmployeeDesignation GeneralEmployee::getDesignation() const
return m_designation;
}
std::string GeneralEmployee::getHeaders()
{
return "EmployeeId,Email,Name,Phone,Password,TeamID,TeamStatus,AccountStatus,EmployeeType,EmployeeDesignation";
}
void GeneralEmployee::setDesignation(Enums::EmployeeDesignation 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::ostringstream serializedEmployee;
@@ -34,6 +47,14 @@ std::string GeneralEmployee::serialize() const
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)
{
std::string id, name, phone, password, email;
@@ -65,8 +86,3 @@ GeneralEmployee* GeneralEmployee::deserialize(const std::string& record)
accountStatus
);
}
std::string GeneralEmployee::getHeaders()
{
return "EmployeeId,Email,Name,Phone,Password,TeamID,TeamStatus,AccountStatus,EmployeeType,EmployeeDesignation";
}
@@ -36,4 +36,3 @@ public:
accountStatus) {}
~HRManager() = default;
};
@@ -36,4 +36,3 @@ public:
accountStatus) {}
~ITExecutive() = default;
};
@@ -87,9 +87,3 @@ void Leave::setLeaveType(Enums::LeaveType type)
{
m_leaveType = type;
}
int Leave::m_numberOfGeneralLeave = 12;
int Leave::m_numberOfRestrictedLeave = 2;
int Leave::m_numberOfMedicalLeave = 6;