Add destructor in datastore
This commit is contained in:
@@ -91,4 +91,22 @@ Employee* DataStore::getAuthenticatedUser()
|
|||||||
{
|
{
|
||||||
return m_authenticatedEmployee;
|
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;
|
Employee* m_authenticatedEmployee;
|
||||||
employeeMap m_employees;
|
employeeMap m_employees;
|
||||||
logMap m_logs;
|
logMap m_logs;
|
||||||
DataStore() = default;
|
DataStore() : m_authenticatedEmployee(nullptr) {};
|
||||||
public:
|
public:
|
||||||
static DataStore& getInstance();
|
static DataStore& getInstance();
|
||||||
DataStore(const DataStore&) = delete;
|
DataStore(const DataStore&) = delete;
|
||||||
@@ -46,4 +46,5 @@ public:
|
|||||||
logMap& getLogs();
|
logMap& getLogs();
|
||||||
Employee*& getAuthenticatedEmployee();
|
Employee*& getAuthenticatedEmployee();
|
||||||
void setAuthenticatedEmployee(Employee*);
|
void setAuthenticatedEmployee(Employee*);
|
||||||
|
~DataStore();
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user