Dynamic superclass name in call to superclass method.

1 vue (au cours des 30 derniers jours)
Cedric
Cedric le 5 Déc 2017
Modifié(e) : Cedric le 5 Déc 2017
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

Réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by