Base class for writing mitk::BaseData objects to files or streams.
More...
#include <mitkAbstractFileWriter.h>
Base class for writing mitk::BaseData objects to files or streams.
In general, all file writers should derive from this class to ensure that the implementation is exposed to the CppMicroServices framework and is automatically available throughout MITK. Subclasses need to implement Write() and Clone().
- See also
- IFileWriter
-
AbstractFileIO
-
AbstractFileReader
-
FileWriterSelector
Definition at line 54 of file mitkAbstractFileWriter.h.
◆ ~AbstractFileWriter()
| mitk::AbstractFileWriter::~AbstractFileWriter |
( |
| ) |
|
|
overrideprotected |
◆ AbstractFileWriter() [1/3]
Copy constructor.
- Parameters
-
| [in] | other | The writer to copy from. |
◆ AbstractFileWriter() [2/3]
| mitk::AbstractFileWriter::AbstractFileWriter |
( |
const std::string & |
baseDataType | ) |
|
|
protected |
Construct a writer for the given BaseData type name.
- Parameters
-
| [in] | baseDataType | The class name of the BaseData sub-class this writer supports. |
◆ AbstractFileWriter() [3/3]
| mitk::AbstractFileWriter::AbstractFileWriter |
( |
const std::string & |
baseDataType, |
|
|
const CustomMimeType & |
mimeType, |
|
|
const std::string & |
description |
|
) |
| |
|
protected |
Construct a writer for the given BaseData type, MIME type, and description.
- Parameters
-
| [in] | baseDataType | The class name of the BaseData sub-class this writer supports. |
| [in] | mimeType | The MIME type this writer produces. |
| [in] | description | A human-readable description of this writer. |
◆ AddProgressCallback()
| void mitk::AbstractFileWriter::AddProgressCallback |
( |
const ProgressCallback & |
callback | ) |
|
|
overridevirtual |
Register a progress callback.
- Parameters
-
| [in] | callback | The callback delegate to add. |
Implements mitk::IFileIO.
◆ GetBaseDataType()
| virtual std::string mitk::AbstractFileWriter::GetBaseDataType |
( |
| ) |
const |
|
protectedvirtual |
◆ GetConfidenceLevel()
◆ GetDefaultOptions()
| Options mitk::AbstractFileWriter::GetDefaultOptions |
( |
| ) |
const |
|
protected |
Get the default options for this writer.
- Returns
- A map of option names to default values.
◆ GetDescription()
| std::string mitk::AbstractFileWriter::GetDescription |
( |
| ) |
const |
|
protected |
Get the human-readable description of this writer.
- Returns
- The description string.
◆ GetInput()
| const BaseData* mitk::AbstractFileWriter::GetInput |
( |
| ) |
const |
|
overridevirtual |
◆ GetMimeType()
Get the MIME type this writer can handle.
- Returns
- Pointer to the internal CustomMimeType, or
nullptr.
◆ GetMimeTypePrefix()
| std::string mitk::AbstractFileWriter::GetMimeTypePrefix |
( |
| ) |
const |
|
protected |
Get the current MIME type name prefix.
- Returns
- The prefix string.
◆ GetOption()
| us::Any mitk::AbstractFileWriter::GetOption |
( |
const std::string & |
name | ) |
const |
|
overridevirtual |
Get the value of a specific option.
- Parameters
-
- Returns
- The option value.
Implements mitk::IFileIO.
◆ GetOptions()
| Options mitk::AbstractFileWriter::GetOptions |
( |
| ) |
const |
|
overridevirtual |
Get the current option values.
- Returns
- A map of option names to their current values.
Implements mitk::IFileIO.
◆ GetOutputLocation()
| std::string mitk::AbstractFileWriter::GetOutputLocation |
( |
| ) |
const |
|
overridevirtual |
◆ GetOutputStream()
| std::ostream* mitk::AbstractFileWriter::GetOutputStream |
( |
| ) |
const |
|
overridevirtual |
Get the current output stream.
- Returns
- The output stream, or
nullptr if writing to a file path.
Implements mitk::IFileWriter.
◆ GetRanking()
| int mitk::AbstractFileWriter::GetRanking |
( |
| ) |
const |
|
protected |
Get the service ranking for this file writer.
- Returns
- The ranking value.
◆ GetRegisteredMimeType()
| MimeType mitk::AbstractFileWriter::GetRegisteredMimeType |
( |
| ) |
const |
Get the MIME type that was registered for this writer.
- Returns
- The registered MimeType, which may be invalid if not yet registered.
◆ GetServiceProperties()
Get the service properties for registration.
- Returns
- A map of service property names to values.
◆ RegisterMimeType()
Register a new CustomMimeType service object.
Called internally from RegisterService(). The default implementation registers a new mime-type service if the mime-type has not been registered yet.
- Parameters
-
| [in] | context | The module context for registration. |
- Returns
- The service registration for the CustomMimeType.
- Exceptions
-
| std::invalid_argument | if context is nullptr. |
◆ RegisterService()
Register this writer as a CppMicroServices service.
Registers this writer with its mime-type in the service registry using a PrototypeServiceFactory, so that each consumer gets its own clone.
- Parameters
-
| [in] | context | The module context for service registration. Defaults to the current module context. |
- Returns
- The service registration object, or an invalid registration if the writer could not be registered.
◆ RemoveProgressCallback()
| void mitk::AbstractFileWriter::RemoveProgressCallback |
( |
const ProgressCallback & |
callback | ) |
|
|
overridevirtual |
Remove a previously registered progress callback.
- Parameters
-
| [in] | callback | The callback delegate to remove. |
Implements mitk::IFileIO.
◆ SetBaseDataType()
| void mitk::AbstractFileWriter::SetBaseDataType |
( |
const std::string & |
baseDataType | ) |
|
|
protected |
Set the name of the mitk::BaseData sub-class this writer supports.
- Parameters
-
| [in] | baseDataType | The class name, as returned by BaseData::GetNameOfClass(). |
◆ SetDefaultOptions()
| void mitk::AbstractFileWriter::SetDefaultOptions |
( |
const Options & |
defaultOptions | ) |
|
|
protected |
Set the default options for this writer.
- Parameters
-
| [in] | defaultOptions | A map of option names to default values. |
◆ SetDescription()
| void mitk::AbstractFileWriter::SetDescription |
( |
const std::string & |
description | ) |
|
|
protected |
Set a human-readable description of this writer.
- Parameters
-
| [in] | description | The description string, used in file dialogs. |
◆ SetInput()
| void mitk::AbstractFileWriter::SetInput |
( |
const BaseData * |
data | ) |
|
|
overridevirtual |
◆ SetMimeType()
| void mitk::AbstractFileWriter::SetMimeType |
( |
const CustomMimeType & |
mimeType | ) |
|
|
protected |
Set the MIME type this writer can handle.
- Parameters
-
◆ SetMimeTypePrefix()
| void mitk::AbstractFileWriter::SetMimeTypePrefix |
( |
const std::string & |
prefix | ) |
|
|
protected |
Set the prefix used for auto-generated MIME type names.
- Parameters
-
| [in] | prefix | The prefix string (e.g. "application/vnd.mitk"). |
◆ SetOption()
| void mitk::AbstractFileWriter::SetOption |
( |
const std::string & |
name, |
|
|
const us::Any & |
value |
|
) |
| |
|
overridevirtual |
Set a single option value.
- Parameters
-
| [in] | name | The option name. |
| [in] | value | The new option value. |
Implements mitk::IFileIO.
◆ SetOptions()
| void mitk::AbstractFileWriter::SetOptions |
( |
const Options & |
options | ) |
|
|
overridevirtual |
Set multiple options at once.
- Parameters
-
| [in] | options | A map of option names to their new values. |
Implements mitk::IFileIO.
◆ SetOutputLocation()
| void mitk::AbstractFileWriter::SetOutputLocation |
( |
const std::string & |
location | ) |
|
|
overridevirtual |
Set the output file-system path, clearing any output stream.
- Parameters
-
| [in] | location | The file path to write to. |
Implements mitk::IFileWriter.
◆ SetOutputStream()
| void mitk::AbstractFileWriter::SetOutputStream |
( |
const std::string & |
location, |
|
|
std::ostream * |
os |
|
) |
| |
|
overridevirtual |
Set an output stream and associated location label.
- Parameters
-
| [in] | location | A file-system path or custom label. |
| [in] | os | The output stream, or nullptr to clear. |
Implements mitk::IFileWriter.
◆ SetRanking()
| void mitk::AbstractFileWriter::SetRanking |
( |
int |
ranking | ) |
|
|
protected |
Set the service ranking for this file writer.
- Parameters
-
| [in] | ranking | The ranking value. Default is zero. |
The ranking is used to determine which writer to use if several equivalent writers have been found. Use a higher ranking to override a default writer from MITK in your own project.
◆ UnregisterService()
| void mitk::AbstractFileWriter::UnregisterService |
( |
| ) |
|
Unregister this writer from the CppMicroServices registry.
◆ ValidateOutputLocation()
| void mitk::AbstractFileWriter::ValidateOutputLocation |
( |
| ) |
const |
|
protected |
Validate the output location or stream.
- Exceptions
-
◆ Write()
| void mitk::AbstractFileWriter::Write |
( |
| ) |
|
|
overridepure virtual |
Write the base data to the specified location or output stream.
Subclasses must implement this method. Call GetOutputStream() first and check for a non-null stream to write to. If the output stream is nullptr, use GetOutputLocation() to write to a local file-system path.
If the writer cannot use streams directly, use LocalFile to retrieve a temporary local file name instead.
- Exceptions
-
- See also
- LocalFile
-
IFileWriter::Write()
Implements mitk::IFileWriter.
Implemented in mitk::PlyFileWriterService, mitk::PointSetWriterService, mitk::GeometryDataWriterService, mitk::ContourModelWriter, mitk::ContourModelSetWriter, mitk::ExampleDataStructureWriterService, mitk::SegmentationTaskListIO, mitk::ROIIO, mitk::PlanarFigureIO, mitk::MultiLabelSegmentationStackWriterBase, mitk::MultiLabelSegmentationIO, mitk::DICOMSegmentationIO, mitk::MAPRegistrationWrapperIO, mitk::PlyFileWriterService, mitk::DICOMPMIO, mitk::SurfaceVtkXmlIO, mitk::SurfaceVtkLegacyIO, mitk::SurfaceStlIO, mitk::PointSetWriterService, mitk::ImageVtkXmlIO, mitk::ImageVtkLegacyIO, mitk::ItkImageIO, mitk::GeometryDataWriterService, mitk::ContourModelWriter, mitk::ContourModelSetWriter, and mitk::ExampleDataStructureWriterService.
The documentation for this class was generated from the following file: