Custom class property and method attributes
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Thomas Satterly
el 10 de Sept. de 2019
Comentada: Thomas Satterly
el 4 de Nov. de 2019
I'd like to be able to define my own attributes in classes, but I'm not finding any documentation as to how that might be done. My main goal is to be able to create a property attribute, "UseAsReference", that marks object properties that need to be saved and loaded via custom methods because they are references to other Matlab handle objects. I'm hoping to accomplish this with property attributes and a superclass rather than defining an interface so that I don't have to worry about maintaining a constant list of reference properties and custom save/load functions for each implementing member. The pages for property and method attributes note that inheriting from certian frameworks (e.g., the UnitTest framework) will open up more attributes that a class can use. Is it possible to replicate this functionality?
2 comentarios
Adam
el 4 de Nov. de 2019
I'm not entirely sure what it is you are wanting, and didn't notice the question at the time, though as you seem to have found an answer now I guess it doesn't matter. I'd have thought dependent properties could have been utilised to achieve this though.
I did implement my own class called a JustInTimeProperty to store certain data in my classes too as I have cases where I want the property to only be calculated when first asked for, but then stored thereafter, rather than a pure dependent property which would always recalculate or a regular property which would have to be calculated upfront even if it is never actually asked for.
I can't remember the exact implementation i had for these and it isn't the same scenario you want anyway, but their usage did make use of dependent properties, paired with private properties.
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Entering Commands en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!