From 9cab181cabbb8b824d493e837bb0ce8da03e0beb Mon Sep 17 00:00:00 2001 From: Dawid Drozd Date: Sat, 28 Mar 2020 19:45:26 +0100 Subject: [PATCH] Update Perks to shared Maybe we would like to share perks to achieve something between event buses --- lib/src/dexode/eventbus/perk/PerkEventBus.cpp | 2 +- lib/src/dexode/eventbus/perk/PerkEventBus.hpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/dexode/eventbus/perk/PerkEventBus.cpp b/lib/src/dexode/eventbus/perk/PerkEventBus.cpp index afe605d..46d33db 100644 --- a/lib/src/dexode/eventbus/perk/PerkEventBus.cpp +++ b/lib/src/dexode/eventbus/perk/PerkEventBus.cpp @@ -6,7 +6,7 @@ namespace dexode::eventbus::perk { -PerkEventBus::RegisterHelper PerkEventBus::addPerk(std::unique_ptr perk) +PerkEventBus::RegisterHelper PerkEventBus::addPerk(std::shared_ptr perk) { auto* local = perk.get(); _perks.push_back(std::move(perk)); diff --git a/lib/src/dexode/eventbus/perk/PerkEventBus.hpp b/lib/src/dexode/eventbus/perk/PerkEventBus.hpp index f3f4499..12e7603 100644 --- a/lib/src/dexode/eventbus/perk/PerkEventBus.hpp +++ b/lib/src/dexode/eventbus/perk/PerkEventBus.hpp @@ -46,13 +46,13 @@ public: {} }; - RegisterHelper addPerk(std::unique_ptr perk); + RegisterHelper addPerk(std::shared_ptr perk); template T* getPerk() { auto found = - std::find_if(_perks.begin(), _perks.end(), [](const std::unique_ptr& perk) { + std::find_if(_perks.begin(), _perks.end(), [](const std::shared_ptr& perk) { return dynamic_cast(perk.get()) != nullptr; }); if(found != _perks.end()) @@ -66,7 +66,7 @@ protected: bool postponeEvent(PostponeHelper& postponeCall) override; private: - std::vector> _perks; + std::vector> _perks; std::vector> _onPrePostpone; std::vector> _onPostPostpone; };