Dynamic superclass name in call to superclass method.
조회 수: 2 (최근 30일)
이전 댓글 표시
Dear all,
but back then the only option seemed to involve the evil eval:
eval( ['methodName@', superclassName, '(args..)'] ) ;
Do you know if MATLAB implements a better mechanism now?
To give a little more information about the context, I am working on a framework that involves e.g. the following classes:
Project < ProjectKernel < Resource < ResourceKernel < Core < handle
each of which implements an errorManager method that produces extended error analysis/reporting. Now say the Core implements a method/validator for setting a user level : Core.set.userLevelId. If I try to set an invalid user level in a project object:
project = Project() ;
project.userLevelId = -1 ;
the error management mechanism makes Project.errorManager capture the error, which must delegate the creation of the error report to Core.errorManager (because each class implements the management of errors associated with its own specific features/resources). The class name Core can easily be extracted from dbstack, but right now it seems that the only way to call errorManager@Core(...) is by using the approach based on eval.
Of course, it would be more satisfactory to use nested try/catch statements and to filter/rethrow based on the identifier, but we are not in such a context with the hierarchy of classes.
Thanks,
Cedric
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Whos에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!