handle - Abstract class for deriving handle classes

Syntax

classdef myclass < handle

Description

The handle class is the superclass for all classes that follow handle semantics: a handle object indirectly references its data. If a handle object is copied, only the handle is copied and both objects refer to the same data. This behavior is equivalent to that of Handle Graphics® objects, where the handle of a graphics object always refers to a particular object regardless of whether you save the handle when you create the object, store it in another variable, or obtain it with convenience functions like findobj or gca.

The handle class is an abstract class so you cannot create an instance of this class directly. You use the handle class to derive other classes, which can be concrete classes whose instances are handle objects. See Value or Handle Class — Which to Use for information on using handle classes.

classdef myclass < handle makes myclass a subclass of the handle class.

Handle Class Methods

When you derive a class from the handle class, your class inherits the following methods.

MethodPurpose
addlistenerCreates a listener for the specified event and assigns a callback function to execute when the event occurs.
notifyBroadcast a notice that a specific event is occurring on a specified handle object or array of handle objects.
deleteHandle object destructor method that is called when the object's lifecycle ends.
dispHandle object disp method which is called by the display method. See the MATLAB®disp function.
displayHandle object display method called when MATLAB software interprets an expression returning a handle object that is not terminated by a semicolon. See the MATLABdisplay function.
findobjFinds objects matching the specified conditions from the input array of handle objects.
findpropReturns a meta.property objects associated with the specified property name.
fieldsReturns a cell array of string containing the names of public properties.
fieldnamesReturns a cell array of string containing the names of public properties. See the MATLABfieldnames function.
isvalidReturns a logical array in which elements are true if the corresponding elements in the input array are valid handles.
eq
ne
lt
le
gt
ge
relationaloperators
Relational functions return a logical array of the same size as the pair of input handle object arrays. Comparisons use a number associated with each handle. You can assume that the same two handles will compare as equal and the repeated comparison of any two handles will yield the same result in the same MATLAB session. Different handles are always not-equal. The order of handles is purely arbitrary, but consistent.
ctranspose transposeTransposes the elements of the handle object array.
permuteRearranges the dimensions of the handle object array. See the MATLABpermute function.
reshapeChanges the dimensions of the handle object array to the specified dimensions. See the MATLABreshape function.
sortSort the handle objects in any array in ascending or descending order. The order of handles is purely arbitrary, but reproducible in a given MATLAB session. See the MATLABsort function.

Handle Class Events

The handle class defines one event:

ObjectBeingDestroyed

This event is triggered when the handle object is about to be destroyed. If you define a listener for this event, its callback executes before the handle object is destroyed.

You can add a listener for this event using the addlistener method. See Defining Events and Listeners — Syntax and Techniques for more information on using events and listeners.

Handle Subclasses

There are two abstract handle subclasses that you can use to derive handle classes:

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS