Is there a way to give method/property access to all classes in a package without typing them all in manually?

2 vues (au cours des 30 derniers jours)
So I am writing a rather large application in appdesigner, and so I put a lot of the callbacks used by the app in a seperate class file where they are all accessed as static methods. I want these methods to be able to obviously access the private methods and private properties of the app object. For the properties of the app, I have something like this:
properties (Access = {?libs.callbacks.kinetics.Data, ...
?libs.callbacks.kinetics.Processes, ...
?libs.callbacks.kinetics.Figures})
Right now this is not a big deal, however, as I add more callbacks, this is going to get more and more annoying. I tried to just do:
properties (Access = ?libs.callbacks)
But this does not work (I am actually unsure what this even does, because it doesn't return an error or anything it just doesn't give access to any of the classes). Is there a way to give access to all the classes in a package without manually writing them all in into a class list?

Réponses (1)

Image Analyst
Image Analyst le 30 Juin 2022
I don't know what that "Access=" stuff is, but I know if you have an instance of a class or a static class you can do
methods(className)
properties(className)
and it will list them all. For example, with the attached class:
methods(Excel_utils);
Methods for class Excel_utils: Excel_utils Static methods: ActivateSheet ClearCells FormatCellFont InsertComments WrapText AlignCells DeleteEmptyExcelSheets FormatDecimalPlaces LeftAlignSheet AutoSizeAllSheets DeleteExcelSheets FormatLeftBorder MoveToSheet1 AutoSizeColumns DuplicateExcelSheet FormatRightBorder SetActiveCell CenterCellsAndAutoSizeColumns FormatBottomBorder GetNumberOfExcelSheets SetColumnWidth CenterCellsAndAutoSizeSpecificColumns FormatCellColor GoToNextRowInColumn SetRowHeight
properties(Excel_utils)
No properties for class Excel_utils.
  2 commentaires
Danila Berezin
Danila Berezin le 5 Juil 2022
Hi, thank you for the answer, but unfortunately it's not very helpful. I don't need a list of methods for a single class, I need a list of all the classes in a package.
Image Analyst
Image Analyst le 6 Juil 2022
You could easily write a script that looks at all m-files in a folder and determine which are class definitions by reading in the m-files line-by-line and then, for class files, find out what the methods and properties are. I'd be surprised if there is not something in the File Exchange already that does that. If there is not, and you can't figure out how to write the simple code to do it, write back and I'll do it if I find the time.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Software Development Tools dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by