Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

Working with Meta-Classes

What Are Meta-Classes?

Meta-classes are classes that contain information about class definitions. Each block in a class definition has an associated meta-class that defines the attributes for that block. Each attribute corresponds to a property in the meta-class. An instance of a meta-class has values assigned to each property that correspond to the values of the attributes of the associated class block.

Meta-classes enable programmatic inspection of classes and objects. Tools such as property inspectors, debuggers, and so on, use these techniques.

The meta Package

The meta package contains meta-classes that MATLAB uses for the definition of classes and class components. The class name indicates the component described by the meta-class:

meta.package
meta.class
meta.property
meta.method
meta.event

Each meta-class has properties, methods, and events that contain information about the class or class component. See meta.package, meta.class, meta.property, meta.method and meta.event for more information on these meta-classes.

Creating Meta-Class Objects

You cannot instantiate meta-classes directly by calling the respective class constructor. You can create meta-class objects from class instances or from the class name.

% create meta-class object from class name using the ? operator
mobj = ?classname; 
% create meta-class object from class name using the fromName method
mobj = meta.class.fromName('classname'); 
% create meta-class object from class instance
obj = myClass;
mobj = metaclass(obj); 

The metaclass function returns the meta.class object (that is, an object of the meta.class class). You can obtain other meta-class objects (meta.property, meta.method, and so on) from the meta.class object.

Using Meta-Class Objects

Here is how you can use meta-class objects:

The following examples show these techniques.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS