필터 지우기
필터 지우기

Can I specify a package of classes as allowable subclasses?

조회 수: 1 (최근 30일)
Ryan
Ryan 2015년 8월 27일
댓글: Ryan 2015년 9월 1일
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

채택된 답변

Shruti Sapre
Shruti Sapre 2015년 8월 31일
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
Ryan
Ryan 2015년 9월 1일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Software Development Tools에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by