Medical Imaging Interaction Toolkit  2018.4.99-064ad45c
Medical Imaging Interaction Toolkit
mitk::AbstractFileReader Class Referenceabstract

Base class for creating mitk::BaseData objects from files or streams. More...

#include <mitkAbstractFileReader.h>

Inheritance diagram for mitk::AbstractFileReader:
Collaboration diagram for mitk::AbstractFileReader:

Classes

class  InputStream
 An input stream wrapper. More...
 

Public Member Functions

void SetInput (const std::string &location) override
 Set the input location. More...
 
void SetInput (const std::string &location, std::istream *is) override
 Set an input stream to read from. More...
 
std::string GetInputLocation () const override
 Get the current input location. More...
 
std::istream * GetInputStream () const override
 Get the input stream. More...
 
MimeType GetRegisteredMimeType () const
 
std::vector< itk::SmartPointer< BaseData > > Read () override
 Reads a path or stream and creates a list of BaseData objects. More...
 
DataStorage::SetOfObjects::Pointer Read (mitk::DataStorage &ds) override
 Reads the specified file or input stream, loading its contents into the provided DataStorage. More...
 
ConfidenceLevel GetConfidenceLevel () const override
 The confidence level of the reader or writer implementation. More...
 
Options GetOptions () const override
 returns a list of the supported options More...
 
us::Any GetOption (const std::string &name) const override
 
void SetOptions (const Options &options) override
 
void SetOption (const std::string &name, const us::Any &value) override
 
void AddProgressCallback (const ProgressCallback &callback) override
 
void RemoveProgressCallback (const ProgressCallback &callback) override
 
us::ServiceRegistration< IFileReaderRegisterService (us::ModuleContext *context=us::GetModuleContext())
 
void UnregisterService ()
 
std::vector< std::string > GetReadFiles () override
 
- Public Member Functions inherited from mitk::IFileReader
 ~IFileReader () override
 
virtual ~IFileReader ()
 
- Public Member Functions inherited from mitk::IFileIO
virtual ~IFileIO ()
 

Protected Member Functions

 AbstractFileReader ()
 
 ~AbstractFileReader () override
 
 AbstractFileReader (const AbstractFileReader &other)
 
 AbstractFileReader (const CustomMimeType &mimeType, const std::string &description)
 
virtual std::vector< itk::SmartPointer< BaseData > > DoRead ()=0
 
virtual us::ServiceProperties GetServiceProperties () const
 
virtual us::ServiceRegistration< CustomMimeTypeRegisterMimeType (us::ModuleContext *context)
 
void SetMimeType (const CustomMimeType &mimeType)
 
const CustomMimeTypeGetMimeType () const
 
void SetMimeTypePrefix (const std::string &prefix)
 
std::string GetMimeTypePrefix () const
 
void SetDescription (const std::string &description)
 
std::string GetDescription () const
 
void SetDefaultOptions (const Options &defaultOptions)
 
Options GetDefaultOptions () const
 
void SetRanking (int ranking)
 Set the service ranking for this file reader. More...
 
int GetRanking () const
 
std::string GetLocalFileName () const
 Get a local file name for reading. More...
 
virtual void SetDefaultDataNodeProperties (DataNode *node, const std::string &filePath)
 

Protected Attributes

std::vector< std::string > m_ReadFiles
 

Additional Inherited Members

- Public Types inherited from mitk::IFileIO
enum  ConfidenceLevel { Unsupported, PartiallySupported, Supported }
 A confidence level describing the confidence of the reader or writer in handling the given data. More...
 
typedef std::map< std::string, us::AnyOptions
 Options for reading or writing data. More...
 
typedef mitk::MessageAbstractDelegate1< float > ProgressCallback
 
- Static Public Member Functions inherited from mitk::IFileIO
static std::string PROP_DESCRIPTION ()
 Service property name for a description. More...
 
static std::string PROP_MIMETYPE ()
 Service property name for the mime-type associated with this file writer. More...
 

Detailed Description

Base class for creating mitk::BaseData objects from files or streams.

Definition at line 42 of file mitkAbstractFileReader.h.

Constructor & Destructor Documentation

◆ AbstractFileReader() [1/3]

mitk::AbstractFileReader::AbstractFileReader ( )
protected

Definition at line 61 of file mitkAbstractFileReader.cpp.

◆ ~AbstractFileReader()

mitk::AbstractFileReader::~AbstractFileReader ( )
overrideprotected

Definition at line 62 of file mitkAbstractFileReader.cpp.

References UnregisterService().

◆ AbstractFileReader() [2/3]

mitk::AbstractFileReader::AbstractFileReader ( const AbstractFileReader other)
protected

Definition at line 74 of file mitkAbstractFileReader.cpp.

◆ 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
mimeTypeThe mime type this reader can read.
descriptionA human readable description of this reader.
Exceptions
std::invalid_argumentif mimeType is empty.
See also
RegisterService

Definition at line 78 of file mitkAbstractFileReader.cpp.

