2013-08-26 05:52:03 -05:00
|
|
|
#include <opm/core/utility/Event.hpp>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace Opm;
|
|
|
|
|
|
|
|
Event&
|
2013-08-26 07:33:23 -05:00
|
|
|
EventSource::add (const std::function<void ()>& handler) {
|
2013-08-26 05:52:03 -05:00
|
|
|
// add handler to the back of the queue
|
|
|
|
handlers_.push_back (handler);
|
|
|
|
|
|
|
|
// return ourselves so we can be used in a call chain
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EventSource::signal () {
|
|
|
|
// loop through the list of handlers, and invoke every one of them
|
|
|
|
// (range-based for loops are not available until GCC 4.6)
|
|
|
|
for (auto it = handlers_.begin(); it != handlers_.end(); ++it) {
|
|
|
|
(*it) ();
|
|
|
|
}
|
|
|
|
}
|