MATLAB 2009a Class Event Properties

From ControlTheoryPro.com

Jump to: navigation, search
Symbol.gif
MATLAB 2009a Class Event Properties
Green carrot left.gif
Classdef Method Attributes
Green carrot.jpg
In order to prevent spam, users must register before they can edit or create articles.


1 Introduction to MATLAB 2009a Class Event Properties

Classes in MATLAB 2009a can have multiple events. After the classdef command line you must define your class properties, then methods, and finally events. All available attributes are listed in the event properties table.

1.1 What is an Event?[1]

Events represent changes or actions that occur within class instances. For example,

  • Modification of class data
  • Execution of a method
  • Querying or setting a property value
  • Destruction of an object

Basically, any activity that can be detected programmatically can generate an event and communicate information to other objects.

MATLAB classes define a process that communicates the occurrence of events to other objects that need to respond to the events. The event model works this way:

  • A handle class declares a name used to represent an event. Naming Events
  • After an instance of the event-declaring class is created, you can attach listener objects to it. Ways to Create Listeners
  • A class method call broadcasts a notice of the event to listeners and the class user is responsible for determining when to declare that the event has occurred. Triggering Events
  • Listeners execute a callback function when notified that the event has occurred. Defining Listener Callback Functions
  • Listeners can be bound to the lifecycle of the object that defines the event or limited to the existence and scope of a listener object. Ways to Create Listeners

1.2 Example Event Definitions

Events are defined after properties and methods. You can create an event listener using the MATLAB addlistner command.

 classdef ...
   % Public
   properties
     ...
   end
   
   ...
   
   methods
     ...
   end
   
   ...
   
   events
     ...
   end

See the psdData Class Example for more information.

2 Table of Class Event Properties[2]

PropertyPurpose
Name read only

Name of the event.

Description read only

Currently not used

DetailedDescription read only

Currently not used

Hidden

If true, the event does not appear

in the list of events returned by the events function

(or other event listing functions or viewers)

ListenAccess

Determines where you can create listeners for the event.

  • public — unrestricted access

  • protected — access from methods in class or derived classes

  • private — access by class methods only (not from derived classes)

NotifyAccess

Determines where code can trigger the event.

  • public — any code can trigger event

  • protected — can trigger event from methods in class or derived classes

  • private — can trigger event by class methods only (not from derived classes)

DefiningClassThe meta.class object representing the class that defines this event.


3 References

MATLAB 2009a Help

3.1 Notes

  1. Events and Listeners - Concepts
  2. Event Properties


4 MATLAB Related Books