DarkflameServer/dMasterServer/ObjectIDManager.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
883 B
C
Raw Permalink Normal View History

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