From 6d32f3eda675ac0c36d835e69054eba2b1a777c8 Mon Sep 17 00:00:00 2001 From: chatty Date: Tue, 10 May 1994 08:50:04 +0000 Subject: Added Grab/Release --- dnn/Reaction.cc | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'dnn/Reaction.cc') 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 ti (Triggers); + CcuListIterOf 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 -- cgit v1.1