Can I specify a package of classes as allowable subclasses?

When defining a class and specifying allowable subclasses (AllowedSubclasses = ?ClassName), can I specify a package instead? For example:
classdef SuperClass (AllowedSubclasses = ?PackageName)
...
or
classdef SuperClass (AllowedSubclasses = ?PackageName.*)
...
Thanks!
--Ryan

 Akzeptierte Antwort

Shruti Sapre
Shruti Sapre am 31 Aug. 2015

0 Stimmen

Hello Sean,
I understand that you want to use “AllowedSubclasses” function but with package names.
However, there isn’t a way of specifying that in MATLAB because the “AllowedSubclasses” parameter accepts only fully qualified class name while referencing a class name.
You can specify multiple classes in the “classdef” of your super class using the “AllowedSubclasses” parameter using a cell array of meta.class objects to define more than one allowed subclass:
classdef (AllowedSubclasses = {?ClassName1,?ClassName2,...?ClassNameN}) MySuperClass ... end
Please refer to the below link for more details on the same:
Hope this helps!
-Shruti

1 Kommentar

Shruti,
The key in your answer is when you say that the AllowedSubclasses parameter only accepts qualified class names.
I just wish I could specify an entire package of classes, rather than just individual classes.
Thanks!
--Ryan

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Class Introspection and Metadata finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 27 Aug. 2015

Kommentiert:

am 1 Sep. 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by