EightBit/inc/Signal.h
Adrian Conlon 45dc274167 Get rid of wrappers for bus access: i.e. make it clearer where the bus is being read/written.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
2018-03-10 01:53:57 +00:00

25 lines
431 B
C++

#pragma once
#include <vector>
#include <functional>
namespace EightBit {
template<class T> class Signal {
private:
typedef std::function<void(const T&)> delegate_t;
typedef std::vector<delegate_t> delegates_t;
delegates_t m_delegates;
public:
void connect(delegate_t functor) {
m_delegates.push_back(functor);
}
void fire(const T& e) const {
for (auto& delegate : m_delegates)
delegate(e);
}
};
}