Medical Imaging Interaction Toolkit  2018.4.99-b585543d
Medical Imaging Interaction Toolkit
mitk::AbstractFileWriter Class Referenceabstract

Base class for writing mitk::BaseData objects to files or streams. More...

#include <mitkAbstractFileWriter.h>

Inheritance diagram for mitk::AbstractFileWriter:
Collaboration diagram for mitk::AbstractFileWriter:

Classes

class  LocalFile
 A local file representation for streams. More...
 
class  OutputStream
 An output stream wrapper. More...
 

Public Member Functions

void SetInput (const BaseData *data) override
 Set the input data for writing. More...
 
const BaseDataGetInput () const override
 Get the input data set via SetInput(). More...
 
void SetOutputLocation (const std::string &location) override
 Set the output location. More...
 
std::string GetOutputLocation () const override
 Get the current output location. More...
 
void SetOutputStream (const std::string &location, std::ostream *os) override
 Set an output stream for writing. More...
 
std::ostream * GetOutputStream () const override
 Get the output stream. More...
 
void Write () override=0
 Write the base data to the specified location or output stream. More...
 
ConfidenceLevel GetConfidenceLevel () const override
 The confidence level of the reader or writer implementation. More...
 
MimeType GetRegisteredMimeType () const
 
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< IFileWriterRegisterService (us::ModuleContext *context=us::GetModuleContext())
 
void UnregisterService ()
 
- Public Member Functions inherited from mitk::IFileWriter
 ~IFileWriter () override
 
- Public Member Functions inherited from mitk::IFileIO
virtual ~IFileIO ()
 

Protected Member Functions

 ~AbstractFileWriter () override
 
 AbstractFileWriter (const AbstractFileWriter &other)
 
 AbstractFileWriter (const std::string &baseDataType)
 
 AbstractFileWriter (const std::string &baseDataType, 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)
 Sets a human readable description of this writer. More...
 
std::string GetDescription () const
 
void SetDefaultOptions (const Options &defaultOptions)
 
Options GetDefaultOptions () const
 
void SetRanking (int ranking)
 Set the service ranking for this file writer. More...
 
int GetRanking () const
 
void SetBaseDataType (const std::string &baseDataType)
 Sets the name of the mitk::Basedata that this writer is able to handle. More...
 
virtual std::string GetBaseDataType () const
 
void ValidateOutputLocation () const
 

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::IFileWriter
static std::string PROP_BASEDATA_TYPE ()
 Service property name for the supported mitk::BaseData sub-class. More...
 
- 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 writing mitk::BaseData objects to files or streams.

In general, all file writers should derive from this class, this way it is made sure that the new implementation is exposed to the Microservice-Framework and that is automatically available troughout MITK. The default implementation only requires one Write() method and the Clone() method to be implemented.

Definition at line 50 of file mitkAbstractFileWriter.h.

Constructor & Destructor Documentation

◆ ~AbstractFileWriter()

mitk::AbstractFileWriter::~AbstractFileWriter ( )
overrideprotected

Definition at line 125 of file mitkAbstractFileWriter.cpp.

References UnregisterService().

◆ AbstractFileWriter() [1/3]

mitk::AbstractFileWriter::AbstractFileWriter ( const AbstractFileWriter other)
protected

◆ AbstractFileWriter() [2/3]

mitk::AbstractFileWriter::AbstractFileWriter ( const std::string &  baseDataType)
protected

Definition at line 136 of file mitkAbstractFileWriter.cpp.

◆ AbstractFileWriter() [3/3]

mitk::AbstractFileWriter::AbstractFileWriter ( const std::string &  baseDataType,
const CustomMimeType mimeType,
const std::string &  description 
)
protected

Definition at line 141 of file mitkAbstractFileWriter.cpp.

Member Function Documentation

◆ AddProgressCallback()

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

Implements mitk::IFileIO.

Definition at line 262 of file mitkAbstractFileWriter.cpp.

◆ GetBaseDataType()

std::string mitk::AbstractFileWriter::GetBaseDataType ( ) const
protectedvirtual

Definition at line 273 of file mitkAbstractFileWriter.cpp.

◆ GetConfidenceLevel()

IFileWriter::ConfidenceLevel mitk::AbstractFileWriter::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::LegacyFileWriterService.

Definition at line 153 of file mitkAbstractFileWriter.cpp.

References mitk::IFileIO::Supported, and mitk::IFileIO::Unsupported.

