Medical Imaging Interaction Toolkit  2016.11.0
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

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

Protected Member Functions

 AbstractFileReader ()
 
 ~AbstractFileReader ()
 
 AbstractFileReader (const AbstractFileReader &other)
 
 AbstractFileReader (const CustomMimeType &mimeType, const std::string &description)
 
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)
 

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 46 of file mitkAbstractFileReader.h.

Constructor & Destructor Documentation

mitk::AbstractFileReader::AbstractFileReader ( )
protected

Definition at line 64 of file mitkAbstractFileReader.cpp.

mitk::AbstractFileReader::~AbstractFileReader ( )
protected

Definition at line 65 of file mitkAbstractFileReader.cpp.

References UnregisterService().

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

Definition at line 77 of file mitkAbstractFileReader.cpp.

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 81 of file mitkAbstractFileReader.cpp.

Member Function Documentation

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

Implements mitk::IFileIO.

Definition at line 273 of file mitkAbstractFileReader.cpp.

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

Definition at line 120 of file mitkAbstractFileReader.cpp.

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

Referenced by mitk::AbstractFileIOReader::GetReaderConfidenceLevel().

IFileReader::Options mitk::AbstractFileReader::GetDefaultOptions ( ) const
protected
std::string mitk::AbstractFileReader::GetDescription ( ) const
protected
std::istream * mitk::AbstractFileReader::GetInputStream ( ) const
overridevirtual
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 212 of file mitkAbstractFileReader.cpp.

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

Referenced by mitk::ImageVtkLegacyIO::GetReaderConfidenceLevel(), mitk::SurfaceVtkLegacyIO::GetReaderConfidenceLevel(), mitk::MAPRegistrationWrapperIO::GetReaderConfidenceLevel(), mitk::RandomForestFileIO::GetReaderConfidenceLevel(), mitk::ItkImageIO::GetReaderConfidenceLevel(), mitk::LabelSetImageIO::GetReaderConfidenceLevel(), mitk::BaseDICOMReaderService::GetRelevantFiles(), mitk::DicomSeriesReaderService::Read(), mitk::ImageVtkLegacyIO::Read(), mitk::SurfaceStlIO::Read(), mitk::SurfaceVtkLegacyIO::Read(), mitk::MAPRegistrationWrapperIO::Read(), mitk::BaseDICOMReaderService::Read(), mitk::ItkImageIO::Read(), mitk::LabelSetImageIO::Read(), and mitk::MAPRegistrationWrapperIO::Write().

const CustomMimeType * mitk::AbstractFileReader::GetMimeType ( ) const
protected
std::string mitk::AbstractFileReader::GetMimeTypePrefix ( ) const
protected

Definition at line 283 of file mitkAbstractFileReader.cpp.

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

Implements mitk::IFileIO.

Definition at line 268 of file mitkAbstractFileReader.cpp.

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

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 267 of file mitkAbstractFileReader.cpp.

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

int mitk::AbstractFileReader::GetRanking ( ) const
protected
MimeType mitk::AbstractFileReader::GetRegisteredMimeType ( ) const
std::vector< BaseData::Pointer > mitk::AbstractFileReader::Read ( )
overridepure virtual

Reads a path or stream and creates a list of BaseData objects.

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 NULL, 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
mitk::Exception
See also
GetLocalFileName()
IFileReader::Read()

Implements mitk::IFileReader.

