DarkflameServer/dMasterServer/ObjectIDManager.h

48 lines
880 B
C
Raw Normal View History

#pragma once
// C++
#include <cstdint>
class Logger;
/*!
\file ObjectIDManager.hpp
\brief A manager that handles requests for object IDs
*/
2022-07-28 13:39:57 +00:00
//! The Object ID Manager
class ObjectIDManager {
private:
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
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
void Initialize(Logger* logger);
2022-07-28 13:39:57 +00:00
//! Generates a new persistent ID
/*!
\return The new persistent ID
*/
uint32_t GeneratePersistentID(void);
void SaveToDatabase();
};