|
Medical Imaging Interaction Toolkit
2026.06.00
Medical Imaging Interaction Toolkit
|
Base class for creating mitk::BaseData objects from files or streams. More...
#include <mitkAbstractFileReader.h>


Classes | |
| class | InputStream |
| An input stream wrapper for reader implementations. More... | |
Public Member Functions | |
| void | SetInput (const std::string &location) override |
| Set the input file path, clearing any previously set input stream. More... | |
| void | SetInput (const std::string &location, std::istream *is) override |
| Set an input stream and associated location label. More... | |
| std::string | GetInputLocation () const override |
| Get the current input location. More... | |
| std::istream * | GetInputStream () const override |
| Get the current input stream. More... | |
| MimeType | GetRegisteredMimeType () const |
| Get the mime-type that was registered for this reader. More... | |
| std::vector< itk::SmartPointer< BaseData > > | Read () override |
| Read data and create a list of BaseData objects. More... | |
| DataStorage::SetOfObjects::Pointer | Read (mitk::DataStorage &ds) override |
| Read data and add it to the given DataStorage. More... | |
| ConfidenceLevel | GetConfidenceLevel () const override |
| Determine confidence for reading the current input. More... | |
| Options | GetOptions () const override |
| Get the current option values. More... | |
| us::Any | GetOption (const std::string &name) const override |
| Get the value of a specific option. More... | |
| void | SetOptions (const Options &options) override |
| Set multiple options at once. More... | |
| void | SetOption (const std::string &name, const us::Any &value) override |
| Set a single option value. More... | |
| void | AddProgressCallback (const ProgressCallback &callback) override |
| Register a progress callback. More... | |
| void | RemoveProgressCallback (const ProgressCallback &callback) override |
| Remove a previously registered progress callback. More... | |
| us::ServiceRegistration< IFileReader > | RegisterService (us::ModuleContext *context=us::GetModuleContext()) |
| Register this reader as a CppMicroServices service. More... | |
| void | UnregisterService () |
| Unregister this reader from the CppMicroServices registry. More... | |
| std::vector< std::string > | GetReadFiles () override |
| Get the list of files consumed during the last Read() call. More... | |
| void | SetProperties (const PropertyList *properties) override |
| Set base data properties as a source of meta data for reading. More... | |
Public Member Functions inherited from mitk::IFileReader | |
| ~IFileReader () override | |
| virtual | ~IFileReader () |
Public Member Functions inherited from mitk::IFileIO | |
| virtual | ~IFileIO () |
Protected Member Functions | |
| AbstractFileReader () | |
| Default constructor. More... | |
| ~AbstractFileReader () override | |
| AbstractFileReader (const AbstractFileReader &other) | |
| Copy constructor. More... | |
| AbstractFileReader (const CustomMimeType &mimeType, const std::string &description) | |
| Associate this reader instance with the given MIME type. More... | |
| virtual std::vector< itk::SmartPointer< BaseData > > | DoRead ()=0 |
| Perform the actual reading operation. More... | |
| virtual us::ServiceProperties | GetServiceProperties () const |
| Get the service properties for registration. More... | |
| virtual us::ServiceRegistration< CustomMimeType > | RegisterMimeType (us::ModuleContext *context) |
| Register a new CustomMimeType service object. More... | |
| void | SetMimeType (const CustomMimeType &mimeType) |
| Set the MIME type this reader can handle. More... | |
| const CustomMimeType * | GetMimeType () const |
| Get the MIME type this reader can handle. More... | |
| void | SetMimeTypePrefix (const std::string &prefix) |
| Set the prefix used for auto-generated MIME type names. More... | |
| std::string | GetMimeTypePrefix () const |
| Get the current MIME type name prefix. More... | |
| void | SetDescription (const std::string &description) |
| Set the human-readable description of this reader. More... | |
| std::string | GetDescription () const |
| Get the human-readable description of this reader. More... | |
| void | SetDefaultOptions (const Options &defaultOptions) |
| Set the default options for this reader. More... | |
| Options | GetDefaultOptions () const |
| Get the default options for this reader. More... | |
| void | SetRanking (int ranking) |
| Set the service ranking for this file reader. More... | |
| int | GetRanking () const |
| Get the service ranking for this file reader. More... | |
| std::string | GetLocalFileName () const |
| Get a local file name for reading. More... | |
| virtual void | SetDefaultDataNodeProperties (DataNode *node, const std::string &filePath) |
| Set default properties on a DataNode after reading. More... | |
| const PropertyList * | GetProperties () const override |
| Get the properties set via SetProperties(). More... | |
Protected Attributes | |
| std::vector< std::string > | m_ReadFiles |
| List of files consumed during the last Read() call. Must be filled by DoRead(). More... | |
Additional Inherited Members | |
Public Types inherited from mitk::IFileIO | |
| enum | ConfidenceLevel { Unsupported , PartiallySupported , Supported } |
| A confidence level describing the reader's or writer's ability to handle the given data or file format. More... | |
| typedef std::map< std::string, us::Any > | Options |
| Options for reading or writing data. More... | |
| typedef mitk::MessageAbstractDelegate1< float > | ProgressCallback |
| Callback delegate type for progress reporting. More... | |
Static Public Member Functions inherited from mitk::IFileIO | |
| static std::string | PROP_DESCRIPTION () |
| Service property name for a human-readable description. More... | |
| static std::string | PROP_MIMETYPE () |
| Service property name for the mime-type associated with this reader or writer. More... | |
Base class for creating mitk::BaseData objects from files or streams.
AbstractFileReader provides the default implementation of the IFileReader interface. Subclasses only need to implement DoRead() and Clone(). The base class handles service registration via CppMicroServices, mime-type management, option handling, and progress callbacks.
Definition at line 53 of file mitkAbstractFileReader.h.
|
protected |
Default constructor.
|
overrideprotected |
|
protected |
Copy constructor.
| [in] | other | The reader to copy from. |
|
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().
| [in] | mimeType | The mime-type this reader can read. |
| [in] | description | A human-readable description of this reader. |
| std::invalid_argument | if mimeType is empty. |
|
overridevirtual |
Register a progress callback.
| [in] | callback | The callback delegate to add. |
Implements mitk::IFileIO.
|
protectedpure virtual |
Perform the actual reading operation.
Subclasses must implement this method. The implementation should 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.
| mitk::Exception | if reading fails. |
Implemented in mitk::SegmentationTaskListIO, mitk::SceneJsonFileReader, mitk::SceneFileReader, mitk::RTStructureSetReaderService, mitk::RTPlanReaderService, mitk::RTDoseReaderService, mitk::ROIIO, mitk::PlanarFigureIO, mitk::MultiLabelSegmentationStackReader, mitk::MultiLabelSegmentationIO, mitk::LegacyLabelSetImageIO, mitk::DICOMSegmentationIO, mitk::MAPRegistrationWrapperIO, mitk::PlyFileReaderService, mitk::ObjFileReaderService, mitk::DICOMPMIO, mitk::BaseDICOMReaderService, mitk::SurfaceVtkXmlIO, mitk::SurfaceVtkLegacyIO, mitk::SurfaceStlIO, mitk::RawImageFileReaderService, mitk::PointSetReaderService, mitk::ImageVtkXmlIO, mitk::ImageVtkLegacyIO, mitk::ItkImageIO, mitk::GeometryDataReaderService, mitk::ContourModelSetReader, mitk::ContourModelReader, and mitk::ExampleDataStructureReaderService.
|
overridevirtual |
Determine confidence for reading the current input.
Implements mitk::IFileIO.
Reimplemented in mitk::MultiLabelSegmentationStackReader, mitk::LegacyLabelSetImageIO, and mitk::BaseDICOMReaderService.
Referenced by mitk::AbstractFileIOReader::GetReaderConfidenceLevel().
|
protected |
Get the default options for this reader.
|
protected |
Get the human-readable description of this reader.
|
overridevirtual |
Get the current input location.
Implements mitk::IFileReader.
|
overridevirtual |
Get the current input stream.
nullptr if reading from a file path. Implements mitk::IFileReader.
|
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 set, this method returns the result of GetInputLocation(). If an input stream was set via SetInput(std::string, std::istream*), this method writes the stream contents to a temporary file and returns its path.
The temporary file is deleted when SetInput() is called again with a different input stream or when this reader is destroyed.
This method does not validate file names set via SetInput(std::string).
|
protected |
Get the MIME type this reader can handle.
nullptr.
|
protected |
Get the current MIME type name prefix.
|
overridevirtual |
Get the value of a specific option.
| [in] | name | The option name. |
Implements mitk::IFileIO.
|
overridevirtual |
Get the current option values.
Implements mitk::IFileIO.
|
overrideprotectedvirtual |
Get the properties set via SetProperties().
nullptr if none was set. Implements mitk::IFileReader.
|
protected |
Get the service ranking for this file reader.
|
overridevirtual |
Get the list of files consumed during the last Read() call.
Implements mitk::IFileReader.
| MimeType mitk::AbstractFileReader::GetRegisteredMimeType | ( | ) | const |
Get the mime-type that was registered for this reader.
|
protectedvirtual |
Get the service properties for registration.
|
overridevirtual |
Read data and create a list of BaseData objects.
The default implementation calls DoRead() and then annotates each resulting BaseData with meta-information about the reader, MIME type, input location, and reader options.
| mitk::Exception | if reading fails. |
Implements mitk::IFileReader.
Reimplemented in mitk::SegmentationTaskListIO, mitk::SceneJsonFileReader, mitk::SceneFileReader, mitk::RTStructureSetReaderService, mitk::RTPlanReaderService, mitk::RTDoseReaderService, mitk::ROIIO, mitk::PlanarFigureIO, mitk::MultiLabelSegmentationIO, mitk::LegacyLabelSetImageIO, mitk::DICOMSegmentationIO, mitk::MAPRegistrationWrapperIO, mitk::PlyFileReaderService, mitk::ObjFileReaderService, mitk::DICOMPMIO, mitk::BaseDICOMReaderService, mitk::SurfaceVtkXmlIO, mitk::SurfaceVtkLegacyIO, mitk::SurfaceStlIO, mitk::PointSetReaderService, mitk::ImageVtkXmlIO, mitk::ImageVtkLegacyIO, mitk::ItkImageIO, mitk::GeometryDataReaderService, mitk::ContourModelSetReader, mitk::ContourModelReader, mitk::CESTDICOMManualReaderService, mitk::CESTDICOMReaderService, mitk::ExampleDataStructureReaderService, mitk::SegmentationTaskListIO, mitk::SceneJsonFileReader, mitk::SceneFileReader, mitk::RTStructureSetReaderService, mitk::RTPlanReaderService, mitk::RTDoseReaderService, mitk::ROIIO, mitk::PlanarFigureIO, mitk::MultiLabelSegmentationIO, mitk::LegacyLabelSetImageIO, mitk::DICOMSegmentationIO, mitk::MAPRegistrationWrapperIO, mitk::PlyFileReaderService, mitk::ObjFileReaderService, mitk::DICOMPMIO, mitk::BaseDICOMReaderService, mitk::SurfaceVtkXmlIO, mitk::SurfaceVtkLegacyIO, mitk::SurfaceStlIO, mitk::PointSetReaderService, mitk::ImageVtkXmlIO, mitk::ImageVtkLegacyIO, mitk::ItkImageIO, mitk::GeometryDataReaderService, mitk::ContourModelSetReader, mitk::ContourModelReader, mitk::CESTDICOMManualReaderService, mitk::CESTDICOMReaderService, and mitk::ExampleDataStructureReaderService.
|
overridevirtual |
Read data and add it to the given DataStorage.
| [in,out] | ds | The DataStorage to add nodes to. |
ds. | mitk::Exception | if reading fails. |
Implements mitk::IFileReader.
Reimplemented in mitk::SceneJsonFileReader, and mitk::SceneFileReader.
|
protectedvirtual |
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.
| [in] | context | The module context for registration. |
| std::invalid_argument | if context is nullptr. |
| us::ServiceRegistration<IFileReader> mitk::AbstractFileReader::RegisterService | ( | us::ModuleContext * | context = us::GetModuleContext() | ) |
Register this reader as a CppMicroServices service.
Registers this reader with its mime-type in the service registry using a PrototypeServiceFactory, so that each consumer gets its own clone. If no MIME type for the configured extension is already registered, a new MIME type is registered automatically.
| [in] | context | The module context for service registration. Defaults to the current module context. |
|
overridevirtual |
Remove a previously registered progress callback.
| [in] | callback | The callback delegate to remove. |
Implements mitk::IFileIO.
|
protectedvirtual |
|
protected |
Set the default options for this reader.
| [in] | defaultOptions | A map of option names to default values. |
|
protected |
Set the human-readable description of this reader.
| [in] | description | The description string. |
|
overridevirtual |
Set the input file path, clearing any previously set input stream.
| [in] | location | The absolute file-system path to read from. |
Implements mitk::IFileReader.
|
overridevirtual |
Set an input stream and associated location label.
| [in] | location | A file-system path or custom label. |
| [in] | is | The input stream, or nullptr to clear. |
Implements mitk::IFileReader.
|
protected |
Set the MIME type this reader can handle.
| [in] | mimeType | The CustomMimeType to associate with this reader. |
|
protected |
Set the prefix used for auto-generated MIME type names.
| [in] | prefix | The prefix string (e.g. "application/vnd.mitk"). |
|
overridevirtual |
Set a single option value.
| [in] | name | The option name. |
| [in] | value | The new option value. |
Implements mitk::IFileIO.
|
overridevirtual |
Set multiple options at once.
| [in] | options | A map of option names to their new values. |
Implements mitk::IFileIO.
|
overridevirtual |
Set base data properties as a source of meta data for reading.
| [in] | properties | The PropertyList to use, or nullptr to clear. |
Implements mitk::IFileReader.
|
protected |
Set the service ranking for this file reader.
| [in] | ranking | The ranking value. Default is zero. |
The ranking is used to determine which reader to use if several equivalent readers have been found. Use a higher ranking to override a default reader from MITK in your own project.
| void mitk::AbstractFileReader::UnregisterService | ( | ) |
Unregister this reader from the CppMicroServices registry.
|
protected |
List of files consumed during the last Read() call. Must be filled by DoRead().
Definition at line 376 of file mitkAbstractFileReader.h.