/tutorial/signal/a.e

http://github.com/tybor/Liberty · Specman e · 28 lines · 20 code · 6 blank · 2 comment · 1 complexity · 2917b098cced032aeebccb798c177d3e MD5 · raw file

  1. class A
  2. creation {ANY}
  3. make
  4. feature {ANY}
  5. value_changed: SIGNAL_1[INTEGER] --declare variable of SIGNAL type, never inherit form SIGNAL.
  6. value: INTEGER
  7. feature {}
  8. make is
  9. do
  10. create value_changed.make
  11. end
  12. feature {ANY}
  13. set_val (v: INTEGER) is
  14. do
  15. -- Only emit if value really change (see signals.txt: when
  16. -- to use). Avoid infinite looping in case of cyclic connections.
  17. if v /= value then
  18. value := v
  19. value_changed.emit(v)
  20. end
  21. end
  22. end -- class A