Referenced by mitk::LegacyFileWriterService::GetConfidenceLevel(), and mitk::AbstractFileIOWriter::GetWriterConfidenceLevel().

◆ GetDefaultOptions()

IFileWriter::Options mitk::AbstractFileWriter::GetDefaultOptions ( ) const
protected

◆ GetDescription()

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

◆ GetInput()

const BaseData * mitk::AbstractFileWriter::GetInput ( ) const
overridevirtual

Get the input data set via SetInput().

Returns
The input data.

Implements mitk::IFileWriter.

Definition at line 110 of file mitkAbstractFileWriter.cpp.

Referenced by mitk::DICOMSegmentationIO::DoRead(), mitk::LegacyFileWriterService::GetConfidenceLevel(), mitk::SurfaceVtkIO::GetPolyData(), mitk::ImageVtkLegacyIO::GetWriterConfidenceLevel(), mitk::ImageVtkXmlIO::GetWriterConfidenceLevel(), mitk::MAPRegistrationWrapperIO::GetWriterConfidenceLevel(), mitk::RandomForestFileIO::GetWriterConfidenceLevel(), mitk::SurfaceVtkIO::GetWriterConfidenceLevel(), mitk::LabelSetImageIO::GetWriterConfidenceLevel(), mitk::PlanarFigureIO::GetWriterConfidenceLevel(), mitk::DICOMSegmentationIO::GetWriterConfidenceLevel(), mitk::DICOMPMIO::GetWriterConfidenceLevel(), mitk::ItkImageIO::GetWriterConfidenceLevel(), mitk::LegacyFileWriterService::Write(), mitk::NavigationDataSetWriterCSV::Write(), mitk::NavigationDataSetWriterXML::Write(), mitk::SurfaceStlIO::Write(), mitk::ImageVtkLegacyIO::Write(), mitk::ImageVtkXmlIO::Write(), mitk::ExampleDataStructureWriterService::Write(), mitk::SurfaceVtkLegacyIO::Write(), mitk::SurfaceVtkXmlIO::Write(), mitk::RandomForestFileIO::Write(), mitk::ContourModelSetWriter::Write(), mitk::MAPRegistrationWrapperIO::Write(), mitk::LabelSetImageIO::Write(), mitk::PlanarFigureIO::Write(), mitk::DICOMPMIO::Write(), mitk::DICOMSegmentationIO::Write(), mitk::ItkImageIO::Write(), mitk::TubeGraphIO::Write(), mitk::PointSetWriterService::Write(), mitk::GeometryDataWriterService::Write(), and mitk::ContourModelWriter::Write().

◆ GetMimeType()

const CustomMimeType * mitk::AbstractFileWriter::GetMimeType ( ) const
protected
Returns
Get the mime-type this writer can handle.

Definition at line 238 of file mitkAbstractFileWriter.cpp.

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

◆ GetMimeTypePrefix()

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

Definition at line 240 of file mitkAbstractFileWriter.cpp.

◆ GetOption()

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

Implements mitk::IFileIO.

Definition at line 257 of file mitkAbstractFileWriter.cpp.

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

◆ GetOptions()

IFileWriter::Options mitk::AbstractFileWriter::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 256 of file mitkAbstractFileWriter.cpp.

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

◆ GetOutputLocation()

std::string mitk::AbstractFileWriter::GetOutputLocation ( ) const
overridevirtual

◆ GetOutputStream()

◆ GetRanking()

int mitk::AbstractFileWriter::GetRanking ( ) const
protected

◆ GetRegisteredMimeType()

MimeType mitk::AbstractFileWriter::GetRegisteredMimeType ( ) const

Definition at line 166 of file mitkAbstractFileWriter.cpp.

◆ GetServiceProperties()

◆ RegisterMimeType()

us::ServiceRegistration< CustomMimeType > mitk::AbstractFileWriter::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 241 of file mitkAbstractFileWriter.cpp.

◆ RegisterService()

◆ RemoveProgressCallback()

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

Implements mitk::IFileIO.

Definition at line 263 of file mitkAbstractFileWriter.cpp.

◆ SetBaseDataType()

void mitk::AbstractFileWriter::SetBaseDataType ( const std::string &  baseDataType)
protected

Sets the name of the mitk::Basedata that this writer is able to handle.

