From db8427583826910440f6e6643bd16119bce09cf9 Mon Sep 17 00:00:00 2001 From: AnatolyKalin Date: Mon, 22 May 2023 16:38:02 +0300 Subject: [PATCH] [DXFC-402] Implement adding multiple symbols and removing symbols --- .../dxfeed_graal_cpp_api/internal/Common.hpp | 2 + .../internal/managers/EntityManager.hpp | 38 ++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/include/dxfeed_graal_cpp_api/internal/Common.hpp b/include/dxfeed_graal_cpp_api/internal/Common.hpp index 54817e66..bdf7d05b 100644 --- a/include/dxfeed_graal_cpp_api/internal/Common.hpp +++ b/include/dxfeed_graal_cpp_api/internal/Common.hpp @@ -3,6 +3,8 @@ #pragma once +#define DXFCPP_DEBUG_ISOLATES + #ifdef __cpp_lib_bit_cast # include #endif diff --git a/include/dxfeed_graal_cpp_api/internal/managers/EntityManager.hpp b/include/dxfeed_graal_cpp_api/internal/managers/EntityManager.hpp index dce6e68c..bdb3e1d2 100644 --- a/include/dxfeed_graal_cpp_api/internal/managers/EntityManager.hpp +++ b/include/dxfeed_graal_cpp_api/internal/managers/EntityManager.hpp @@ -14,14 +14,24 @@ namespace dxfcpp { template struct EntityManager : private NonCopyable> { // TODO: Boost.Bimap - std::unordered_map, std::shared_ptr> entitiesById_{}; - std::unordered_map, Id> idsByEntities_{}; - std::mutex mutex_{}; + std::unordered_map, std::shared_ptr> entitiesById_; + std::unordered_map, Id> idsByEntities_; + std::mutex mutex_; + + EntityManager() : entitiesById_{}, idsByEntities_{}, mutex_{} { + if constexpr (isDebug) { + auto name = typeid(EntityType).name(); + + debug("EntityManager<{}>()", name); + } + } public: Id registerEntity(std::shared_ptr entity) { if constexpr (isDebug) { - debug("EntityManager::registerEntity({})", entity->toString()); + auto name = typeid(EntityType).name(); + + debug("EntityManager<{}>::registerEntity({})", name, entity->toString()); } std::lock_guard lockGuard{mutex_}; @@ -40,7 +50,9 @@ template struct EntityManager : private NonCopyable entity) { if constexpr (isDebug) { - debug("EntityManager::unregisterEntity({})", entity->toString()); + auto name = typeid(EntityType).name(); + + debug("EntityManager<{}>::unregisterEntity({})", name, entity->toString()); } std::lock_guard lockGuard{mutex_}; @@ -57,7 +69,9 @@ template struct EntityManager : private NonCopyable id) { if constexpr (isDebug) { - debug("EntityManager::unregisterEntity(id = {})", id.getValue()); + auto name = typeid(EntityType).name(); + + debug("EntityManager<{}>::unregisterEntity(id = {})", name, id.getValue()); } std::lock_guard lockGuard{mutex_}; @@ -73,6 +87,12 @@ template struct EntityManager : private NonCopyable getEntity(Id id) { + if constexpr (isDebug) { + auto name = typeid(EntityType).name(); + + debug("EntityManager<{}>::getEntity(id = {})", name, id.getValue()); + } + std::lock_guard lockGuard{mutex_}; if (auto it = entitiesById_.find(id); it != entitiesById_.end()) { @@ -83,6 +103,12 @@ template struct EntityManager : private NonCopyable> getId(std::shared_ptr entity) { + if constexpr (isDebug) { + auto name = typeid(EntityType).name(); + + debug("EntityManager<{}>::getId({})", name, entity->toString()); + } + std::lock_guard lockGuard{mutex_}; if (auto it = idsByEntities_.find(entity); it != idsByEntities_.end()) {