matlab.metadata.DynamicProperty - Describe dynamic property of MATLAB object - MATLAB (original) (raw)
Namespace: matlab.metadata
Superclasses: matlab.metadata.Property
Describe dynamic property of MATLAB object
Renamed from meta.DynamicProperty
in R2024a
Description
The matlab.metadata.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 thematlab.metadata.DynamicProperty
class correspond to property attributes. Dynamic properties are not defined in classdef
blocks, but you can set their attributes by setting the matlab.metadata.DynamicProperty
object properties.
Add a dynamic property to an object using the addprop
method of thedynamicprops
class. The addprop
method returns amatlab.metadata.DynamicProperty
instance representing the new dynamic property. You can modify the properties of the matlab.metadata.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 matlab.metadata.DynamicProperty
object.
See Dynamic Properties — Adding Properties to an Instance for more information.
The matlab.metadata.DynamicProperty
class is a handle class.
Creation
You cannot instantiate a matlab.metadata.DynamicProperty
object directly. The addprop
method returns a matlab.metadata.DynamicProperty
object when you add a dynamic property to an object. Use findprop to get the matlab.metadata.DynamicProperty
object for an object that already has a dynamic property.
Properties
Name
— Name of dynamic property
character vector
Name of the dynamic property, returned as a character vector.
Description
— Not used
empty character vector (default)
This property is not used.
DetailedDescription
— Not used
empty character vector (default)
This property is not used.
GetAccess
— Value of property attribute GetAccess
public
(default) | protected
| private
Value of property attribute GetAccess
, returned as one of these values:
public
– unrestricted access
protected
– access from class or subclasses
private
– access by class members only
SetAccess
— Value of property attribute SetAccess
public
(default) | protected
| private
Value of property attribute SetAccess
, returned as one of these:
public
– unrestricted access
protected
– access from class or subclasses
private
– access by class members only
Dependent
— Value of property attribute Dependent
false
(default) | true
Value of property attribute Dependent
, returned as a logical. Iffalse
, the property value is stored in the object. Iftrue
, the property value is not stored in the object and the set and get methods 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 Get and Set Methods for Dependent Properties.
Constant
— Value of property attribute Constant
false
(default)
Value of property attribute Constant
. For dynamic properties, the value is always false
. Changing the Constant
attribute of a dynamic property is not supported. Dynamic properties cannot be constant.
Abstract
— Value of property attribute Abstract
false
(default)
Value of property attribute Abstract
. For dynamic properties, the value is always false
. Changing the Abstract
attribute of a dynamic property is not supported. Dynamic properties cannot be abstract.
Transient
— Value of property attribute Transient
false
(default) | true
Value of property attribute Transient
, specified as a logical value. If true
, the property value is not saved when the object is saved to a file. See Default Save and Load Process for Objects for more about saving objects.
Hidden
— Value of property attribute Hidden
false
(default) | true
Value of property attribute Hidden
, returned as a logical value. This attribute determines if the property is shown in property lists, such as the Property Inspector or the output of the properties function.
GetObservable
— Value of property attribute GetObservable
false
(default) | true
Value of property attribute GetObservable
, 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.
SetObservable
— Value of property attribute SetObservable
false
(default) | true
Value of property attribute SetObservable
, specified as a logical value. If true
, listeners can be created for property set events. MATLAB calls the listeners whenever property values are modified. See Property-Set and Query Events.
AbortSet
— Value of property attribute AbortSet
false
(default) | true
Value of property attribute AbortSet
, 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 propertyPreSet
and PostSet
events.
NonCopyable
— Value of property attribute NonCopyable
true
(default) | false
Value of property attribute NonCopyable
, specified as a logical value. NonCopyable
determines if the dynamic property can be copied when the object is copied. By default, dynamic properties are not copied. For more information, see Exclude Properties from Copy.
PartialMatchPriority
— Value of property attribute PartialMatchPriority
1 (default) | positive integer
Value of property attribute PartialMatchPriority
, specified as a positive integer. This property is 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.
GetMethod
— Property get method
function handle or empty
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.
SetMethod
— Property set method
function handle or empty
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 Get and Set Methods.
HasDefault
— Indicates if property has default value
false
(default)
Indicates if the property has a default value. For dynamic properties, the value is always false
. Dynamic properties cannot define default values.
Validation
— Validation defined for property
empty matlab.metadata.Validation
array (default)
Validation defined for the property. For dynamic properties, the value is always an empty matlab.metadata.Validation
array. Dynamic properties do not support validation.
DefiningClass
— Class that defines the property
empty matlab.metadata.Class
array (default)
Class that defines the property. For dynamic properties, the value is always an empty matlab.metadata.Class
array. Dynamic properties are not defined by classes.
Events
Event Name | Trigger | Event Data | Event Attributes |
---|---|---|---|
PreGet | Event occurs just before the property value is queried. | event.PropertyEvent | NotifyAccess: privateListenAccess: public |
PostGet | Event occurs just after the property value has been queried. | event.PropertyEvent | NotifyAccess: privateListenAccess: public |
PreSet | Event occurs just before the property value is changed. | event.PropertyEvent | NotifyAccess: privateListenAccess: public |
PostSet | Event occurs just after the property value has been changed. | event.PropertyEvent | NotifyAccess: privateListenAccess: public |
Examples
Return matlab.metadata.DynamicProperty
Object
Create an instance of MySimpleClass
. Use the addprop method of the dynamicprops
class to add a dynamic property to an object and return a matlab.metadata.DynamicProperty
object.
classdef MySimpleClass < dynamicprops end
obj = MySimpleClass; mdp = addprop(obj,"InstanceProp")
mdp =
DynamicProperty with properties:
Name: 'InstanceProp'
Description: ''
DetailedDescription: ''
GetAccess: 'public'
SetAccess: 'public'
Dependent: 0
Constant: 0
Abstract: 0
Transient: 0
Hidden: 0
GetObservable: 0
SetObservable: 0
AbortSet: 0
NonCopyable: 1
PartialMatchPriority: 1
GetMethod: []
SetMethod: []
HasDefault: 0
Validation: [0×0 matlab.metadata.Validation]
DefiningClass: [0×0 matlab.metadata.Class]
Make the property hidden by setting the Hidden
property of thematlab.metadata.DynamicProperty
object.
Version History
Introduced in R2008a
R2024a: Renamed from meta.DynamicProperty
The namespace of DynamicProperty
has been changed frommeta
to matlab.metadata
. The behavior remains the same.
MATLAB will continue to recognize the old metaclass names in most contexts. However, code that relies on string comparisons to identify metaclasses might need to be updated to continue to work as expected. For example, if mObj
in the example below is a matlab.metadata.DynamicProperty
instance, the code under thecase
statement for 'meta.DynamicProperty'
does not execute because class(mObj)
returns'matlab.metadata.DynamicProperty'
.
switch class(mObj) case 'meta.DynamicProperty' % code to execute if mObj is a % meta.DynamicProperty instance ... end
To ensure this code continues to work as intended, use an if
statement with isa
. The isa
command recognizes both the old and new names of the class.
if isa(mObj,'meta.DynamicProperty') % code to execute if mObj is a % matlab.metadata.DynamicProperty instance else ... end
If compatibility with older releases of MATLAB is not a concern, you can update 'meta.DynamicProperty'
to'matlab.metadata.DynamicProperty'
. However, continue to use the old name if your code needs to run on versions of MATLAB before R2024a.