Documentation

meta.property

meta.property class describes MATLAB class properties

Description

The meta.property class provides information about the properties of MATLAB® classes. The read/write properties of the meta.property class correspond to property attributes and are specified only from within your class definitions.

You can query the read-only properties of the meta.property object to obtain information that is specified syntactically by the class (for example, to obtain the function handle of a property's set access method).

You cannot instantiate a meta.property object directly. Obtain a meta.property object from the meta.class PropertyList property, which contains an array of meta.property objects, one for each class property. For example, replace ClassName with the name of the class whose properties you want to query:

mco = ?ClassName;
plist = mco.PropertyList;
plist(1).Name; % name of first property

Use the metaclass function to obtain a meta.class object from a class instance:

mco = metaclass(obj);

Properties

PropertyPurpose
Name read only

Name of the property.

Description read only

Currently not used

DetailedDescription read only

Currently not used

AbortSet attribute, default = false

If true, and this property belongs to a handle class, then MATLAB does not set the property value if the new value is the same as the current value. This prevents the triggering of property PreSet and PostSet events.

See Listen for Changes to Property Values

Abstract attribute, default = falseIf true, the property has no implementation, but a concrete subclass must redefine this property without Abstract being set to true.
  • Abstract properties cannot define set or get access methods. See Property Access Methods

  • Abstract properties cannot define initial values. Assigning a Default Value

  • All subclasses must specify the same values as the superclass for the property SetAccess and GetAccess attributes.

  • Abstract=true should be used with the class attribute Sealed=false (the default).

Access

public – unrestricted access

protected – access from class or subclasses

private – access by class members only (not subclasses)

List of classes that have get and set access to this property. Specify classes as meta.class objects in the form:

  • A single meta.class object

  • A cell array of meta.class objects. An empty cell array, {}, is the same as private access.

Use Access to set both SetAccess and GetAccess to the same value. Query the values of SetAccess and GetAccess directly (not Access).

Constant attribute, default = false

Set to true if you want only one value for this property in all instances of the class.

  • Subclasses inherit constant properties, but cannot change them.

  • Constant properties cannot be Dependent

  • SetAccess is ignored.

See Properties with Constant Values

DefaultValue

Property default value (if specified in class definition). See also HasDefault property. Abstract, dependent and dynamic properties cannot specify default values.

DefiningClassThe meta.class object representing the class that defines this property.
GetAccess attribute, default = public

public – unrestricted access

protected – access from class or subclasses

private – access by class members only

List classes that have get access to this property. Specify classes as meta.class objects in the form:

  • A single meta.class object

  • A cell array of meta.class objects. An empty cell array, {}, is the same as private access.

See Controlling Access to Class Members

Dependent attribute, default = false

If false, property value is stored in object. If true, property value is not stored in object and the set and get functions cannot access the property by indexing into the object using the property name.

See Property Get Methods

Transient attribute, default = false

If true, property value is not saved when object is saved to a file. See Understanding the Save and Load Process for more about saving objects.

GetMethod read only Function handle of the get method associated with this property. Empty if there is no get method specified. See Get Method Syntax
GetObservable attribute, default = falseIf true, and it is a handle class property, then listeners can be created for access to this property. The listeners are called whenever property values are queried. See Property-Set and Query Events
HasDefault

Property contains a boolean value indicating if the property defines a default value. Test HasDefault before querying the DefaultValue property to avoid a MATLAB:class:NoDefaultDefined error.

Hidden attribute, default = falseDetermines whether the property should be shown in a property list (e.g., Property Inspector, call to properties, etc.).
SetAccess attribute, default = public

public – unrestricted access

protected – access from class or subclasses

private – access by class members only

immutable — property can be set only in the constructor.

See Mutable and Immutable Properties

List classes that have set access to this property. Specify classes as meta.class objects in the form:

  • A single meta.class object

  • A cell array of meta.class objects. An empty cell array, {}, is the same as private access.

See Controlling Access to Class Members

SetMethod read onlyFunction handle of the set method associated with this property. Empty if there is no set method specified. See Property Set Methods
SetObservable attribute, default = falseIf true, and it is a handle class property, then listeners can be created for access to this property. The listeners are called whenever property values are modified. See Property-Set and Query Events

Events

See Listen for Changes to Property Values for information on using property events.

Event NamePurpose
PreGetEvent occurs just before property is queried.
PostGetEvent occurs just after property has been queried
PreSetEvent occurs just before this property is modified
PostSetEvent occurs just after this property has been modified

Was this topic helpful?