mirror of
https://github.com/gelldur/EventBus.git
synced 2024-12-26 18:51:02 +08:00
Update Perks to shared
Maybe we would like to share perks to achieve something between event buses
This commit is contained in:
parent
a58aa21934
commit
9cab181cab
@ -6,7 +6,7 @@
|
||||
namespace dexode::eventbus::perk
|
||||
{
|
||||
|
||||
PerkEventBus::RegisterHelper PerkEventBus::addPerk(std::unique_ptr<Perk> perk)
|
||||
PerkEventBus::RegisterHelper PerkEventBus::addPerk(std::shared_ptr<Perk> perk)
|
||||
{
|
||||
auto* local = perk.get();
|
||||
_perks.push_back(std::move(perk));
|
||||
|
@ -46,13 +46,13 @@ public:
|
||||
{}
|
||||
};
|
||||
|
||||
RegisterHelper addPerk(std::unique_ptr<Perk> perk);
|
||||
RegisterHelper addPerk(std::shared_ptr<Perk> perk);
|
||||
|
||||
template <typename T>
|
||||
T* getPerk()
|
||||
{
|
||||
auto found =
|
||||
std::find_if(_perks.begin(), _perks.end(), [](const std::unique_ptr<Perk>& perk) {
|
||||
std::find_if(_perks.begin(), _perks.end(), [](const std::shared_ptr<Perk>& perk) {
|
||||
return dynamic_cast<T*>(perk.get()) != nullptr;
|
||||
});
|
||||
if(found != _perks.end())
|
||||
@ -66,7 +66,7 @@ protected:
|
||||
bool postponeEvent(PostponeHelper& postponeCall) override;
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<Perk>> _perks;
|
||||
std::vector<std::shared_ptr<Perk>> _perks;
|
||||
std::vector<std::function<perk::Flag(PostponeHelper&)>> _onPrePostpone;
|
||||
std::vector<std::function<perk::Flag(PostponeHelper&)>> _onPostPostpone;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user