Implemented in mitk::RTDoseReader, mitk::GeometryDataReaderService, mitk::PointSetReaderService, mitk::DiffusionImageNiftiReaderService, mitk::DiffusionImageNrrdReaderService, mitk::NrrdTensorImageReader, mitk::ContourModelSetReader, mitk::ContourModelReader, mitk::NrrdQBallImageReader, mitk::LabelSetImageIO, mitk::ItkImageIO, mitk::ConnectomicsNetworkReader, mitk::FiberBundleTrackVisReader, mitk::FiberBundleVtkReader, mitk::PlanarFigureCompositeReader, mitk::TubeGraphIO, mitk::RandomForestFileIO, mitk::RawImageFileReaderService, mitk::ExampleDataStructureReaderService, mitk::NavigationDataReaderCSV, mitk::NavigationDataReaderXML, mitk::DummyLsetFileReader, mitk::BaseDICOMReaderService, mitk::MAPRegistrationWrapperIO, mitk::LegacyFileReaderService, mitk::SurfaceVtkLegacyIO, mitk::SurfaceVtkXmlIO, mitk::ImageVtkLegacyIO, mitk::ImageVtkXmlIO, mitk::SurfaceStlIO, mitk::SimulationIO, and mitk::DicomSeriesReaderService.

Definition at line 89 of file mitkAbstractFileReader.cpp.

References mitk::StandaloneDataStorage::New().

Referenced by Read().

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 105 of file mitkAbstractFileReader.cpp.

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

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

Definition at line 203 of file mitkAbstractFileReader.cpp.

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 139 of file mitkAbstractFileReader.cpp.

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

Referenced by mitk::AutoSelectingDICOMReaderService::AutoSelectingDICOMReaderService(), mitk::ClassicDICOMSeriesReaderService::ClassicDICOMSeriesReaderService(), mitk::ConnectomicsNetworkReader::ConnectomicsNetworkReader(), mitk::ContourModelReader::ContourModelReader(), mitk::ContourModelSetReader::ContourModelSetReader(), mitk::DicomSeriesReaderService::DicomSeriesReaderService(), mitk::DiffusionImageNiftiReaderService::DiffusionImageNiftiReaderService(), mitk::DiffusionImageNrrdReaderService::DiffusionImageNrrdReaderService(), mitk::ExampleDataStructureReaderService::ExampleDataStructureReaderService(), mitk::FiberBundleTrackVisReader::FiberBundleTrackVisReader(), mitk::FiberBundleVtkReader::FiberBundleVtkReader(), mitk::GeometryDataReaderService::GeometryDataReaderService(), mitk::LegacyFileReaderService::LegacyFileReaderService(), mitk::NavigationDataReaderCSV::NavigationDataReaderCSV(), mitk::NavigationDataReaderXML::NavigationDataReaderXML(), mitk::NrrdQBallImageReader::NrrdQBallImageReader(), mitk::NrrdTensorImageReader::NrrdTensorImageReader(), mitk::PlanarFigureCompositeReader::PlanarFigureCompositeReader(), mitk::PointSetReaderService::PointSetReaderService(), mitk::RawImageFileReaderService::RawImageFileReaderService(), mitk::AbstractFileIO::RegisterService(), and mitk::RTDoseReader::RTDoseReader().

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

Implements mitk::IFileIO.

Definition at line 274 of file mitkAbstractFileReader.cpp.

void mitk::AbstractFileReader::SetDefaultDataNodeProperties ( DataNode node,
const std::string &  filePath 
)
protectedvirtual
void mitk::AbstractFileReader::SetDefaultOptions ( const Options defaultOptions)
protected
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 247 of file mitkAbstractFileReader.cpp.

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

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 NULL, 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 253 of file mitkAbstractFileReader.cpp.

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

Implements mitk::IFileIO.

Definition at line 270 of file mitkAbstractFileReader.cpp.

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

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

Implements mitk::IFileIO.

Definition at line 269 of file mitkAbstractFileReader.cpp.

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

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 210 of file mitkAbstractFileReader.cpp.

Referenced by mitk::ItkImageIO::ItkImageIO(), mitk::LabelSetImageIO::LabelSetImageIO(), and mitk::AbstractFileIO::SetReaderRanking().

void mitk::AbstractFileReader::UnregisterService ( )

Definition at line 182 of file mitkAbstractFileReader.cpp.

Referenced by ~AbstractFileReader().


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