Add destructor in datastore
This commit is contained in:
@@ -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();
|
||||
};
|
||||
Reference in New Issue
Block a user