diff options
author | chatty | 1994-03-14 08:40:16 +0000 |
---|---|---|
committer | chatty | 1994-03-14 08:40:16 +0000 |
commit | 33c173febd67cf6b558eb86ba552dc9369ab4b24 (patch) | |
tree | 0af984e138144b6ff9d8ec98b0ea7245dd003bef /dnn/Trigger.cc | |
parent | 1ed65383fc2b49e22929862dd5705c93f79a60c2 (diff) | |
download | ivy-league-33c173febd67cf6b558eb86ba552dc9369ab4b24.zip ivy-league-33c173febd67cf6b558eb86ba552dc9369ab4b24.tar.gz ivy-league-33c173febd67cf6b558eb86ba552dc9369ab4b24.tar.bz2 ivy-league-33c173febd67cf6b558eb86ba552dc9369ab4b24.tar.xz |
Initial revision
Diffstat (limited to 'dnn/Trigger.cc')
-rw-r--r-- | dnn/Trigger.cc | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/dnn/Trigger.cc b/dnn/Trigger.cc new file mode 100644 index 0000000..59a3b33 --- /dev/null +++ b/dnn/Trigger.cc @@ -0,0 +1,67 @@ +/* + * DNN - Data News Network + * + * by Stephane Chatty + * + * Copyright 1993-1994 + * Centre d'Etudes de la Navigation Aerienne (CENA) + * + * Event triggers. + * + * $Id$ + * $CurLog$ + */ + +#include "Trigger.h" +#include "Reaction.h" + +/*?class DnnTrigger +\typ{DnnTrigger}s are the core of event detection and emission. The presence of a trigger +(generally in a sensor) determines whether a certain situation, or the reception +of an event from the underlying window system, should provoke the emission of an event. +Each trigger holds a list of reactions (of type \typ{DnnBaseReaction}). These reactions will +receive all the events whose creation and emission was caused by the presence of +the trigger. +?*/ + +/*? +Create a trigger with an empty list of associated reaction. +?*/ +DnnTrigger :: DnnTrigger () +: Subscribers () +{ +} + +/*?nodoc?*/ +DnnTrigger :: ~DnnTrigger () +{ +} + +/*?nextdoc?*/ +void +DnnTrigger :: Subscribe (DnnBaseReaction& a) +{ + Subscribers.Append (&a); +} + +/*? +Add (resp. Remove) a reaction to (resp. from) the list of reactions that should receive +events caused by this trigger. +?*/ +void +DnnTrigger :: Unsubscribe (DnnBaseReaction& a) +{ + Subscribers.Remove (&a); +} + +/*? +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); +} |