Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- note
- description: "Summary description for {TEMPERATURE_SENSOR}."
- author: ""
- date: "$Date$"
- revision: "$Revision$"
- class
- TEMPERATURE_SENSOR
- create
- make
- feature -- Initialization
- make
- -- Creation procedure
- do
- create {V_LINKED_LIST [PROCEDURE[ANY, TUPLE[REAL_64]]]} on_temperature_change
- end
- feature -- Subscription
- register (a_procedure: PROCEDURE[ANY, TUPLE[REAL_64]])
- -- Register a new observer.
- require
- a_procedure_exists: a_procedure /= void
- do
- if
- not on_temperature_change.has (a_procedure)
- then
- on_temperature_change.extend_back (a_procedure)
- end
- ensure
- a_procedure_exists: on_temperature_change.has (a_procedure)
- end
- unregister (a_procedure: PROCEDURE[ANY, TUPLE[REAL_64]])
- -- Unregister an existing observe-r.
- require
- a_procedure_exists: a_procedure /= void
- do
- if
- on_temperature_change.has (a_procedure)
- then
- on_temperature_change.remove (a_procedure)
- end
- ensure
- a_procedure_does_not_exist: not on_temperature_change.has (a_procedure)
- end
- feature -- Write / Set
- set_temperature (a_temperature: REAL_64)
- -- Set the new temperature.
- require
- temperature_input_exists: a_temperature /= void
- do
- temperature := a_temperature
- across
- on_temperature_change as i
- loop
- i.item.call (temperature)
- end
- ensure
- temperature_exists: temperature /= void
- temperature_is_correct: temperature = a_temperature
- end
- feature -- Access
- temperature: REAL_64
- -- Current temperature.
- on_temperature_change: V_LINKED_LIST [PROCEDURE[ANY, TUPLE[REAL_64]]]
- -- Actions performed on temperature change.
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement