25#ifndef _SOURCE_EVENT_TFEVENT_H_
26#define _SOURCE_EVENT_TFEVENT_H_
28#include <TissueForge_private.h>
30#include <forward_list>
37 template<
typename event_t>
using EventMethodT =
HRESULT (*)(
const event_t&);
40 enum class EventFlag :
unsigned int {
45 struct CAPI_EXPORT EventBase {
48 std::forward_list<EventFlag> flags;
83 virtual HRESULT eval(
const FloatP_t &time) {
85 if(!predicate())
return 0;
88 if(invoke() == 1)
return -1;
100 void remove() { flags.push_front(EventFlag::REMOVE); }
106 using EventMethod = EventMethodT<Event>;
109 struct CAPI_EXPORT Event : EventBase {
119 Event(EventMethod *invokeMethod, EventMethod *predicateMethod);
124 HRESULT eval(
const FloatP_t &time);
128 EventMethod *invokeMethod;
129 EventMethod *predicateMethod;
140 CPPAPI_FUNC(
Event*)
onEvent(EventMethod *invokeMethod, EventMethod *predicateMethod);
Tissue Forge event system.
Definition tfEvent.h:34
Event * onEvent(EventMethod *invokeMethod, EventMethod *predicateMethod)
Creates an event using prescribed invoke and predicate functions.
virtual HRESULT predicate()=0
FloatP_t last_fired
Record of last time fired.
Definition tfEvent.h:53
int times_fired
Record of how many times fired.
Definition tfEvent.h:58
void remove()
Designates event for removal.
Definition tfEvent.h:100
virtual HRESULT invoke()=0
Event(EventMethod *invokeMethod, EventMethod *predicateMethod)
Construct an instance using functions.
int32_t HRESULT
Definition tf_port.h:255