Base class for creating mitk::BaseData objects from files or streams.
More...
#include <mitkAbstractFileReader.h>
Base class for creating mitk::BaseData objects from files or streams.
Definition at line 42 of file mitkAbstractFileReader.h.
◆ AbstractFileReader() [1/3]
mitk::AbstractFileReader::AbstractFileReader |
( |
| ) |
|
|
protected |
◆ ~AbstractFileReader()
mitk::AbstractFileReader::~AbstractFileReader |
( |
| ) |
|
|
overrideprotected |
◆ AbstractFileReader() [2/3]
◆ AbstractFileReader() [3/3]
mitk::AbstractFileReader::AbstractFileReader |
( |
const CustomMimeType & |
mimeType, |
|
|
const std::string & |
description |
|
) |
| |
|
explicitprotected |
Associate this reader instance with the given MIME type.
If mimeType
does not provide an extension list, an already registered mime-type object is used. Otherwise, the first entry in the extensions list is used to construct a mime-type name and register it as a new CustomMimeType service object in the default implementation of RegisterMimeType().
- Parameters
-
mimeType | The mime type this reader can read. |
description | A human readable description of this reader. |
- Exceptions
-
std::invalid_argument | if mimeType is empty. |
- See also
- RegisterService
◆ AddProgressCallback()
void mitk::AbstractFileReader::AddProgressCallback |
( |
const ProgressCallback & |
callback | ) |
|
|
overridevirtual |
◆ DoRead()
Method that should be implemented by derived classes and does the real loading. This method is called by Read(). This method must be implemented for each specific reader. Call GetInputStream() first and check for a non-null stream to read from. If the input stream is nullptr
, use GetInputLocation() to read from a local file-system path.
If the reader cannot use streams directly, use GetLocalFileName() instead.
- Returns
- The created BaseData objects.
- Exceptions
-
- See also
- GetLocalFileName()
-
IFileReader::Read()
Implemented in mitk::ItkImageIO, mitk::RTStructureSetReaderService, mitk::DICOMSegmentationIO, mitk::PlanarFigureIO, mitk::RTPlanReaderService, mitk::DICOMPMIO, mitk::MultiLabelSegmentationIO, mitk::ContourModelReader, mitk::GeometryDataReaderService, mitk::PointSetReaderService, mitk::RTDoseReaderService, mitk::LegacyLabelSetImageIO, mitk::ContourModelSetReader, mitk::MAPRegistrationWrapperIO, mitk::BaseDICOMReaderService, mitk::ExampleDataStructureReaderService, mitk::RawImageFileReaderService, mitk::SurfaceVtkLegacyIO, mitk::SurfaceVtkXmlIO, mitk::ImageVtkLegacyIO, mitk::ImageVtkXmlIO, mitk::LegacyFileReaderService, mitk::SurfaceStlIO, mitk::SegmentationTaskListIO, and mitk::ROIIO.
◆ GetConfidenceLevel()
◆ GetDefaultOptions()
Options mitk::AbstractFileReader::GetDefaultOptions |
( |
| ) |
const |
|
protected |
◆ GetDescription()
std::string mitk::AbstractFileReader::GetDescription |
( |
| ) |
const |
|
protected |
◆ GetInputLocation()
std::string mitk::AbstractFileReader::GetInputLocation |
( |
| ) |
const |
|
overridevirtual |
Get the current input location.
- Returns
- The input location.
Implements mitk::IFileReader.
◆ GetInputStream()
std::istream* mitk::AbstractFileReader::GetInputStream |
( |
| ) |
const |
|
overridevirtual |
Get the input stream.
- Returns
- The currently set input stream.
Implements mitk::IFileReader.
◆ GetLocalFileName()
std::string mitk::AbstractFileReader::GetLocalFileName |
( |
| ) |
const |
|
protected |
Get a local file name for reading.
This is a convenience method for readers which cannot work natively with input streams. If no input stream has been been set, this method just returns the result of GetLocation(). However, if SetLocation(std::string, std::istream*) has been called with a non-null input stream, this method writes the contents of the stream to a temporary file and returns the name of the temporary file.
The temporary file is deleted when either SetLocation(std::string, std::istream*) is called again with a different input stream or the destructor of this class is called.
This method does not validate file names set via SetInput(std::string).
- Returns
- A file path in the local file-system for reading.
◆ GetMimeType()
- Returns
- The mime-type this reader can handle.
◆ GetMimeTypePrefix()
std::string mitk::AbstractFileReader::GetMimeTypePrefix |
( |
| ) |
const |
|
protected |
◆ GetOption()
us::Any mitk::AbstractFileReader::GetOption |
( |
const std::string & |
name | ) |
const |
|
overridevirtual |
◆ GetOptions()
Options mitk::AbstractFileReader::GetOptions |
( |
| ) |
const |
|
overridevirtual |
returns a list of the supported options
Options are strings that are treated as flags when passed to the write method.
Implements mitk::IFileIO.
◆ GetProperties()
const PropertyList* mitk::AbstractFileReader::GetProperties |
( |
| ) |
const |
|
overrideprotectedvirtual |
◆ GetRanking()
int mitk::AbstractFileReader::GetRanking |
( |
| ) |
const |
|
protected |
◆ GetReadFiles()
std::vector< std::string > mitk::AbstractFileReader::GetReadFiles |
( |
| ) |
|
|
overridevirtual |
- Returns
- A list of files that were loaded during the last call of Read. Has to be filled by the actual reader class.
Implements mitk::IFileReader.
◆ GetRegisteredMimeType()
MimeType mitk::AbstractFileReader::GetRegisteredMimeType |
( |
| ) |
const |
◆ GetServiceProperties()
◆ Read() [1/2]
Reads a path or stream and creates a list of BaseData objects.
The default implementation of this method (1) calls DoRead() (Implement the specific reader operation there) and (2) it adds general meta information about the loading process.
Implements mitk::IFileReader.
◆ Read() [2/2]
DataStorage::SetOfObjects::Pointer mitk::AbstractFileReader::Read |
( |
mitk::DataStorage & |
ds | ) |
|
|
overridevirtual |
Reads the specified file or input stream, loading its contents into the provided DataStorage.
- Parameters
-
- Returns
- The set of added DataNodes to
ds
.
This method may be overridden by implementations to create or reconstructed a hierarchy of mitk::DataNode instances in the provided mitk::DataStorage.
- Exceptions
-
Implements mitk::IFileReader.
◆ RegisterMimeType()
Registers a new CustomMimeType service object.
This method is called from RegisterService and the default implementation registers a new mime-type service object if all of the following conditions are true:
- Parameters
-
- Returns
- Exceptions
-
std::invalid_argument | if context is nullptr. |
◆ RegisterService()
Associate this reader with the MIME type returned by the current IMimeTypeProvider service for the provided extension if the MIME type exists, otherwise registers a new MIME type when RegisterService() is called.
If no MIME type for extension
is already registered, a call to RegisterService() will register a new MIME type and associate this reader instance with it. The MIME type id can be set via SetMimeType() or it will be auto-generated using extension
, having the form "application/vnd.mitk.<extension>".
- Parameters
-
◆ RemoveProgressCallback()
void mitk::AbstractFileReader::RemoveProgressCallback |
( |
const ProgressCallback & |
callback | ) |
|
|
overridevirtual |
◆ SetDefaultDataNodeProperties()
virtual void mitk::AbstractFileReader::SetDefaultDataNodeProperties |
( |
DataNode * |
node, |
|
|
const std::string & |
filePath |
|
) |
| |
|
protectedvirtual |
◆ SetDefaultOptions()
void mitk::AbstractFileReader::SetDefaultOptions |
( |
const Options & |
defaultOptions | ) |
|
|
protected |
◆ SetDescription()
void mitk::AbstractFileReader::SetDescription |
( |
const std::string & |
description | ) |
|
|
protected |
◆ SetInput() [1/2]
void mitk::AbstractFileReader::SetInput |
( |
const std::string & |
location | ) |
|
|
overridevirtual |
Set the input location.
- Parameters
-
location | The file name to read from. |
Implements mitk::IFileReader.
◆ SetInput() [2/2]
void mitk::AbstractFileReader::SetInput |
( |
const std::string & |
location, |
|
|
std::istream * |
is |
|
) |
| |
|
overridevirtual |
Set an input stream to read from.
- Parameters
-
location | A custom label for the input stream. |
is | The input stream. |
If is
is nullptr
, this clears the current input stream and location
is interpreted as a file-system path. Otherwise, location
is a custom label describing the input stream is
.
Implements mitk::IFileReader.
◆ SetMimeType()
void mitk::AbstractFileReader::SetMimeType |
( |
const CustomMimeType & |
mimeType | ) |
|
|
protected |
◆ SetMimeTypePrefix()
void mitk::AbstractFileReader::SetMimeTypePrefix |
( |
const std::string & |
prefix | ) |
|
|
protected |
◆ SetOption()
void mitk::AbstractFileReader::SetOption |
( |
const std::string & |
name, |
|
|
const us::Any & |
value |
|
) |
| |
|
overridevirtual |
◆ SetOptions()
void mitk::AbstractFileReader::SetOptions |
( |
const Options & |
options | ) |
|
|
overridevirtual |
◆ SetProperties()
void mitk::AbstractFileReader::SetProperties |
( |
const PropertyList * |
properties | ) |
|
|
overridevirtual |
Optionally provide base data properties as a source of meta data.
The purpose of this method is not to preset the base data property list of the read data but to provide access to meta data of previous read operations that may be beneficial for the new read operation.
A typical usecase may occur when reading files from an MITK scene file in which case base data properties are already provided in addition to the actual data file. If such a data file references other files relative to its original location on the filesystem, the original location can be retrieved from the base data properties. In this scenario, GetInputLocation() would return a path within a temporary directory in which the scene file has been extracted. This is not the intended base path for searching referenced external data files.
Implements mitk::IFileReader.
◆ SetRanking()
void mitk::AbstractFileReader::SetRanking |
( |
int |
ranking | ) |
|
|
protected |
Set the service ranking for this file reader.
Default is zero and should only be chosen differently for a reason. The ranking is used to determine which reader to use if several equivalent readers have been found. It may be used to replace a default reader from MITK in your own project. E.g. if you want to use your own reader for nrrd files instead of the default, implement it and give it a higher ranking than zero.
◆ UnregisterService()
void mitk::AbstractFileReader::UnregisterService |
( |
| ) |
|
◆ m_ReadFiles
std::vector< std::string > mitk::AbstractFileReader::m_ReadFiles |
|
protected |
The documentation for this class was generated from the following file: