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.
Kesh Ikuma (2023). 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 .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Inspired by: HandleGraphicsSetGet class
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!
v2.5 - validateproperty now supports a new propopts.EmptyAllowed logical field.
v2.4a - (another) same-day update to fix an array creation bug.
Improved support for multiple-inheritance of hgsetgetex-based classes
Same-day bug fix for MultiSelect
* Better support multiple-inheritance of multiple hgsetgetex-based classes
v2.1-Bug fix in validateproperty.m
v2.1 - Bug Fix Release
Added full support for matlab.mixin.Heterogeneous subclasses
v1.3 (Jul. 7, 2014):
v1.2a - a bug fix in property validation and property set exception handling
v1.2 - a couple bug fixes
v1.1. - Changed init(obj) abstract function to be a scalar-object function.