matlab.io.datastore.FileWritable - Add file writing support to datastore - MATLAB (original) (raw)

Main Content

Namespace: matlab.io.datastore

Add file writing support to datastore

Description

matlab.io.datastore.FileWritable is an abstract mixin class that adds file writing support to custom datastores by adding support for the writeall method.

To use this mixin class, you must inherit from thematlab.io.datastore.FileWritable class and the matlab.io.Datastore base class. Use this syntax as the first few lines in your class definition file:

classdef MyDatastore < matlab.io.Datastore & .... matlab.io.datastore.FileWritable ... end

To add support for file writing to your custom datastore, you must follow these requirements:

The matlab.io.datastore.FileWritable class is a handle class.

Properties

expand all

List of writable formats, returned as a string vector. This property lists all possible output formats that can be used with writeall. See Initialize Properties of Custom Datastore for an example of initializing this property in a subclass.

Attributes:

GetAccess public
SetAccess public
Constant true
Abstract true

Data Types: string

Default output format, returned as a string scalar. This property gives the output format to use with writeall when none is specified. See Initialize Properties of Custom Datastore for an example of initializing this property in a subclass.

Attributes:

GetAccess public
SetAccess public
Constant true
Abstract true

Data Types: string

Methods

Examples

collapse all

If you are authoring a custom datastore class that subclasses frommatlab.io.datastore.FileWritable to add file writing capabilities, then you need to initialize the properties SupportedOutputFormats andDefaultOutputFormat in the subclass.

For example, the subclass in Develop Custom Datastore for DICOM Data initializes these properties as:

properties (Constant) SupportedOutputFormats = ... [matlab.io.datastore.ImageDatastore.SupportedOutputFormats, "dcm"]; DefaultOutputFormat = "dcm"; end

"dcm" is a custom format that is also set to be the default, but the datastore also supports all supported output formats ofImageDatastore.

Version History

Introduced in R2020a