MATLAB Object-Oriented Programming

(Joyce) #1

The meta Package


The meta package contains metaclasses that describe the definition of classes and class
components. The class name indicates the component described by the metaclass. For
example, each class property has a meta.property associated with it. Attributes defined
for class components correspond to properties in the respective metaclass object.



  • meta.package — Access from meta.class ContainingPackage property.

  • meta.class — Create from class name or class object using metaclass function or?
    operator.

  • meta.property — Access from meta.class PropertyList property.

  • meta.DynamicProperty — Obtain from the addprop method.

  • meta.method — Access from meta.class MethodList property.

  • meta.event — Access from meta.class EventList property.

  • meta.EnumeratedValue — Access from meta.class
    EnumerationMemberListList property.


Metaclass Objects


You cannot instantiate metaclasses directly by calling the respective class constructor.
Create metaclass objects from class instances or from the class name.



  • ?ClassName — Returns a meta.class object for the named class. Use
    meta.class.fromName with class names stored as characters in variables.

  • meta.class.fromName('ClassName') — returns the meta.class object for the
    named class (meta.class.fromName is a meta.class method).

  • metaclass(obj) — Returns a metaclass object for the class instance (metaclass)


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


mc = ?MyClass;


Create meta.class object from class name using the fromName method:


mc = meta.class.fromName('MyClass');


Create meta.class object from class instance


obj = MyClass;
mc = metaclass(obj);


Class Metadata
Free download pdf