MATLAB Object-Oriented Programming

(Joyce) #1

  1. A message is broadcast.

  2. The callback function is executed.

  3. A listener awaiting the message
    executes its callback.

  4. The SetObservable attribute of Properties
    is set to Tr ue, so setting the property
    automatically triggers a PostSet event.
    Note that methods and events did not have
    to be declared in myfunceval.

  5. New limits are assigned. myfunceval


Properties (SetObservable)
Lm

Listener

Properties
EventName = ‘PostSet’
FunctionHandle = @listenLm

myfuncview

Methods
listenLm

PostSet

obj.Lm = [-3 5];

Sequence During the Lm Property Assignment


The fcneval class defines a set function for the Lm property. When a value is assigned to
this property during object construction or property reassignment, the following
sequence occurs:


(^1) An attempt is made to assign argument value to Lm property.
(^2) The set.Lm method executes to check whether the value is in appropriate range — if
yes, it makes assignment, if no, it generates an error.
(^3) If the value of Lm is set successfully, MATLAB triggers a PostSet event.
(^4) All listeners execute their callbacks, but the order is nondeterministic.
Techniques for Using Events and Listeners

Free download pdf