File Exchange

image thumbnail

hgsetgetex: Extension of hgsetget Class (v.2.5)

version 1.15.0.0 (24.9 KB) by Kesh Ikuma
Extended HG-style set and get for MATLAB objects

1 Download

Updated 28 Aug 2014

View Version History

View License

--------------------
Caution for updating
--------------------
Following version updates affect derived class programming. Please update the derived classes accordingly.
[v2.3a -> v2.4+]: Constructor execution order has changed from init->processargin->setdefault->processprops to init->setdefault->processargin->processprops.
[v1.2a -> v1.3+]: init() method no longer passes through the constructor input arguments.
------------------
The hgsetgetex class is an abstract class that provides an HG-style property set and get interface. hgsetgetex is a subclass of handle and hgsetget, so any classes derived from hgsetgetex are handle classes.

classdef MyClass < hgsetgetex makes MyClass a subclass of hgsetgetex.

Classes that are derived from hgsetgetex inherit no public properties but do inherit methods that can be overridden as needed.

The key extensions to the built-in hgsetget class are:
1. hgsetgetex class constructor accepts a chain of property name-value pairs to initialize the object in a similar fashion as the HG constructors. In v.2.0+, derived class can override processargin.m to allow other input argument format.

2. hgsetgetex class supports construction of an object array in a similar fashion to the built-in functions like ones, zeros, etc. E.g., MyClass(4,2) creates a 4-by-2 array of MyClass objects.

3. hgsetgetex/set method implements a mechanism to display string options and other descriptions for its properties in its outcome.

4. hgsetgetex/validateproperty protected method may be used during property set methods to validate the new values.

5. hgsetgetex/propopts protected property provides a single location to store property information: option strings, other data type description and validator, and default value.

6. hgsetgetex requires subclass to implement "init" protected method to initialize the propopts struct.

7. hgsetgetex/sortpropopts protected method may be used to sort the display order of the public properties.

8. hgsetgetex supports subclasses of matlab.mixin.Heterogeneous class. When an object array of such subclass is constructed, the array is filled with the subclass objects.

9. A subclass may be based on multiple hgsetgetex-based superclasses. The constructor of the subclass should explicitly call the constructor of one of the hgsetgetex superclasses and its overriding init()/processargin() to account for all superclasses.

In addition to the class definition, hgsetgetex_demo.m file is included in the distribution to demonstrate the basic capability of hgsetgetex.

Cite As

Kesh Ikuma (2020). hgsetgetex: Extension of hgsetget Class (v.2.5) (https://www.mathworks.com/matlabcentral/fileexchange/47045-hgsetgetex-extension-of-hgsetget-class-v-2-5), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (0)

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: HandleGraphicsSetGet class

Community Treasure Hunt

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

Start Hunting!