summaryrefslogtreecommitdiff
path: root/dnn/Reaction.cc
diff options
context:
space:
mode:
authorchatty1994-05-10 08:50:04 +0000
committerchatty1994-05-10 08:50:04 +0000
commit6d32f3eda675ac0c36d835e69054eba2b1a777c8 (patch)
treee59397a630f2e47ad38393eece7a30e3aebda87f /dnn/Reaction.cc
parent9e5332136b567af8c9fd6a6b91338d2d68349562 (diff)
downloadivy-league-6d32f3eda675ac0c36d835e69054eba2b1a777c8.zip
ivy-league-6d32f3eda675ac0c36d835e69054eba2b1a777c8.tar.gz
ivy-league-6d32f3eda675ac0c36d835e69054eba2b1a777c8.tar.bz2
ivy-league-6d32f3eda675ac0c36d835e69054eba2b1a777c8.tar.xz
Added Grab/Release
Diffstat (limited to 'dnn/Reaction.cc')
-rw-r--r--dnn/Reaction.cc27
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