StateChartTransition.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Xml.Linq;
  4. namespace csharp_sccd_compiler
  5. {
  6. public class StateChartTransition : Visitable
  7. {
  8. public TriggerEvent trigger { get; private set; }
  9. public StateChartNode parent { get; private set; }
  10. public Expression guard { get; private set; }
  11. public StateReference target { get; private set; }
  12. public Action action { get; private set; }
  13. /// <summary>
  14. /// Ordered list of nodes to be entered upon taking the transition.
  15. /// The boolean value indicates whether the <c>StateChartNode</c> in the list is the last in a branch.
  16. /// (And was thus specified specifically in the state reference.)
  17. /// </summary>
  18. /// <value>Set by the Path Calculator visitor.</value>
  19. public List<Tuple<StateChartNode,bool>> enter_nodes { get; set; }
  20. /// <summary>
  21. /// Ordered list of nodes to be exited upon taking the transition.
  22. /// </summary>
  23. /// <value>Set by the Path Calculator visitor.</value>
  24. public List<StateChartNode> exit_nodes { get; set; }
  25. public StateChartTransition(XElement xml, StateChartNode parent)
  26. {
  27. this.parent = parent;
  28. this.trigger = new TriggerEvent(xml);
  29. XAttribute guard_attribute = xml.Attribute("cond");
  30. if (guard_attribute != null && guard_attribute.Value.Trim() != "")
  31. this.guard = new Expression(guard_attribute.Value.Trim());
  32. else
  33. this.guard = null;
  34. XAttribute target_attribute = xml.Attribute("target");
  35. if (target_attribute == null)
  36. throw new CompilerException(string.Format("Transition from <{0}> is missing a target attribute.", this.parent.full_name));
  37. this.target = new StateReference(target_attribute.Value.Trim());
  38. this.action = new Action(xml);
  39. }
  40. public override void accept(Visitor visitor)
  41. {
  42. visitor.visit (this);
  43. }
  44. }
  45. }