Main Content

meta.DynamicProperty class

Package: meta
Superclasses: meta.property

Describe dynamic property of MATLAB object

Description

The meta.DynamicProperty class contains descriptive information about dynamic properties that have been added to an instance of a MATLAB® class. To add a dynamic property to a class instance, the class must be a subclass of the dynamicprops class. The properties of the meta.DynamicProperty class correspond to property attributes. Dynamic properties are not defined in classdef blocks, but you can set their attributes by setting the meta.DynamicProperty object properties.

Add a dynamic property to an object using the addprop method of the dynamicprops class. The addprop method returns a meta.DynamicProperty instance representing the new dynamic property. You can modify the properties of the meta.DynamicProperty object to set the attributes of the dynamic property or to add set and get access methods, which, for regular properties, would be defined in the classdef file.

To remove the dynamic property, call the delete handle class method on the meta.DynamicProperty object.

See Dynamic Properties — Adding Properties to an Instance for more information.

The meta.DynamicProperty class is a handle class.

Class Attributes

Abstract
true
Sealed
true

For information on class attributes, see Class Attributes.

Creation

You cannot instantiate the meta.DynamicProperty class. The addprop method returns a meta.DynamicProperty when you add a dynamic property to an object. Use findprop to get the meta.DynamicProperty object for an object that already has a dynamic property.

Properties

expand all

Name of the dynamic property, returned as a character vector.

Data Types: char

Currently not used to collect information about the property from comments.

Data Types: char

Currently not used to collect information about the property from comments.

Data Types: char

What code can get this property value, returned as one of these:

public – unrestricted access

protected – access from class or subclasses

private – access by class members only

Data Types: enumerated

What code can set this property value, returned as one of these:

public – unrestricted access

protected – access from class or subclasses

private – access by class members only

Data Types: enumerated

If false (the default), property value is stored in the object. If true, the property value is not stored in the object and the set and get functions cannot access the property by indexing into the object using the property name. The value of a dependent property depends on some other value, therefore, dependent properties must define access methods to determine the value. For more information, see Set and Get Methods for Dependent Properties.

Data Types: logical

Setting the Constant attribute of a dynamic property is not allowed. Dynamic properties cannot be constant.

Data Types: logical

If 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 use with the class attribute Sealed=false (the default).

Data Types: logical

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

Data Types: logical

This attribute determines if the property is shown in property lists such as the Property Inspector or the output of the properties function.

Data Types: logical

Can listeners detect property pre and post get events, specified as a logical value. If true, then listeners can be created for property get events. MATLAB calls the listeners whenever property values are queried. See Property-Set and Query Events

Data Types: logical

Can listeners detect property pre and post set events, specified as a logical value. If true, then listeners can be created for property set events. MATLAB calls the listeners whenever property values are modified. See Property-Set and Query Events

Data Types: logical

Abort set operation if value unchanged, specified as a logical value. If true, then MATLAB does not set the property value if the new value is the same as the current value. Aborted set operations do not trigger the property PreSet and PostSet events.

Data Types: logical

Can property be copied, specified as a logical value. NonCopyable determines if dynamic property can be copied when object is copied. By default, dynamic properties are not copied. For more information, see Exclude Properties from Copy

Data Types: logical

Priority for partial name matching, specified as a positive integer. Used with subclasses of matlab.mixin.SetGet to define the relative priority of partial property name matches used in set and get methods. The default value is 1. Greater values assign lower priorities.

For more information, see Set Priority for Matching Partial Property Names.

Data Types: positive integer

Property get method, returned as a function handle. The function handle refers to the get method associated with this property. The value is empty if there is no get method specified. See Get Method Syntax

Data Types: function_handle

Property set method, returned as a function handle. The function handle refers to the set method associated with this property. The value is empty if there is no set method specified. See Property Set Methods

Data Types: function_handle

Always false for dynamic properties. Dynamic properties cannot define default values.

Data Types: logical

Dynamic properties do not support validation.

Data Types: meta.Validation

Dynamic properties are not defined by classes.

Data Types: meta.class

Events

Event NameTriggerEvent DataEvent Attributes
PreGetEvent occurs just before the property value is queried.event.PropertyEvent

NotifyAccess: private

ListenAccess: public

PostGetEvent occurs just after the property value has been queried.event.PropertyEvent

NotifyAccess: private

ListenAccess: public

PreSetEvent occurs just before the property value is changed.event.PropertyEvent

NotifyAccess: private

ListenAccess: public

PostSetEvent occurs just after the property value has been changed.event.PropertyEvent

NotifyAccess: private

ListenAccess: public

Examples

Return meta.DynamicProperty Object

Use the dynamicprops addprop method to add a dynamic property to an object and return a meta.DynamicProperty object. Make the property hidden by setting the Hidden property of the meta.DynamicProperty.

classdef MySimpleClass < dynamicprops
end
obj = MySimpleClass;
mdp = addprop(obj,'InstanceProp');
mdp.Hidden = true;
Introduced in R2008a