2021-12-05 17:54:36 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// C++
|
|
|
|
#include <cstdint>
|
|
|
|
|
2023-10-21 23:31:55 +00:00
|
|
|
class Logger;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
\file ObjectIDManager.hpp
|
|
|
|
\brief A manager that handles requests for object IDs
|
|
|
|
*/
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
//! The Object ID Manager
|
2021-12-05 17:54:36 +00:00
|
|
|
class ObjectIDManager {
|
|
|
|
private:
|
2023-10-21 23:31:55 +00:00
|
|
|
Logger* mLogger;
|
2022-07-28 13:39:57 +00:00
|
|
|
static ObjectIDManager* m_Address; //!< The singleton instance
|
|
|
|
|
|
|
|
uint32_t currentPersistentID; //!< The highest current persistent ID in use
|
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
public:
|
2022-07-28 13:39:57 +00:00
|
|
|
|
|
|
|
//! Return the singleton if it is initialized
|
|
|
|
static ObjectIDManager* TryInstance() {
|
|
|
|
return m_Address;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! The singleton method
|
|
|
|
static ObjectIDManager* Instance() {
|
|
|
|
if (m_Address == nullptr) {
|
|
|
|
m_Address = new ObjectIDManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_Address;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Initializes the manager
|
2023-10-21 23:31:55 +00:00
|
|
|
void Initialize(Logger* logger);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
|
|
|
//! Generates a new persistent ID
|
|
|
|
/*!
|
|
|
|
\return The new persistent ID
|
|
|
|
*/
|
2023-11-18 00:47:18 +00:00
|
|
|
uint32_t GeneratePersistentID();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
|
|
|
void SaveToDatabase();
|
2021-12-05 17:54:36 +00:00
|
|
|
};
|