2021-12-05 17:54:36 +00:00
|
|
|
#include "ObjectIDManager.h"
|
|
|
|
|
|
|
|
// Custom Classes
|
|
|
|
#include "Database.h"
|
|
|
|
#include "dLogger.h"
|
|
|
|
|
|
|
|
// Static Variables
|
2022-07-28 13:39:57 +00:00
|
|
|
ObjectIDManager* ObjectIDManager::m_Address = nullptr;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
//! Initializes the manager
|
2022-07-28 13:39:57 +00:00
|
|
|
void ObjectIDManager::Initialize(dLogger* logger) {
|
|
|
|
this->mLogger = logger;
|
2023-10-10 00:40:48 +00:00
|
|
|
this->currentPersistentID = Database::Connection->GetObjectIDTracker();
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//! Generates a new persistent ID
|
|
|
|
uint32_t ObjectIDManager::GeneratePersistentID(void) {
|
2022-07-28 13:39:57 +00:00
|
|
|
uint32_t toReturn = ++this->currentPersistentID;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-10-10 00:40:48 +00:00
|
|
|
Database::Connection->SetObjectIDTracker(toReturn);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
return toReturn;
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ObjectIDManager::SaveToDatabase() {
|
2023-10-10 00:40:48 +00:00
|
|
|
Database::Connection->SetObjectIDTracker(this->currentPersistentID);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|