The correct value is the one given as the first parameter in the mitkNewMacro of that BaseData derivate. You can also retrieve it by calling GetNameOfClass() on an instance of said data.

Definition at line 271 of file mitkAbstractFileWriter.cpp.

◆ SetDefaultOptions()

void mitk::AbstractFileWriter::SetDefaultOptions ( const Options defaultOptions)
protected

◆ SetDescription()

void mitk::AbstractFileWriter::SetDescription ( const std::string &  description)
protected

◆ SetInput()

void mitk::AbstractFileWriter::SetInput ( const BaseData data)
overridevirtual

Set the input data for writing.

Parameters
dataThe input data.

Implements mitk::IFileWriter.

Definition at line 109 of file mitkAbstractFileWriter.cpp.

Referenced by mitk::ContourModelSerializer::Serialize(), mitk::ContourModelSetSerializer::Serialize(), and mitk::ContourModelSetWriter::Write().

◆ SetMimeType()

◆ SetMimeTypePrefix()

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

◆ SetOption()

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

Implements mitk::IFileIO.

Definition at line 258 of file mitkAbstractFileWriter.cpp.

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

◆ SetOptions()

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

Implements mitk::IFileIO.

Definition at line 259 of file mitkAbstractFileWriter.cpp.

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

◆ SetOutputLocation()

void mitk::AbstractFileWriter::SetOutputLocation ( const std::string &  location)
overridevirtual

Set the output location.

Parameters
locationA file-system path.

The location argument specifies a file-system path where the input data must be written. This method must remove any previously set output stream.

Implements mitk::IFileWriter.

Definition at line 111 of file mitkAbstractFileWriter.cpp.

Referenced by mitk::ContourModelSerializer::Serialize(), mitk::ContourModelSetSerializer::Serialize(), mitk::MAPRegistrationWrapperSerializer::Serialize(), and mitk::ExampleDataStructureWriterService::Write().

◆ SetOutputStream()

void mitk::AbstractFileWriter::SetOutputStream ( const std::string &  location,
std::ostream *  os 
)
overridevirtual

Set an output stream for writing.

Parameters
locationA custom label for the output stream.
osThe output stream.

If os is nullptr, this clears the current output stream and location is interpreted as a file-system path. Otherwise, location is a custom label describing the output stream os.

Implements mitk::IFileWriter.

Definition at line 118 of file mitkAbstractFileWriter.cpp.

Referenced by mitk::ContourModelSetWriter::Write().

◆ SetRanking()

void mitk::AbstractFileWriter::SetRanking ( int  ranking)
protected

Set the service ranking for this file writer.

Default is zero and should only be chosen differently for a reason. The ranking is used to determine which writer to use if several equivalent writers have been found. It may be used to replace a default writer from MITK in your own project. E.g. if you want to use your own writer for nrrd files instead of the default, implement it and give it a higher ranking than zero.

Definition at line 247 of file mitkAbstractFileWriter.cpp.

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

◆ UnregisterService()

void mitk::AbstractFileWriter::UnregisterService ( )

Definition at line 212 of file mitkAbstractFileWriter.cpp.

Referenced by ~AbstractFileWriter().

◆ ValidateOutputLocation()

◆ Write()

void mitk::AbstractFileWriter::Write ( )
overridepure virtual

Write the base data to the specified location or output stream.

This method must be implemented for each specific writer. 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 reader cannot use streams directly, use GetLocalFile() to retrieve a temporary local file name instead.

Exceptions
mitk::Exception
See also
GetLocalFile()
IFileWriter::Write()

Implements mitk::IFileWriter.

Implemented in mitk::ContourModelWriter, mitk::GeometryDataWriterService, mitk::ItkImageIO, mitk::PointSetWriterService, mitk::DICOMPMIO, mitk::DICOMSegmentationIO, mitk::TubeGraphIO, mitk::LabelSetImageIO, mitk::PlanarFigureIO, mitk::MAPRegistrationWrapperIO, mitk::ContourModelSetWriter, mitk::RandomForestFileIO, mitk::SurfaceVtkLegacyIO, mitk::SurfaceVtkXmlIO, mitk::ExampleDataStructureWriterService, mitk::ImageVtkLegacyIO, mitk::ImageVtkXmlIO, mitk::USDeviceWriterXML, mitk::SurfaceStlIO, mitk::NavigationDataSetWriterXML, mitk::LegacyFileWriterService, and mitk::NavigationDataSetWriterCSV.


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