Add classes for event-handling

The new classes Event and EventSource can be used as a simple mechanism
for implementing event-based callbacks in the simulators.
This commit is contained in:
Roland Kaufmann
2017-12-04 16:24:14 +01:00
committed by Arne Morten Kvarving
parent a767e166ae
commit 0c53ac1509
4 changed files with 211 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
// Copyright (C) 2013 Uni Research AS
// This file is licensed under the GNU General Public License v3.0
#ifndef OPM_EVENT_HEADER_INCLUDED
#error Do NOT include this file directly!
#endif /* OPM_EVENT_HEADER_INCLUDED */
template <typename T, void (T::*member)()> inline Event&
Event::add (T& t) {
// wrap the member function in a std::function and add that
// notice the use of ref() to avoid invoking the copy constructor
return this->add (std::bind (member, std::ref(t)));
}