-
Notifications
You must be signed in to change notification settings - Fork 0
Tutorial 3 ( creating your own classes )
You can create your own database structure by defining a set of HDS Class definitions. The contents of these class definitions is not restricted apart from a couple of constants that define the relation of objects of this class to other classes. The HDSTemplate.m file (contents shown below) can be used as a template for creating you own classes.
Make sure to read the MATLAB help section on Object Oriented Programming for an introduction on using objects and classes in MATLAB.
The HDSTemplate file shows an example of a valid simple class-definition for the HDSToolbox.
- On the first line, you can see that the HDSTemplate class is a subclass of the HDS class.
- We defined 4 properties in this class. The first three properties don't have special attributes, and the last one is defined as a 'Transient' property. As we will see in the Constants section, the 'rawData' property is defined to contain 'data' values. These values will be stored in a separate file and therefore, the property should be defined as 'Transient' (Values not stored in object).
- Notice that all properties are initialized in the class-definition. This is not only proper coding, but also informs the HDSToolbox what type of data is stored in the property. If a property is not initialized, the HDSToolbox assumes the contents are numeric.
- Also note that each property has a help line following the property definition. This line is displayed in the Matlab command window when you use the PROPERTIES method. Use this to describe the contents of each property.
- The HDSToolbox does not limit the number of properties, or property-groups. You can add attributes as you wish as long as the 'data' properties are defined as 'Transient'.
listas : Default property name in which objects of this class reside.
classVersion : Version of class definition, changing this will result in a call to the update method for the class ('UPDATEOBJ').
childClasses : Cell array of strings indicating the classes that can be added to objects of this class.
parentClasses : Cell array of strings indicating the classes to which objects of this class can be added.
metaProps : Unused at this time, will be used to indicate which properties should be indexed for the search function.
dataProps : Indicates which properties contain raw data. Data in these properties will be stored separately such that the object can be loaded without loading the rawdata. These properties should be defined as 'Transient' in the properties section.
propsWithUnits : Indicates which properties have associated units. The length of this vector should be the same size as that of 'propUnits' and 'propDims'.
propUnits : Cell array with strings indicating the unit of the data in the property indicated at the same index in the 'propsWithUnits' property.
propsDims : Cell array with strings or cell array of strings indicating a label for each dimension of the data in the property indicated at the same index in the 'propsWithUnits' property.
strIndexProp : String indicating a property that contains strings which can be used for indexing instead of the numeric index (i.e. 'experiment('02-2009').trial(4)'
maskDisp : Cell array with strings that indicate properties that should not be evaluated when the object is displayed. This can be useful if you have dependent properties that take a while to return their content.