Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::FileWriterSelector Class Reference

Selects the most suitable IFileWriter for a given BaseData object. More...

#include <mitkFileWriterSelector.h>

Classes

class  Item
 Represents a single candidate file writer with associated metadata. More...
 

Public Member Functions

 FileWriterSelector (const FileWriterSelector &other)
 Copy constructor. More...
 
 FileWriterSelector (const BaseData *baseData, const std::string &destMimeType=std::string(), const std::string &path=std::string())
 Construct a selector for the given BaseData and optional mime-type/path. More...
 
 ~FileWriterSelector ()
 
FileWriterSelector & operator= (const FileWriterSelector &other)
 Copy assignment operator. More...
 
bool IsEmpty () const
 Check whether any suitable writers were found. More...
 
std::vector< Item > Get (const std::string &mimeType) const
 Get a sorted list of writer items filtered by mime-type. More...
 
std::vector< Item > Get () const
 Get a sorted list of writer items matching the currently selected mime-type. More...
 
Item Get (long id) const
 Get a writer item by its service id. More...
 
Item GetDefault () const
 Get the best-matching (highest-ranked) writer item. More...
 
long GetDefaultId () const
 Get the service id of the best-matching writer. More...
 
Item GetSelected () const
 Get the currently selected writer item. More...
 
long GetSelectedId () const
 Get the service id of the currently selected writer. More...
 
bool Select (const std::string &mimeType)
 Select the best writer for the given mime-type. More...
 
bool Select (const Item &item)
 Select a writer by Item. More...
 
bool Select (long id)
 Select a writer by its service id. More...
 
std::vector< MimeType > GetMimeTypes () const
 Get all mime-types for which at least one writer was found. More...
 
void Swap (FileWriterSelector &fws)
 Swap the contents of this selector with another. More...
 

Detailed Description

Selects the most suitable IFileWriter for a given BaseData object.

FileWriterSelector queries the service registry for all IFileWriter services that can write the given BaseData instance, optionally filtered by a destination mime-type or file path. It ranks the matching writers by confidence level, BaseData class hierarchy index, and service ranking, providing access to the best-matching (default) writer as well as all candidates.

See also
IFileWriter
FileReaderSelector
MimeType

Definition at line 45 of file mitkFileWriterSelector.h.

Constructor & Destructor Documentation

◆ FileWriterSelector() [1/2]

mitk::FileWriterSelector::FileWriterSelector ( const FileWriterSelector &  other)

Copy constructor.

Parameters
[in]otherThe FileWriterSelector to copy.

◆ FileWriterSelector() [2/2]

mitk::FileWriterSelector::FileWriterSelector ( const BaseData *  baseData,
const std::string &  destMimeType = std::string(),
const std::string &  path = std::string() 
)

Construct a selector for the given BaseData and optional mime-type/path.

Parameters
[in]baseDataThe BaseData object to find writers for.
[in]destMimeTypeOptional mime-type name to restrict results. If empty and a path is given, the mime-type is inferred from the path.
[in]pathOptional output file path to help infer the mime-type.

Queries the service registry for all IFileWriter services matching the given BaseData type and evaluates their confidence levels.

◆ ~FileWriterSelector()

mitk::FileWriterSelector::~FileWriterSelector ( )

Member Function Documentation

◆ Get() [1/3]

std::vector<Item> mitk::FileWriterSelector::Get ( ) const

Get a sorted list of writer items matching the currently selected mime-type.

Returns
An ordered vector of writer items.

◆ Get() [2/3]

std::vector<Item> mitk::FileWriterSelector::Get ( const std::string &  mimeType) const

Get a sorted list of writer items filtered by mime-type.

Items are sorted in ascending order by:

  1. Confidence level
  2. File writer service ranking

The best-matching item is at the back of the returned container. If mimeType is empty, all items are returned regardless of mime-type.

Parameters
[in]mimeTypeThe mime-type name to filter by, or empty for all.
Returns
A sorted vector of Item objects.

◆ Get() [3/3]

Item mitk::FileWriterSelector::Get ( long  id) const

Get a writer item by its service id.

Parameters
[in]idThe service id to look up.
Returns
The matching Item, or a default-constructed Item if not found.

◆ GetDefault()

Item mitk::FileWriterSelector::GetDefault ( ) const

Get the best-matching (highest-ranked) writer item.

Returns
The default Item, or a default-constructed Item if the selector is empty.

◆ GetDefaultId()

long mitk::FileWriterSelector::GetDefaultId ( ) const

Get the service id of the best-matching writer.

Returns
The service id, or -1 if the selector is empty.

◆ GetMimeTypes()

std::vector<MimeType> mitk::FileWriterSelector::GetMimeTypes ( ) const

Get all mime-types for which at least one writer was found.

Returns
A vector of MimeType objects.

◆ GetSelected()

Item mitk::FileWriterSelector::GetSelected ( ) const

Get the currently selected writer item.

Returns
The selected Item, or a default-constructed Item if none is selected.

◆ GetSelectedId()

long mitk::FileWriterSelector::GetSelectedId ( ) const

Get the service id of the currently selected writer.

Returns
The service id, or -1 if none is selected.

◆ IsEmpty()

bool mitk::FileWriterSelector::IsEmpty ( ) const

Check whether any suitable writers were found.

Returns
true if no writers are available for the given data.

◆ operator=()

FileWriterSelector& mitk::FileWriterSelector::operator= ( const FileWriterSelector &  other)

Copy assignment operator.

Parameters
[in]otherThe FileWriterSelector to assign from.
Returns
Reference to this selector.

◆ Select() [1/3]

bool mitk::FileWriterSelector::Select ( const Item &  item)

Select a writer by Item.

Parameters
[in]itemThe Item to select.
Returns
true if the selection was successful.

◆ Select() [2/3]

bool mitk::FileWriterSelector::Select ( const std::string &  mimeType)

Select the best writer for the given mime-type.

Parameters
[in]mimeTypeThe mime-type name to select by.
Returns
true if at least one writer with the given mime-type exists and was selected.

◆ Select() [3/3]

bool mitk::FileWriterSelector::Select ( long  id)

Select a writer by its service id.

Parameters
[in]idThe service id of the writer to select.
Returns
true if a writer with the given id exists and was selected.

◆ Swap()

void mitk::FileWriterSelector::Swap ( FileWriterSelector &  fws)

Swap the contents of this selector with another.

Parameters
[in,out]fwsThe FileWriterSelector to swap with.

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