Change shared pointers to raw pointers in model classes

This commit is contained in:
Princy Jerin
2026-04-16 18:08:56 +05:30
parent c7b9d7bcd5
commit 703cea447e
30 changed files with 15 additions and 38 deletions
+1 -2
View File
@@ -4,7 +4,6 @@
* Author: Trenser * Author: Trenser
* Created: 31-Mar-2026 * Created: 31-Mar-2026
*/ */
#pragma once #pragma once
#include "Employee.h" #include "Employee.h"
@@ -16,7 +15,7 @@ public:
const std::string& name, const std::string& name,
const std::string& phone, const std::string& phone,
const std::string& email, const std::string& email,
std::shared_ptr<Payroll> payroll Payroll* payroll
) :Employee(name, phone, email, Enums::EmployeeType::ADMIN, payroll) {}; ) :Employee(name, phone, email, Enums::EmployeeType::ADMIN, payroll) {};
Admin(const std::string& id, Admin(const std::string& id,
const std::string& name, const std::string& name,
@@ -189,7 +189,7 @@ std::string Employee::serialize() const
return serializedEmployee.str(); return serializedEmployee.str();
} }
std::shared_ptr<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;
std::string teamId, teamStatusString, accountStatusString, employeeTypeString; std::string teamId, teamStatusString, accountStatusString, employeeTypeString;
@@ -94,7 +94,7 @@ public:
void addLeave(Leave* leave); void addLeave(Leave* leave);
Enums::EmployeeType getEmployeeType() const; Enums::EmployeeType getEmployeeType() const;
virtual std::string serialize() const; virtual std::string serialize() const;
static std::shared_ptr<Employee> deserialize(const std::string&); static Employee* deserialize(const std::string&);
static std::string getHeaders(); static std::string getHeaders();
virtual ~Employee() = default; virtual ~Employee() = default;
}; };
@@ -15,7 +15,7 @@ public:
const std::string& name, const std::string& name,
const std::string& phone, const std::string& phone,
const std::string& email, const std::string& email,
std::shared_ptr<Payroll> payroll Payroll* payroll
) :Employee(name, phone, email, Enums::EmployeeType::FINANCE, payroll) {}; ) :Employee(name, phone, email, Enums::EmployeeType::FINANCE, payroll) {};
FinanceExecutive(const std::string& id, FinanceExecutive(const std::string& id,
const std::string& name, const std::string& name,
@@ -34,7 +34,7 @@ std::string GeneralEmployee::serialize() const
return serializedEmployee.str(); return serializedEmployee.str();
} }
std::shared_ptr<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;
std::string teamId, teamStatusString, accountStatusString, employeeTypeString, employeeDesignationString; std::string teamId, teamStatusString, accountStatusString, employeeTypeString, employeeDesignationString;
@@ -48,7 +48,7 @@ public:
Enums::EmployeeDesignation getDesignation() const; Enums::EmployeeDesignation getDesignation() const;
void setDesignation(Enums::EmployeeDesignation designation); void setDesignation(Enums::EmployeeDesignation designation);
std::string serialize() const override; std::string serialize() const override;
static std::shared_ptr<GeneralEmployee> deserialize(const std::string&); static GeneralEmployee* deserialize(const std::string&);
static std::string getHeaders(); static std::string getHeaders();
~GeneralEmployee() = default; ~GeneralEmployee() = default;
}; };
@@ -15,7 +15,7 @@ public:
const std::string& name, const std::string& name,
const std::string& phone, const std::string& phone,
const std::string& email, const std::string& email,
std::shared_ptr<Payroll> payroll Payroll* payroll
) :Employee(name, phone, email, Enums::EmployeeType::HR, payroll) {}; ) :Employee(name, phone, email, Enums::EmployeeType::HR, payroll) {};
HRManager(const std::string& id, HRManager(const std::string& id,
const std::string& name, const std::string& name,
@@ -15,7 +15,7 @@ public:
const std::string& name, const std::string& name,
const std::string& phone, const std::string& phone,
const std::string& email, const std::string& email,
std::shared_ptr<Payroll> payroll Payroll* payroll
) :Employee(name, phone, email, Enums::EmployeeType::IT, payroll) {}; ) :Employee(name, phone, email, Enums::EmployeeType::IT, payroll) {};
ITExecutive(const std::string& id, ITExecutive(const std::string& id,
const std::string& name, const std::string& name,
@@ -4,7 +4,6 @@ File: JobListing.cpp
* Author : Trenser * Author : Trenser
* Created : 01-Apr-2026 * Created : 01-Apr-2026
*/ */
#include "JobListing.h" #include "JobListing.h"
int JobListing::m_uid = 0; int JobListing::m_uid = 0;
@@ -4,7 +4,6 @@ File: JobListing.h
* Author : Trenser * Author : Trenser
* Created : 01-Apr-2026 * Created : 01-Apr-2026
*/ */
#pragma once #pragma once
#include <string> #include <string>
#include <map> #include <map>
@@ -4,7 +4,6 @@ File: Leave.cpp
* Author : Trenser * Author : Trenser
* Created : 31-Mar-2026 * Created : 31-Mar-2026
*/ */
#include "Leave.h" #include "Leave.h"
int Leave::m_uid = 0; int Leave::m_uid = 0;
@@ -4,7 +4,6 @@ File: Leave.h
* Author : Trenser * Author : Trenser
* Created : 31-Mar-2026 * Created : 31-Mar-2026
*/ */
#pragma once #pragma once
#include <string> #include <string>
#include "Enums.h" #include "Enums.h"
@@ -4,7 +4,6 @@ File: Log.cpp
* Author : Trenser * Author : Trenser
* Created : 01-Apr-2026 * Created : 01-Apr-2026
*/ */
#include "Log.h" #include "Log.h"
//Getters and setters //Getters and setters
-1
View File
@@ -4,7 +4,6 @@ File: Log.h
* Author : Trenser * Author : Trenser
* Created : 01-Apr-2026 * Created : 01-Apr-2026
*/ */
#pragma once #pragma once
#include <string> #include <string>
#include "Timestamp.h" #include "Timestamp.h"
@@ -4,7 +4,6 @@ File: Notification.cpp
* Author : Trenser * Author : Trenser
* Created : 31-Mar-2026 * Created : 31-Mar-2026
*/ */
#include "Notification.h" #include "Notification.h"
int Notification::m_uid = 0; int Notification::m_uid = 0;
@@ -4,7 +4,6 @@ File: Notification.h
* Author : Trenser * Author : Trenser
* Created : 31-Mar-2026 * Created : 31-Mar-2026
*/ */
#pragma once #pragma once
#include <string> #include <string>
#include "Enums.h" #include "Enums.h"
@@ -4,7 +4,6 @@ File: Payroll.cpp
* Author : Trenser * Author : Trenser
* Created : 31-Mar-2026 * Created : 31-Mar-2026
*/ */
#include "Payroll.h" #include "Payroll.h"
#include "StringHelper.h" #include "StringHelper.h"
#include "Factory.h" #include "Factory.h"
@@ -111,7 +110,7 @@ std::string Payroll::serialize() const
return serializedPayroll.str(); return serializedPayroll.str();
} }
std::shared_ptr<Payroll> Payroll::deserialize(const std::string& record) Payroll* Payroll::deserialize(const std::string& record)
{ {
std::string id, employeeId; std::string id, employeeId;
std::string basicSalaryString, houseRentAllowanceString, foodAllowanceString, employeePFString, employerPFString; std::string basicSalaryString, houseRentAllowanceString, foodAllowanceString, employeePFString, employerPFString;
+1 -2
View File
@@ -4,7 +4,6 @@ File: Payroll.h
* Author : Trenser * Author : Trenser
* Created : 31-Mar-2026 * Created : 31-Mar-2026
*/ */
#pragma once #pragma once
#include <string> #include <string>
#include <memory> #include <memory>
@@ -62,6 +61,6 @@ public:
void setEmployeePFContribution(double); void setEmployeePFContribution(double);
void setEmployerPFContribution(double); void setEmployerPFContribution(double);
std::string serialize() const; std::string serialize() const;
static std::shared_ptr<Payroll> deserialize(const std::string&); static Payroll* deserialize(const std::string&);
static std::string getHeaders(); static std::string getHeaders();
}; };
@@ -4,7 +4,6 @@ File: Payslip.cpp
* Author : Trenser * Author : Trenser
* Created : 31-Mar-2026 * Created : 31-Mar-2026
*/ */
#include <sstream> #include <sstream>
#include "Payslip.h" #include "Payslip.h"
#include "StringHelper.h" #include "StringHelper.h"
@@ -68,7 +67,7 @@ std::string Payslip::serialize() const
return serializedPayslip.str(); return serializedPayslip.str();
} }
std::shared_ptr<Payslip> Payslip::deserialize(const std::string& record) Payslip* Payslip::deserialize(const std::string& record)
{ {
std::string id, employeeId, timestampString; std::string id, employeeId, timestampString;
std::string salaryString; std::string salaryString;
+1 -2
View File
@@ -4,7 +4,6 @@ File: Payslip.h
* Author : Trenser * Author : Trenser
* Created : 31-Mar-2026 * Created : 31-Mar-2026
*/ */
#pragma once #pragma once
#include <memory> #include <memory>
#include <string> #include <string>
@@ -32,6 +31,6 @@ public:
const util::Timestamp& getTimestamp() const; const util::Timestamp& getTimestamp() const;
const std::string& getEmployeeId() const; const std::string& getEmployeeId() const;
std::string serialize() const; std::string serialize() const;
static std::shared_ptr<Payslip> deserialize(const std::string&); static Payslip* deserialize(const std::string&);
static std::string getHeaders(); static std::string getHeaders();
}; };
@@ -4,7 +4,6 @@ File: Room.cpp
* Author : Trenser * Author : Trenser
* Created : 31-Mar-2026 * Created : 31-Mar-2026
*/ */
#include "Room.h" #include "Room.h"
int Room::m_uid = 0; int Room::m_uid = 0;
@@ -4,7 +4,6 @@ File: Room.h
* Author : Trenser * Author : Trenser
* Created : 31-Mar-2026 * Created : 31-Mar-2026
*/ */
#pragma once #pragma once
#include <string> #include <string>
#include <map> #include <map>
@@ -4,5 +4,4 @@ File: TalentExecutive.cpp
* Author : Trenser * Author : Trenser
* Created : 31-Mar-2026 * Created : 31-Mar-2026
*/ */
#include "TalentExecutive.h" #include "TalentExecutive.h"
@@ -4,7 +4,6 @@ File: TalentExecutive.h
* Author : Trenser * Author : Trenser
* Created : 31-Mar-2026 * Created : 31-Mar-2026
*/ */
#pragma once #pragma once
#include "Employee.h" #include "Employee.h"
@@ -16,7 +15,7 @@ public:
const std::string& name, const std::string& name,
const std::string& phone, const std::string& phone,
const std::string& email, const std::string& email,
std::shared_ptr<Payroll> payroll Payroll* payroll
) :Employee(name, phone, email, Enums::EmployeeType::TALENT_ACQUISITION, payroll) {}; ) :Employee(name, phone, email, Enums::EmployeeType::TALENT_ACQUISITION, payroll) {};
TalentExecutive(const std::string& id, TalentExecutive(const std::string& id,
const std::string& name, const std::string& name,
@@ -4,7 +4,6 @@ File: Team.cpp
* Author : Trenser * Author : Trenser
* Created : 31-Mar-2026 * Created : 31-Mar-2026
*/ */
#include "Team.h" #include "Team.h"
int Team::m_uid = 0; int Team::m_uid = 0;
@@ -4,7 +4,6 @@ File: Team.h
* Author : Trenser * Author : Trenser
* Created : 31-Mar-2026 * Created : 31-Mar-2026
*/ */
#pragma once #pragma once
#include <string> #include <string>
#include <map> #include <map>
@@ -4,5 +4,4 @@ File: TeamExecutive.cpp
* Author : Trenser * Author : Trenser
* Created : 31-Mar-2026 * Created : 31-Mar-2026
*/ */
#include "TeamExecutive.h" #include "TeamExecutive.h"
@@ -4,7 +4,6 @@ File: TeamExecutive.h
* Author : Trenser * Author : Trenser
* Created : 31-Mar-2026 * Created : 31-Mar-2026
*/ */
#pragma once #pragma once
#include "Employee.h" #include "Employee.h"
@@ -16,7 +15,7 @@ public:
const std::string& name, const std::string& name,
const std::string& phone, const std::string& phone,
const std::string& email, const std::string& email,
std::shared_ptr<Payroll> payroll Payroll* payroll
) :Employee(name, phone, email, Enums::EmployeeType::TEAM, payroll) {}; ) :Employee(name, phone, email, Enums::EmployeeType::TEAM, payroll) {};
TeamExecutive(const std::string& id, TeamExecutive(const std::string& id,
const std::string& name, const std::string& name,
@@ -4,7 +4,6 @@ File: Ticket.cpp
* Author : Trenser * Author : Trenser
* Created : 31-Mar-2026 * Created : 31-Mar-2026
*/ */
#include "Ticket.h" #include "Ticket.h"
int Ticket::m_uid = 0; int Ticket::m_uid = 0;
@@ -4,7 +4,6 @@ File: Ticket.h
* Author : Trenser * Author : Trenser
* Created : 31-Mar-2026 * Created : 31-Mar-2026
*/ */
#pragma once #pragma once
#include <string> #include <string>
#include "Enums.h" #include "Enums.h"