added Emitter::clearAll
This commit is contained in:
parent
aa20079537
commit
cf65a0a65f
@ -20,6 +20,7 @@ class Emitter {
|
||||
struct BaseHandler {
|
||||
virtual ~BaseHandler() noexcept = default;
|
||||
virtual bool empty() const noexcept = 0;
|
||||
virtual void clear() noexcept = 0;
|
||||
};
|
||||
|
||||
template<typename E>
|
||||
@ -33,6 +34,11 @@ class Emitter {
|
||||
return onceL.empty() && onL.empty();
|
||||
}
|
||||
|
||||
void clear() noexcept override {
|
||||
onceL.clear();
|
||||
onL.clear();
|
||||
}
|
||||
|
||||
Connection once(Listener f) {
|
||||
auto conn = onceL.insert(onceL.cbegin(), std::move(f));
|
||||
return { onceL, std::move(conn) };
|
||||
@ -47,11 +53,6 @@ class Emitter {
|
||||
conn.first.erase(conn.second);
|
||||
}
|
||||
|
||||
void clear() noexcept {
|
||||
onceL.clear();
|
||||
onL.clear();
|
||||
}
|
||||
|
||||
void publish(const E &event, T &ref) {
|
||||
for(auto &&listener: onceL) { listener(event, ref); }
|
||||
for(auto &&listener: onL) { listener(event, ref); }
|
||||
@ -122,6 +123,12 @@ public:
|
||||
handler<E>().clear();
|
||||
}
|
||||
|
||||
void clearAll() noexcept {
|
||||
for(auto &&h: handlers) {
|
||||
h->clear();
|
||||
}
|
||||
}
|
||||
|
||||
bool empty() const noexcept {
|
||||
bool empty = true;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user