mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-11-08 22:06:20 +00:00
cac871cf2b
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
25 lines
431 B
C++
25 lines
431 B
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <functional>
|
|
|
|
namespace EightBit {
|
|
template<class T> class Signal final {
|
|
private:
|
|
typedef std::function<void(T&)> delegate_t;
|
|
typedef std::vector<delegate_t> delegates_t;
|
|
|
|
delegates_t m_delegates;
|
|
|
|
public:
|
|
void connect(const delegate_t functor) {
|
|
m_delegates.push_back(functor);
|
|
}
|
|
|
|
void fire(T& e) const {
|
|
for (auto& delegate : m_delegates)
|
|
delegate(e);
|
|
}
|
|
};
|
|
}
|