diff options
Diffstat (limited to 'dnn/Trigger.cc')
-rw-r--r-- | dnn/Trigger.cc | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/dnn/Trigger.cc b/dnn/Trigger.cc index 59a3b33..9b6db60 100644 --- a/dnn/Trigger.cc +++ b/dnn/Trigger.cc @@ -28,7 +28,8 @@ the trigger. Create a trigger with an empty list of associated reaction. ?*/ DnnTrigger :: DnnTrigger () -: Subscribers () +: Subscribers (), + Grabs () { } @@ -52,6 +53,24 @@ void DnnTrigger :: Unsubscribe (DnnBaseReaction& a) { Subscribers.Remove (&a); + Grabs.Remove (&a); +} + +/*?nextdoc?*/ +void +DnnTrigger :: Grab (DnnBaseReaction& a) +{ + Grabs.Prepend (&a); +} + +/*? +Add (resp. Remove) a reaction onto (resp. from) the stack of reactions that preempt +events caused by this trigger. +?*/ +void +DnnTrigger :: Release (DnnBaseReaction& a) +{ + Subscribers.Remove (&a); } /*? @@ -60,8 +79,13 @@ Have a trigger dispatch the event \var{ev} to its associated reactions. void DnnTrigger :: Dispatch (DnnEvent& ev) { - CcuListOf <DnnBaseReaction> subscribers = Subscribers; - CcuListIterOf <DnnBaseReaction> ai (subscribers); - while (++ai) - (*ai)->Manage (ev); + DnnBaseReaction* r = Grabs.First (); + if (r) { + r->Manage (ev); + } else { + CcuListOf <DnnBaseReaction> subscribers = Subscribers; + CcuListIterOf <DnnBaseReaction> ai = subscribers; + while (++ai) + (*ai)->Manage (ev); + } } |