Member Function Documentation

◆ AddProgressCallback()

void mitk::AbstractFileReader::AddProgressCallback ( const ProgressCallback callback)
overridevirtual

Implements mitk::IFileIO.

Definition at line 283 of file mitkAbstractFileReader.cpp.

◆ DoRead()

virtual std::vector<itk::SmartPointer<BaseData> > mitk::AbstractFileReader::DoRead ( )
protectedpure virtual

◆ GetConfidenceLevel()

IFileReader::ConfidenceLevel mitk::AbstractFileReader::GetConfidenceLevel ( ) const
overridevirtual

The confidence level of the reader or writer implementation.

Returns
Confidence level.

The level is used to rank multiple competing implementations.

Implements mitk::IFileIO.

Reimplemented in mitk::BaseDICOMReaderService.

Definition at line 128 of file mitkAbstractFileReader.cpp.

References GetInputLocation(), mitk::IFileIO::Supported, and mitk::IFileIO::Unsupported.

Referenced by mitk::BaseDICOMReaderService::GetConfidenceLevel(), and mitk::AbstractFileIOReader::GetReaderConfidenceLevel().

◆ GetDefaultOptions()

IFileReader::Options mitk::AbstractFileReader::GetDefaultOptions ( ) const
protected

◆ GetDescription()

std::string mitk::AbstractFileReader::GetDescription ( ) const
protected

◆ GetInputLocation()

◆ GetInputStream()

std::istream * mitk::AbstractFileReader::GetInputStream ( ) const
overridevirtual

◆ 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.

Definition at line 222 of file mitkAbstractFileReader.cpp.

References mitk::IOUtil::CreateTemporaryFile(), and GetInputLocation().

Referenced by mitk::LegacyFileReaderService::DoRead(), mitk::SurfaceStlIO::DoRead(), mitk::ImageVtkLegacyIO::DoRead(), mitk::RawImageFileReaderService::DoRead(), mitk::SurfaceVtkLegacyIO::DoRead(), mitk::BaseDICOMReaderService::DoRead(), mitk::MAPRegistrationWrapperIO::DoRead(), mitk::DICOMSegmentationIO::DoRead(), mitk::LabelSetImageIO::DoRead(), mitk::ItkImageIO::DoRead(), mitk::BaseDICOMReaderService::GetDICOMFilesInSameDirectory(), mitk::ImageVtkLegacyIO::GetReaderConfidenceLevel(), mitk::SurfaceVtkLegacyIO::GetReaderConfidenceLevel(), mitk::MAPRegistrationWrapperIO::GetReaderConfidenceLevel(), mitk::LabelSetImageIO::GetReaderConfidenceLevel(), mitk::RandomForestFileIO::GetReaderConfidenceLevel(), mitk::DICOMSegmentationIO::GetReaderConfidenceLevel(), mitk::ItkImageIO::GetReaderConfidenceLevel(), and mitk::MAPRegistrationWrapperIO::Write().

◆ GetMimeType()

const CustomMimeType * mitk::AbstractFileReader::GetMimeType ( ) const
protected
Returns
The mime-type this reader can handle.

Definition at line 291 of file mitkAbstractFileReader.cpp.

Referenced by mitk::AbstractFileIO::GetMimeType(), GetServiceProperties(), and RegisterService().

◆ GetMimeTypePrefix()

std::string mitk::AbstractFileReader::GetMimeTypePrefix ( ) const
protected

◆ GetOption()

us::Any mitk::AbstractFileReader::GetOption ( const std::string &  name) const
overridevirtual

◆ GetOptions()

IFileReader::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.

Definition at line 277 of file mitkAbstractFileReader.cpp.

Referenced by mitk::RawImageFileReaderService::DoRead(), mitk::CESTDICOMManualReaderService::GetOptions(), mitk::AbstractFileIO::GetReaderOptions(), mitk::CESTDICOMReaderService::Read(), and Read().

◆ 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.

Definition at line 216 of file mitkAbstractFileReader.cpp.

References m_ReadFiles.

◆ GetRegisteredMimeType()

MimeType mitk::AbstractFileReader::GetRegisteredMimeType ( ) const

◆ GetServiceProperties()

◆ Read() [1/2]

◆ 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
dsThe DataStorage to which the data is added.
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
mitk::Exception

Implements mitk::IFileReader.

Definition at line 113 of file mitkAbstractFileReader.cpp.

References mitk::DataStorage::Add(), GetInputLocation(), mitk::DataNode::New(), Read(), and SetDefaultDataNodeProperties().

◆ RegisterMimeType()

us::ServiceRegistration< CustomMimeType > mitk::AbstractFileReader::RegisterMimeType ( us::ModuleContext *  context)
protectedvirtual

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:

  • TODO
Parameters
context
Returns
Exceptions
std::invalid_argumentif context is nullptr.

Definition at line 211 of file mitkAbstractFileReader.cpp.

◆ RegisterService()

