diff options
Diffstat (limited to 'dnn/Reaction.cc')
-rw-r--r-- | dnn/Reaction.cc | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/dnn/Reaction.cc b/dnn/Reaction.cc index 62a6849..845d689 100644 --- a/dnn/Reaction.cc +++ b/dnn/Reaction.cc @@ -25,13 +25,19 @@ and can be associated to one or more triggers, generally located in a sensor. Create a reaction. ?*/ DnnBaseReaction :: DnnBaseReaction () +: Triggers (), + Grabbed () { } /*?nodoc?*/ DnnBaseReaction :: ~DnnBaseReaction () { - CcuListIterOf <DnnTrigger> ti (Triggers); + CcuListIterOf <DnnTrigger> ti = Grabbed; + while (++ti) + (*ti)->Release (*this); + + ti = Triggers; while (++ti) (*ti)->Unsubscribe (*this); } @@ -55,6 +61,25 @@ DnnBaseReaction :: UnsubscribeTo (DnnTrigger& t) t.Unsubscribe (*this); } +/*?nextdoc?*/ +void +DnnBaseReaction :: Grab (DnnTrigger& t) +{ + Grabbed.Append (&t); + t.Grab (*this); +} + +/*? +Tell that a reaction should (resp. should no more) be the only one +activated when the trigger \var{t} causes the emission of an event. +?*/ +void +DnnBaseReaction :: Release (DnnTrigger& t) +{ + Grabbed.Remove (&t); + t.Release (*this); +} + /*? This virtual function is called when an event is emitted because of a trigger to which this reaction was attached. It should be redefined in derived classes to implement |