Add destructor in datastore

This commit is contained in:
Tinu Johnson
2026-04-10 15:23:27 +05:30
committed by Joel Thomas
parent 75b69f8c11
commit 83f1c4183c
2 changed files with 20 additions and 1 deletions
@@ -91,4 +91,22 @@ Employee* DataStore::getAuthenticatedUser()
{
return m_authenticatedEmployee;
}
DataStore::~DataStore()
{
for (auto& pair : m_employees)
{
delete pair.second;
}
m_employees.clear();
for (auto& pair : m_logs)
{
delete pair.second;
}
m_logs.clear();
if (m_authenticatedEmployee)
{
delete m_authenticatedEmployee;
m_authenticatedEmployee = nullptr;
}
}
@@ -34,7 +34,7 @@ private:
Employee* m_authenticatedEmployee;
employeeMap m_employees;
logMap m_logs;
DataStore() = default;
DataStore() : m_authenticatedEmployee(nullptr) {};
public:
static DataStore& getInstance();
DataStore(const DataStore&) = delete;
@@ -46,4 +46,5 @@ public:
logMap& getLogs();
Employee*& getAuthenticatedEmployee();
void setAuthenticatedEmployee(Employee*);
~DataStore();
};