17 void Register(T
object)
override {
18 std::string hash =
object->GetHash();
19 if (m_objects.count(hash) > 0) {
23 m_objects.insert(std::pair<std::string, T>(hash,
object));
27 void Remove(T
object)
override {
28 std::string hash =
object->GetHash();
29 if (m_objects.count(hash) <= 0)
return;
30 for (
auto it = m_objects.begin(); it != m_objects.end(); ++it) {
31 if (it->second ==
object) {
39 bool HasHash(
const std::string& hash)
const {
40 return m_objects.count(hash) > 0;
43 T Get(std::string index)
const override {
44 return m_objects.at(index);
47 std::unordered_map<std::string, T> GetAll()
const override {
51 std::string GetID(T
object)
const override {
52 return object->GetHash();
55 int GetSize()
const override {
59 void ChangeHash(
const std::string& srcHash,
const std::string& dstHash) {
60 T
object = m_objects.at(srcHash);
61 if(
object ==
nullptr)
return;
62 m_objects.erase(srcHash);
63 const auto& prevSize = m_objects.size();
64 m_objects.insert(std::pair<std::string, T>(dstHash,
object));
69 std::unordered_map<std::string, T> m_objects;