us::ServiceRegistration< IFileReader > mitk::AbstractFileReader::RegisterService ( us::ModuleContext *  context = us::GetModuleContext())

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
extensionThe file extension (without a leading period) for which a registered mime-type object is looked up and associated with this reader instance.
descriptionA human readable description of this reader.

Definition at line 147 of file mitkAbstractFileReader.cpp.

References GetMimeType(), us::GetModuleContext(), GetName(), GetServiceProperties(), and MITK_WARN.

Referenced by mitk::AutoSelectingDICOMReaderService::AutoSelectingDICOMReaderService(), mitk::CESTDICOMManualReaderService::CESTDICOMManualReaderService(), mitk::CESTDICOMReaderService::CESTDICOMReaderService(), mitk::ClassicDICOMSeriesReaderService::ClassicDICOMSeriesReaderService(), mitk::ContourModelReader::ContourModelReader(), mitk::ContourModelSetReader::ContourModelSetReader(), mitk::DummyLsetFileReader::DummyLsetFileReader(), mitk::ExampleDataStructureReaderService::ExampleDataStructureReaderService(), mitk::GeometryDataReaderService::GeometryDataReaderService(), mitk::LegacyFileReaderService::LegacyFileReaderService(), mitk::NavigationDataReaderCSV::NavigationDataReaderCSV(), mitk::NavigationDataReaderXML::NavigationDataReaderXML(), mitk::PointSetReaderService::PointSetReaderService(), mitk::RawImageFileReaderService::RawImageFileReaderService(), mitk::AbstractFileIO::RegisterService(), mitk::RTDoseReaderService::RTDoseReaderService(), mitk::RTPlanReaderService::RTPlanReaderService(), mitk::RTStructureSetReaderService::RTStructureSetReaderService(), mitk::SimpleVolumeDICOMSeriesReaderService::SimpleVolumeDICOMSeriesReaderService(), and mitk::USDeviceReaderXML::USDeviceReaderXML().

◆ RemoveProgressCallback()

void mitk::AbstractFileReader::RemoveProgressCallback ( const ProgressCallback callback)
overridevirtual

Implements mitk::IFileIO.

Definition at line 284 of file mitkAbstractFileReader.cpp.

◆ SetDefaultDataNodeProperties()

void mitk::AbstractFileReader::SetDefaultDataNodeProperties ( DataNode node,
const std::string &  filePath 
)
protectedvirtual

◆ SetDefaultOptions()

◆ SetDescription()

◆ SetInput() [1/2]

void mitk::AbstractFileReader::SetInput ( const std::string &  location)
overridevirtual

Set the input location.

Parameters
locationThe file name to read from.

Implements mitk::IFileReader.

Definition at line 257 of file mitkAbstractFileReader.cpp.

Referenced by mitk::ContourModelSetReader::DoRead().

◆ SetInput() [2/2]

void mitk::AbstractFileReader::SetInput ( const std::string &  location,
std::istream *  is 
)
overridevirtual

Set an input stream to read from.

Parameters
locationA custom label for the input stream.
isThe 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.

Definition at line 263 of file mitkAbstractFileReader.cpp.

◆ SetMimeType()

◆ SetMimeTypePrefix()

void mitk::AbstractFileReader::SetMimeTypePrefix ( const std::string &  prefix)
protected

◆ SetOption()

void mitk::AbstractFileReader::SetOption ( const std::string &  name,
const us::Any value 
)
overridevirtual

Implements mitk::IFileIO.

Definition at line 280 of file mitkAbstractFileReader.cpp.

Referenced by mitk::AbstractFileIO::SetReaderOption().

◆ SetOptions()

void mitk::AbstractFileReader::SetOptions ( const Options options)
overridevirtual

Implements mitk::IFileIO.

Definition at line 279 of file mitkAbstractFileReader.cpp.

Referenced by mitk::AbstractFileIO::SetReaderOptions().

◆ 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.

Definition at line 220 of file mitkAbstractFileReader.cpp.

Referenced by mitk::AutoSelectingDICOMReaderService::AutoSelectingDICOMReaderService(), mitk::DICOMPMIO::DICOMPMIO(), mitk::DICOMSegmentationIO::DICOMSegmentationIO(), mitk::ItkImageIO::ItkImageIO(), mitk::LabelSetImageIO::LabelSetImageIO(), mitk::PlanarFigureIO::PlanarFigureIO(), and mitk::AbstractFileIO::SetReaderRanking().

◆ UnregisterService()

void mitk::AbstractFileReader::UnregisterService ( )

Definition at line 190 of file mitkAbstractFileReader.cpp.

Referenced by ~AbstractFileReader().

Member Data Documentation

◆ m_ReadFiles

std::vector< std::string > mitk::AbstractFileReader::m_ReadFiles
protected

Definition at line 228 of file mitkAbstractFileReader.h.

Referenced by mitk::BaseDICOMReaderService::DoRead(), and GetReadFiles().


The documentation for this class was generated from the following files: