summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2017-07-15 11:59:10 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2017-07-15 11:59:10 +0200
commit6a96bcf1659d07cd3a7f7e65519007abfaeda2a0 (patch)
tree47e7c7b7b7c6377fb159c864c928bbb9cefbc833 /src
parentf777a1a3f5f92814f8b83fe0c22dbe461f11bed7 (diff)
Ensure that the Notifier call order is the same as the connection order.
Diffstat (limited to 'src')
-rw-r--r--src/notifier.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/notifier.h b/src/notifier.h
index ff59741..f044d98 100644
--- a/src/notifier.h
+++ b/src/notifier.h
@@ -27,10 +27,9 @@
#pragma once
#include <functional>
-#include <vector>
-#include <map>
+#include <list>
+#include <utility>
#include <set>
-#include <memory>
namespace aux
{
@@ -124,7 +123,7 @@ public:
template<typename O, typename F>
void connect(O* p, const F& fn)
{
- slots[p] = std::move(construct_mem_fn(fn, p, aux::gen_int_sequence<sizeof...(Args)>{}));
+ slots.emplace_back(std::make_pair(p, std::move(construct_mem_fn(fn, p, aux::gen_int_sequence<sizeof...(Args)>{}))));
if(p && dynamic_cast<Listener*>(p))
{
dynamic_cast<Listener*>(p)->registerNotifier(this);
@@ -134,7 +133,14 @@ public:
//! \brief Disconnect object from this Notifier.
void disconnect(Listener* object)
{
- slots.erase(object);
+ for(auto it = slots.begin(); it != slots.end(); ++it)
+ {
+ if(it->first == object)
+ {
+ slots.erase(it);
+ return;
+ }
+ }
}
//! \brief Activate this notifier by pretending it is a function.
@@ -148,7 +154,7 @@ public:
}
private:
- std::map<Listener*, callback_type> slots;
+ std::list<std::pair<Listener*, callback_type>> slots;
template<typename F, typename O, int... Ns>
callback_type construct_mem_fn(const F& fn, O* p, aux::int_sequence<Ns...>) const