Convert shared pointer to raw pointer

This commit is contained in:
Tinu Johnson
2026-04-10 15:00:31 +05:30
committed by Joel Thomas
parent 7e0becaa3e
commit 75b69f8c11
27 changed files with 145 additions and 133 deletions
@@ -52,3 +52,17 @@ void ZenvyController::changePassword(const std::string& password)
{ {
m_authenticationManagementService->changePassword(password); m_authenticationManagementService->changePassword(password);
} }
ZenvyController::~ZenvyController()
{
delete m_authenticationManagementService;
delete m_attendanceManagementService;
delete m_bookingManagementService;
delete m_employeeManagememtService;
delete m_leaveManagementService;
delete m_notificationManagementService;
delete m_payslipManagementService;
delete m_talentAcquisitionManagementService;
delete m_teamManagementService;
delete m_ticketManagementService;
}
@@ -6,7 +6,6 @@
*/ */
#pragma once #pragma once
#include <memory>
#include <utility> #include <utility>
#include "AuthenticationManagementService.h" #include "AuthenticationManagementService.h"
#include "AttendanceManagementService.h" #include "AttendanceManagementService.h"
@@ -23,31 +22,30 @@
class ZenvyController class ZenvyController
{ {
private: private:
std::shared_ptr<AuthenticationManagementService> m_authenticationManagementService; AuthenticationManagementService* m_authenticationManagementService;
std::shared_ptr<AttendanceManagementService> m_attendanceManagementService; AttendanceManagementService* m_attendanceManagementService;
std::shared_ptr<BookingManagementService> m_bookingManagementService; BookingManagementService* m_bookingManagementService;
std::shared_ptr<EmployeeManagememtService> m_employeeManagememtService; EmployeeManagememtService* m_employeeManagememtService;
std::shared_ptr<LeaveManagementService> m_leaveManagementService; LeaveManagementService* m_leaveManagementService;
std::shared_ptr<NotificationManagementService> m_notificationManagementService; NotificationManagementService* m_notificationManagementService;
std::shared_ptr<PayslipManagementService> m_payslipManagementService; PayslipManagementService* m_payslipManagementService;
std::shared_ptr<TalentAcquisitionManagementService> m_talentAcquisitionManagementService; TalentAcquisitionManagementService* m_talentAcquisitionManagementService;
std::shared_ptr<TeamManagementService> m_teamManagementService; TeamManagementService* m_teamManagementService;
std::shared_ptr<TicketManagementService> m_ticketManagementService; TicketManagementService* m_ticketManagementService;
public: public:
ZenvyController() : ZenvyController() :
m_authenticationManagementService(std::make_shared<AuthenticationManagementService>()), m_authenticationManagementService(new AuthenticationManagementService()),
m_attendanceManagementService(std::make_shared<AttendanceManagementService>()), m_attendanceManagementService(new AttendanceManagementService()),
m_bookingManagementService(std::make_shared<BookingManagementService>()), m_bookingManagementService(new BookingManagementService()),
m_employeeManagememtService(std::make_shared<EmployeeManagememtService>()), m_employeeManagememtService(new EmployeeManagememtService()),
m_leaveManagementService(std::make_shared<LeaveManagementService>()), m_leaveManagementService(new LeaveManagementService()),
m_notificationManagementService(std::make_shared<NotificationManagementService>()), m_notificationManagementService(new NotificationManagementService()),
m_payslipManagementService(std::make_shared<PayslipManagementService>()), m_payslipManagementService(new PayslipManagementService()),
m_talentAcquisitionManagementService(std::make_shared<TalentAcquisitionManagementService>()), m_talentAcquisitionManagementService(new TalentAcquisitionManagementService()),
m_teamManagementService(std::make_shared<TeamManagementService>()), m_teamManagementService(new TeamManagementService()),
m_ticketManagementService(std::make_shared<TicketManagementService>()) {}; m_ticketManagementService(new TicketManagementService()) {};
AuthenticationDTO login(const std::string& email, const std::string& password);
//Authentication void logout();
AuthenticationDTO login(const std::string& email, const std::string& password); void changePassword(const std::string&);
void logout(); ~ZenvyController();
void changePassword(const std::string&);
}; };
@@ -45,7 +45,7 @@ logMap& DataStore::getLogs()
* std::shared_ptr<Employee>& - reference to the authenticated employee object. * std::shared_ptr<Employee>& - reference to the authenticated employee object.
*/ */
std::shared_ptr<Employee>& DataStore::getAuthenticatedEmployee() Employee*& DataStore::getAuthenticatedEmployee()
{ {
return m_authenticatedEmployee; return m_authenticatedEmployee;
} }
@@ -59,7 +59,7 @@ std::shared_ptr<Employee>& DataStore::getAuthenticatedEmployee()
* void - no return value. * void - no return value.
*/ */
void DataStore::setAuthenticatedEmployee(std::shared_ptr<Employee> authenticatedEmployee) void DataStore::setAuthenticatedEmployee(Employee* authenticatedEmployee)
{ {
m_authenticatedEmployee = authenticatedEmployee; m_authenticatedEmployee = authenticatedEmployee;
} }
@@ -87,7 +87,7 @@ employeeMap& DataStore::getEmployees()
* std::shared_ptr<Employee>& - reference to the authenticated employee object. * std::shared_ptr<Employee>& - reference to the authenticated employee object.
*/ */
std::shared_ptr<Employee>& DataStore::getAuthenticatedUser() Employee* DataStore::getAuthenticatedUser()
{ {
return m_authenticatedEmployee; return m_authenticatedEmployee;
} }
@@ -6,7 +6,6 @@
*/ */
#pragma once #pragma once
#include <memory>
#include <map> #include <map>
#include "Employee.h" #include "Employee.h"
#include "Log.h" #include "Log.h"
@@ -26,13 +25,13 @@
#include "Announcement.h" #include "Announcement.h"
#include "Faq.h" #include "Faq.h"
using employeeMap = std::map<std::string, std::shared_ptr<Employee>>; using employeeMap = std::map<std::string,Employee*>;
using logMap = std::map<util::Timestamp, std::shared_ptr<Log>>; using logMap = std::map<util::Timestamp, Log*>;
class DataStore class DataStore
{ {
private: private:
std::shared_ptr<Employee> m_authenticatedEmployee; Employee* m_authenticatedEmployee;
employeeMap m_employees; employeeMap m_employees;
logMap m_logs; logMap m_logs;
DataStore() = default; DataStore() = default;
@@ -43,8 +42,8 @@ public:
DataStore(DataStore&&) = delete; DataStore(DataStore&&) = delete;
DataStore& operator=(DataStore&&) = delete; DataStore& operator=(DataStore&&) = delete;
employeeMap& getEmployees(); employeeMap& getEmployees();
std::shared_ptr<Employee>& getAuthenticatedUser(); Employee* getAuthenticatedUser();
logMap& getLogs(); logMap& getLogs();
std::shared_ptr<Employee>& getAuthenticatedEmployee(); Employee*& getAuthenticatedEmployee();
void setAuthenticatedEmployee(std::shared_ptr < Employee>); void setAuthenticatedEmployee(Employee*);
}; };
@@ -6,7 +6,6 @@
*/ */
#pragma once #pragma once
#include <memory>
#include <utility> #include <utility>
class Factory class Factory
@@ -24,8 +23,8 @@ public:
*/ */
template<typename T, typename... Args> template<typename T, typename... Args>
static std::shared_ptr<T> getObject(Args&&... args) static T* getObject(Args&&... args)
{ {
return std::make_shared<T>(std::forward<Args>(args)...); return T*(std::forward<Args>(args)...);
} }
}; };
@@ -26,7 +26,7 @@ const std::string& Booking::getEmployeeId() const
return m_employeeId; return m_employeeId;
} }
std::shared_ptr<Team> Booking::getTeam() const Team* Booking::getTeam() const
{ {
return m_team; return m_team;
} }
@@ -51,7 +51,7 @@ void Booking::setEmployeeId(const std::string& employeeId)
m_employeeId = employeeId; m_employeeId = employeeId;
} }
void Booking::setTeam(std::shared_ptr<Team> team) void Booking::setTeam(Team* team)
{ {
m_team = team; m_team = team;
} }
+5 -7
View File
@@ -6,7 +6,6 @@
*/ */
#pragma once #pragma once
#include <string> #include <string>
#include <memory>
#include "Team.h" #include "Team.h"
#include "Timestamp.h" #include "Timestamp.h"
@@ -17,25 +16,24 @@ private:
util::Timestamp m_startTime; util::Timestamp m_startTime;
util::Timestamp m_endTime; util::Timestamp m_endTime;
std::string m_employeeId; std::string m_employeeId;
std::shared_ptr<Team> m_team; Team* m_team;
public: public:
Booking() : m_id(""), m_startTime(), m_endTime(), m_employeeId(""), m_team(nullptr) {} Booking() : m_id(""), m_startTime(), m_endTime(), m_employeeId(""), m_team(nullptr) {};
Booking(const std::string& id, Booking(const std::string& id,
const util::Timestamp& startTime, const util::Timestamp& startTime,
const util::Timestamp& endTime, const util::Timestamp& endTime,
const std::string& employeeId, const std::string& employeeId,
std::shared_ptr<Team> team) Team* team) : m_id(id), m_startTime(startTime), m_endTime(endTime), m_employeeId(employeeId), m_team(team) {};
: m_id(id), m_startTime(startTime), m_endTime(endTime), m_employeeId(employeeId), m_team(team) {}
const std::string& getBookingId() const; const std::string& getBookingId() const;
const util::Timestamp& getStartTime() const; const util::Timestamp& getStartTime() const;
const util::Timestamp& getEndTime() const; const util::Timestamp& getEndTime() const;
const std::string& getEmployeeId() const; const std::string& getEmployeeId() const;
std::shared_ptr<Team> getTeam() const; Team* getTeam() const;
void setBookingId(const std::string& id); void setBookingId(const std::string& id);
void setStartTime(const util::Timestamp& startTime); void setStartTime(const util::Timestamp& startTime);
void setEndTime(const util::Timestamp& endTime); void setEndTime(const util::Timestamp& endTime);
void setEmployeeId(const std::string& employeeId); void setEmployeeId(const std::string& employeeId);
void setTeam(std::shared_ptr<Team> team); void setTeam(Team* team);
double getDurationInHours() const; double getDurationInHours() const;
double getDurationInMinutes() const; double getDurationInMinutes() const;
}; };
@@ -46,7 +46,7 @@ const std::string& Employee::getEmployeeTeamId() const
return m_teamId; return m_teamId;
} }
std::shared_ptr<Payroll> Employee::getPayroll() const Payroll* Employee::getPayroll() const
{ {
return m_payroll; return m_payroll;
} }
@@ -101,12 +101,12 @@ void Employee::setEmployeeTeamId(const std::string& teamId)
m_teamId = teamId; m_teamId = teamId;
} }
void Employee::setEmployeePayroll(std::shared_ptr<Payroll> payroll) void Employee::setEmployeePayroll(Payroll* payroll)
{ {
m_payroll = payroll; m_payroll = payroll;
} }
void Employee::addPayslip(std::shared_ptr<Payslip> payslip) void Employee::addPayslip(Payslip* payslip)
{ {
if (payslip) if (payslip)
{ {
@@ -114,7 +114,7 @@ void Employee::addPayslip(std::shared_ptr<Payslip> payslip)
} }
} }
void Employee::addAttendance(std::shared_ptr<Attendance> attendance) void Employee::addAttendance(Attendance* attendance)
{ {
if (attendance) if (attendance)
{ {
@@ -122,7 +122,7 @@ void Employee::addAttendance(std::shared_ptr<Attendance> attendance)
} }
} }
void Employee::addLeave(std::shared_ptr<Leave> leave) void Employee::addLeave(Leave* leave)
{ {
if (leave) if (leave)
{ {
+10 -11
View File
@@ -6,16 +6,15 @@
*/ */
#pragma once #pragma once
#include <string> #include <string>
#include <memory>
#include <map> #include <map>
#include "Payslip.h" #include "Payslip.h"
#include "Attendance.h" #include "Attendance.h"
#include "Leave.h" #include "Leave.h"
#include "Payroll.h" #include "Payroll.h"
#include "Enums.h" #include "Enums.h"
using payslipMap = std::map<std::string, std::shared_ptr<Payslip>>; using payslipMap = std::map<std::string, Payslip*>;
using attendanceMap = std::map<int, std::map<std::string, std::shared_ptr<Attendance>>>; using attendanceMap = std::map<int, std::map<std::string, Attendance*>>;
using leaveMap = std::map<std::string, std::shared_ptr<Leave>>; using leaveMap = std::map<std::string, Leave*>;
class Employee class Employee
{ {
@@ -28,7 +27,7 @@ private:
Enums::AccountStatus m_accountStatus; Enums::AccountStatus m_accountStatus;
Enums::TeamStatus m_teamStatus; Enums::TeamStatus m_teamStatus;
std::string m_teamId; std::string m_teamId;
std::shared_ptr<Payroll> m_payroll; Payroll* m_payroll;
payslipMap m_payslips; payslipMap m_payslips;
attendanceMap m_attendances; attendanceMap m_attendances;
leaveMap m_leaves; leaveMap m_leaves;
@@ -42,7 +41,7 @@ public:
const std::string& email, const std::string& email,
const std::string& teamId, const std::string& teamId,
Enums::EmployeeType employeeType, Enums::EmployeeType employeeType,
std::shared_ptr<Payroll> payroll) Payroll* payroll)
: m_id(id), m_password(password), m_name(name), m_phone(phone), m_email(email), m_accountStatus(Enums::AccountStatus::ACTIVE), m_teamStatus(Enums::TeamStatus::NOT_IN_TEAM), m_teamId(teamId), m_employeeType(employeeType), m_payroll(payroll) { } : m_id(id), m_password(password), m_name(name), m_phone(phone), m_email(email), m_accountStatus(Enums::AccountStatus::ACTIVE), m_teamStatus(Enums::TeamStatus::NOT_IN_TEAM), m_teamId(teamId), m_employeeType(employeeType), m_payroll(payroll) { }
const std::string& getEmployeeId() const; const std::string& getEmployeeId() const;
const std::string& getEmployeePassword() const; const std::string& getEmployeePassword() const;
@@ -52,7 +51,7 @@ public:
Enums::AccountStatus getEmployeeAccountStatus() const; Enums::AccountStatus getEmployeeAccountStatus() const;
Enums::TeamStatus getEmployeeTeamStatus() const; Enums::TeamStatus getEmployeeTeamStatus() const;
const std::string& getEmployeeTeamId() const; const std::string& getEmployeeTeamId() const;
std::shared_ptr<Payroll> getPayroll() const; Payroll* getPayroll() const;
const payslipMap& getEmployeePayslips() const; const payslipMap& getEmployeePayslips() const;
const attendanceMap& getEmployeeAttendances() const; const attendanceMap& getEmployeeAttendances() const;
const leaveMap& getEmployeeLeaves() const; const leaveMap& getEmployeeLeaves() const;
@@ -63,10 +62,10 @@ public:
void setEmployeeAccountStatus(Enums::AccountStatus status); void setEmployeeAccountStatus(Enums::AccountStatus status);
void setEmployeeTeamStatus(Enums::TeamStatus status); void setEmployeeTeamStatus(Enums::TeamStatus status);
void setEmployeeTeamId(const std::string& teamId); void setEmployeeTeamId(const std::string& teamId);
void setEmployeePayroll(std::shared_ptr<Payroll> payroll); void setEmployeePayroll(Payroll* payroll);
void addPayslip(std::shared_ptr<Payslip> payslip); void addPayslip(Payslip* payslip);
void addAttendance(std::shared_ptr<Attendance> attendance); void addAttendance(Attendance* attendance);
void addLeave(std::shared_ptr<Leave> leave); void addLeave(Leave* leave);
Enums::EmployeeType getEmployeeType() const; Enums::EmployeeType getEmployeeType() const;
virtual ~Employee() = default; virtual ~Employee() = default;
}; };
@@ -20,7 +20,7 @@ public:
const std::string& phone, const std::string& phone,
const std::string& email, const std::string& email,
const std::string& teamId, const std::string& teamId,
std::shared_ptr<Payroll> payroll, Payroll* payroll,
Enums::EmployeeDesignation designation) : Employee(id, password, name, phone, email, teamId,Enums::EmployeeType::GENERAL, payroll), m_designation(designation) {} Enums::EmployeeDesignation designation) : Employee(id, password, name, phone, email, teamId,Enums::EmployeeType::GENERAL, payroll), m_designation(designation) {}
Enums::EmployeeDesignation getDesignation() const; Enums::EmployeeDesignation getDesignation() const;
void setDesignation(Enums::EmployeeDesignation designation); void setDesignation(Enums::EmployeeDesignation designation);
@@ -11,7 +11,7 @@ File: JobListing.h
#include <memory> #include <memory>
#include "Candidate.h" #include "Candidate.h"
#include "Enums.h" #include "Enums.h"
using candidateMap = std::map<std::string, std::shared_ptr<Candidate>>; using candidateMap = std::map<std::string, Candidate*>;
class JobListing class JobListing
{ {
+1 -1
View File
@@ -33,7 +33,7 @@ void Room::setRoomName(const std::string& name)
m_name = name; m_name = name;
} }
void Room::addBooking(std::shared_ptr<Booking> booking) void Room::addBooking(Booking* booking)
{ {
if (booking) if (booking)
{ {
+2 -2
View File
@@ -10,7 +10,7 @@ File: Room.h
#include <map> #include <map>
#include <memory> #include <memory>
#include "Booking.h" #include "Booking.h"
using bookingMap = std::map<std::string, std::shared_ptr<Booking>>; using bookingMap = std::map<std::string, Booking*>;
class Room class Room
{ {
@@ -26,5 +26,5 @@ public:
const bookingMap& getBookings() const; const bookingMap& getBookings() const;
void setRoomId(const std::string& id); void setRoomId(const std::string& id);
void setRoomName(const std::string& name); void setRoomName(const std::string& name);
void addBooking(std::shared_ptr<Booking> booking); void addBooking(Booking* booking);
}; };
+2 -2
View File
@@ -18,7 +18,7 @@ const std::string& Team::getTeamName() const
return m_name; return m_name;
} }
std::shared_ptr<Employee> Team::getTeamLead() const Employee* Team::getTeamLead() const
{ {
return m_lead; return m_lead;
} }
@@ -43,7 +43,7 @@ void Team::setTeamName(const std::string& name)
m_name = name; m_name = name;
} }
void Team::setTeamLead(std::shared_ptr<Employee> lead) void Team::setTeamLead(Employee* lead)
{ {
m_lead = lead; m_lead = lead;
} }
+5 -5
View File
@@ -10,32 +10,32 @@ File: Team.h
#include <map> #include <map>
#include <memory> #include <memory>
#include "Employee.h" #include "Employee.h"
using employeeMap = std::map<std::string, std::shared_ptr<Employee>>; using employeeMap = std::map<std::string, Employee*>;
class Team class Team
{ {
private: private:
std::string m_id; std::string m_id;
std::string m_name; std::string m_name;
std::shared_ptr<Employee> m_lead; Employee* m_lead;
employeeMap m_employees; employeeMap m_employees;
int m_maximumNumberOfEmployees; int m_maximumNumberOfEmployees;
public: public:
Team() : m_id(""), m_name(""), m_lead(nullptr), m_maximumNumberOfEmployees(0) {} Team() : m_id(""), m_name(""), m_lead(nullptr), m_maximumNumberOfEmployees(0) {}
Team(const std::string& id, Team(const std::string& id,
const std::string& name, const std::string& name,
std::shared_ptr<Employee> lead, Employee* lead,
int maximumNumberOfEmployees) int maximumNumberOfEmployees)
: m_id(id), m_name(name), m_lead(lead), m_maximumNumberOfEmployees(maximumNumberOfEmployees) { : m_id(id), m_name(name), m_lead(lead), m_maximumNumberOfEmployees(maximumNumberOfEmployees) {
} }
const std::string& getTeamId() const; const std::string& getTeamId() const;
const std::string& getTeamName() const; const std::string& getTeamName() const;
std::shared_ptr<Employee> getTeamLead() const; Employee* getTeamLead() const;
const employeeMap& getEmployeesInTeam() const; const employeeMap& getEmployeesInTeam() const;
int getMaximumNumberOfEmployeesInTeam() const; int getMaximumNumberOfEmployeesInTeam() const;
void setTeamId(const std::string& id); void setTeamId(const std::string& id);
void setTeamName(const std::string& name); void setTeamName(const std::string& name);
void setTeamLead(std::shared_ptr<Employee> lead); void setTeamLead(Employee* lead);
void setEmployeesInTeam(const employeeMap& employees); void setEmployeesInTeam(const employeeMap& employees);
void setMaximumNumberOfEmployeesInTeam(int maximumNumberOfEmployees); void setMaximumNumberOfEmployeesInTeam(int maximumNumberOfEmployees);
}; };
@@ -43,7 +43,7 @@ AuthenticationDTO AuthenticationManagementService::login(const std::string& emai
employeeType = employee.second->getEmployeeType(); employeeType = employee.second->getEmployeeType();
if (employeeType == Enums::EmployeeType::GENERAL) if (employeeType == Enums::EmployeeType::GENERAL)
{ {
std::shared_ptr<GeneralEmployee> generalEmployee = std::dynamic_pointer_cast<GeneralEmployee>(employee.second); GeneralEmployee* generalEmployee = dynamic_cast<GeneralEmployee*>(employee.second);
if (generalEmployee) if (generalEmployee)
{ {
employeeDesignation = generalEmployee->getDesignation(); employeeDesignation = generalEmployee->getDesignation();
@@ -77,7 +77,7 @@ AuthenticationDTO AuthenticationManagementService::login(const std::string& emai
*/ */
void AuthenticationManagementService::changePassword(const std::string& password) void AuthenticationManagementService::changePassword(const std::string& password)
{ {
std::shared_ptr<Employee> authenticatedUser = m_dataStore.getAuthenticatedUser(); Employee* authenticatedUser = m_dataStore.getAuthenticatedUser();
if (authenticatedUser) if (authenticatedUser)
{ {
authenticatedUser->setEmployeePassword(password); authenticatedUser->setEmployeePassword(password);
@@ -99,10 +99,12 @@ void AuthenticationManagementService::changePassword(const std::string& password
* runtime_error if no user is currently logged in * runtime_error if no user is currently logged in
*/ */
void AuthenticationManagementService::logout() { void AuthenticationManagementService::logout() {
if (m_dataStore.getAuthenticatedUser()) { if (m_dataStore.getAuthenticatedEmployee())
m_dataStore.getAuthenticatedUser() = nullptr; {
m_dataStore.getAuthenticatedEmployee() = nullptr;
} }
else { else
{
throw std::runtime_error("No user currently logged In..."); throw std::runtime_error("No user currently logged In...");
} }
} }
@@ -14,6 +14,6 @@ void LogService::log(const std::string& message)
{ {
DataStore& dataStore = DataStore::getInstance(); DataStore& dataStore = DataStore::getInstance();
logMap& logs = dataStore.getLogs(); logMap& logs = dataStore.getLogs();
std::shared_ptr<Log> log = Factory::getObject<Log>(message); Log* log = Factory::getObject<Log>(message);
logs.emplace(std::make_pair(log->getTimestamp(), log)); logs.emplace(std::make_pair(log->getTimestamp(), log));
} }
@@ -6,15 +6,14 @@
*/ */
#pragma once #pragma once
#include<memory>
#include"ZenvyController.h" #include"ZenvyController.h"
class AdminMenu class AdminMenu
{ {
private: private:
std::shared_ptr<ZenvyController> m_zenvyController; ZenvyController* m_zenvyController;
public: public:
AdminMenu() :m_zenvyController(std::make_shared<ZenvyController>()) {}; AdminMenu() :m_zenvyController(new ZenvyController()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
}; };
@@ -6,15 +6,14 @@
*/ */
#pragma once #pragma once
#include<memory>
#include"ZenvyController.h" #include"ZenvyController.h"
class EmployeeMenu class EmployeeMenu
{ {
private: private:
std::shared_ptr<ZenvyController> m_zenvyController; ZenvyController m_zenvyController;
public: public:
EmployeeMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {}; EmployeeMenu() : m_zenvyController(new ZenvyController()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
}; };
@@ -6,15 +6,14 @@
*/ */
#pragma once #pragma once
#include<memory>
#include"ZenvyController.h" #include"ZenvyController.h"
class FinanceExecutiveMenu class FinanceExecutiveMenu
{ {
private: private:
std::shared_ptr<ZenvyController> m_zenvyController; ZenvyController* m_zenvyController;
public: public:
FinanceExecutiveMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {}; FinanceExecutiveMenu() : m_zenvyController(new ZenvyController()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
}; };
@@ -6,15 +6,14 @@
*/ */
#pragma once #pragma once
#include<memory>
#include"ZenvyController.h" #include"ZenvyController.h"
class HRManagerMenu class HRManagerMenu
{ {
private: private:
std::shared_ptr<ZenvyController> m_zenvyController; ZenvyController* m_zenvyController;
public: public:
HRManagerMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {}; HRManagerMenu() : m_zenvyController(new ZenvyController()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
}; };
@@ -6,15 +6,14 @@
*/ */
#pragma once #pragma once
#include<memory>
#include"ZenvyController.h" #include"ZenvyController.h"
class ITExecutiveMenu class ITExecutiveMenu
{ {
private: private:
std::shared_ptr<ZenvyController> m_zenvyController; ZenvyController* m_zenvyController;
public: public:
ITExecutiveMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {}; ITExecutiveMenu() : m_zenvyController(new ZenvyController()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
}; };
@@ -6,15 +6,14 @@
*/ */
#pragma once #pragma once
#include<memory>
#include"ZenvyController.h" #include"ZenvyController.h"
class TalentExecutiveMenu class TalentExecutiveMenu
{ {
private: private:
std::shared_ptr<ZenvyController> m_zenvyController; ZenvyController* m_zenvyController;
public: public:
TalentExecutiveMenu() : m_zenvyController(std::make_shared < ZenvyController>()) {}; TalentExecutiveMenu() : m_zenvyController(new ZenvyController()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
}; };
@@ -6,15 +6,14 @@
*/ */
#pragma once #pragma once
#include<memory>
#include"ZenvyController.h" #include"ZenvyController.h"
class TeamExecutiveMenu class TeamExecutiveMenu
{ {
private: private:
std::shared_ptr<ZenvyController> m_zenvyController; ZenvyController* m_zenvyController;
public: public:
TeamExecutiveMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {}; TeamExecutiveMenu() : m_zenvyController(new ZenvyController()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
}; };
@@ -6,15 +6,14 @@
*/ */
#pragma once #pragma once
#include<memory>
#include"ZenvyController.h" #include"ZenvyController.h"
class TeamLeadMenu class TeamLeadMenu
{ {
private: private:
std::shared_ptr<ZenvyController> m_zenvyController; ZenvyController* m_zenvyController;
public: public:
TeamLeadMenu() : m_zenvyController(std::make_shared<ZenvyController>()) {}; TeamLeadMenu() : m_zenvyController(new ZenvyController()) {};
void run(); void run();
bool handleOperation(int); bool handleOperation(int);
}; };
@@ -7,7 +7,6 @@
#include <iostream> #include <iostream>
#include <utility> #include <utility>
#include <memory>
#include <stdexcept> #include <stdexcept>
#include "UserInterface.h" #include "UserInterface.h"
#include "AdminMenu.h" #include "AdminMenu.h"
@@ -132,7 +131,6 @@ void UserInterface::login()
} }
} }
util::clear(); util::clear();
// Route to appropriate menu
switch (employeeType) switch (employeeType)
{ {
case Enums::EmployeeType::ADMIN: case Enums::EmployeeType::ADMIN:
@@ -191,4 +189,17 @@ void UserInterface::login()
break; break;
} }
m_controller->logout(); m_controller->logout();
}
UserInterface::~UserInterface()
{
delete m_controller;
delete m_employeeMenu;
delete m_adminMenu;
delete m_financeExecutiveMenu;
delete m_hrManagerMenu;
delete m_itExecutiveMenu;
delete m_talentExecutiveMenu;
delete m_teamExecutiveMenu;
delete m_teamLeadMenu;
} }
@@ -6,7 +6,6 @@
*/ */
#pragma once #pragma once
#include <memory>
#include <utility> #include <utility>
#include "AdminMenu.h" #include "AdminMenu.h"
#include "EmployeeMenu.h" #include "EmployeeMenu.h"
@@ -21,27 +20,28 @@
class UserInterface class UserInterface
{ {
private: private:
std::shared_ptr<ZenvyController> m_controller; ZenvyController* m_controller;
std::shared_ptr<EmployeeMenu> m_employeeMenu; EmployeeMenu* m_employeeMenu;
std::shared_ptr<AdminMenu> m_adminMenu; AdminMenu* m_adminMenu;
std::shared_ptr<FinanceExecutiveMenu> m_financeExecutiveMenu; FinanceExecutiveMenu* m_financeExecutiveMenu;
std::shared_ptr<HRManagerMenu> m_hrManagerMenu; HRManagerMenu* m_hrManagerMenu;
std::shared_ptr<ITExecutiveMenu> m_itExecutiveMenu; ITExecutiveMenu* m_itExecutiveMenu;
std::shared_ptr<TalentExecutiveMenu> m_talentExecutiveMenu; TalentExecutiveMenu* m_talentExecutiveMenu;
std::shared_ptr<TeamExecutiveMenu> m_teamExecutiveMenu; TeamExecutiveMenu* m_teamExecutiveMenu;
std::shared_ptr<TeamLeadMenu> m_teamLeadMenu; TeamLeadMenu* m_teamLeadMenu;
public: public:
UserInterface() : m_controller(std::make_shared<ZenvyController>()), UserInterface() :
m_employeeMenu(std::make_shared<EmployeeMenu>()), m_controller(new ZenvyController()),
m_adminMenu(std::make_shared<AdminMenu>()), m_employeeMenu(new EmployeeMenu()),
m_financeExecutiveMenu(std::make_shared<FinanceExecutiveMenu>()), m_adminMenu(new AdminMenu()),
m_hrManagerMenu(std::make_shared<HRManagerMenu>()), m_financeExecutiveMenu(new FinanceExecutiveMenu()),
m_itExecutiveMenu(std::make_shared<ITExecutiveMenu>()), m_hrManagerMenu(new HRManagerMenu()),
m_talentExecutiveMenu(std::make_shared<TalentExecutiveMenu>()), m_itExecutiveMenu(new ITExecutiveMenu()),
m_teamExecutiveMenu(std::make_shared<TeamExecutiveMenu>()), m_talentExecutiveMenu(new TalentExecutiveMenu()),
m_teamLeadMenu(std::make_shared<TeamLeadMenu>()) {}; m_teamExecutiveMenu(new TeamExecutiveMenu()),
void run(); m_teamLeadMenu(new TeamLeadMenu()) {};
bool handleOperation(int choice); void run();
void login(); bool handleOperation(int choice);
}; void login();
~UserInterface();
};