-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSObjectManager.h
More file actions
34 lines (31 loc) · 898 Bytes
/
Copy pathSObjectManager.h
File metadata and controls
34 lines (31 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once
#include "Export.h"
#include "Singleton.hpp"
#include "UUID.h"
#include <shared_mutex>
#include <vector>
#include <unordered_map>
#include <unordered_set>
namespace sh::core
{
class SObject;
/// @brief 모든 SObject는 여기서 관리된다. 스레드 안전하다.
class SObjectManager : public Singleton<SObjectManager>
{
friend Singleton<SObjectManager>;
friend class GarbageCollection;
private:
std::unordered_map<UUID, std::size_t> objIdxMap;
std::vector<SObject*> objs;
std::unordered_set<const SObject*> objPtrs;
std::shared_mutex mu;
private:
SH_CORE_API SObjectManager();
public:
SH_CORE_API ~SObjectManager();
SH_CORE_API void RegisterSObject(SObject* obj);
SH_CORE_API void UnRegisterSObject(const SObject* obj);
SH_CORE_API auto GetSObject(const UUID& uuid) -> SObject*;
SH_CORE_API auto IsSObject(void* ptr) -> bool;
};
}//namespace