MATLAB Object-Oriented Programming

(Joyce) #1

Get Information About Properties


In this section...
“The meta.property Object” on page 16-14
“How to Find Properties with Specific Attributes” on page 16-17

The meta.property Object


Use the meta.property class to determine the values of property attributes. The
writable properties of a meta.property object correspond to the attributes of the
associated property. The values of the writable meta.property properties correspond to
the attribute values specified in the class definition.

Get the meta.property object for a property from the meta.class object. To get the
meta.class object for a class:


  • Use the metaclass function on an object of the class.

  • Use the? operator with the class name.


For example, the BasicHandle class defines three properties:

classdef BasicHandle < handle
properties (SetAccess = private)
Date = date
PassKey = randi(9,[1,7])
end
properties
Category {mustBeMember(Category,{'new','change'})} = 'new'
end
end

Create the meta.class object using the? operator with the class name:

mc = ?BasicHandle

mc =

class with properties:

Name: 'BasicHandle'
Description: ''

16 Information from Class Metadata

Free download pdf