MATLAB Object-Oriented Programming

(Joyce) #1

length(mpArray)
ans =
2


Now get a meta.property object from the array:


prop1 = mpArray(1);
prop1.Name


ans =


EmployeeName


The Name property of the meta.property object identifies the class property
represented by that meta.property object.


Query other meta.property object properties to determine the attributes of the
EmployeeName properties.


Find Component with Specific Attribute


You can use indexing techniques to list class components that have specific attribute
values. For example, this code lists the methods in the EmployeeData class that have
private access:


mc = ?EmployeeData;
mc.PropertyList(ismember({mc.PropertyList(:).SetAccess},'private')).Name


ans =


EmployeeNumber


Access is not a property of the meta.property class. Use SetAccess and GetAccess,
which are properties of the meta.property class.


Find components with attributes that are logical values using a statement like this one:


mc = ?handle;
mc.MethodList(ismember([mc.MethodList(:).Hidden],true)).Name


ans =


empty


Class Introspection with Metadata
Free download pdf