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

Selects the most suitable IFileReader for a given file path. More...

#include <mitkFileReaderSelector.h>

Classes

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

Public Member Functions

 FileReaderSelector (const FileReaderSelector &other)
 Copy constructor. More...
 
 FileReaderSelector (const std::string &path)
 Construct a selector for the given file path. More...
 
 ~FileReaderSelector ()
 
FileReaderSelector & operator= (const FileReaderSelector &other)
 Copy assignment operator. More...
 
bool IsEmpty () const
 Check whether any suitable readers were found. More...
 
std::vector< MimeType > GetMimeTypes () const
 Get all mime-types that matched the file path. More...
 
std::vector< Item > Get () const
 Get a sorted list of all file reader items. More...
 
Item Get (long id) const
 Get a reader item by its service id. More...
 
Item GetDefault () const
 Get the best-matching (highest-ranked) reader item. More...
 
long GetDefaultId () const
 Get the service id of the best-matching reader. More...
 
Item GetSelected () const
 Get the currently selected reader item. More...
 
long GetSelectedId () const
 Get the service id of the currently selected reader. More...
 
bool Select (const Item &item)
 Select a reader by Item. More...
 
bool Select (long id)
 Select a reader by its service id. More...
 
void Swap (FileReaderSelector &fws)
 Swap the contents of this selector with another. More...
 

Detailed Description

Selects the most suitable IFileReader for a given file path.

FileReaderSelector queries the service registry for all IFileReader services whose registered mime-types match the given file path. It ranks the matching readers by confidence level, mime-type ordering, and service ranking, and provides access to the best-matching (default) reader as well as all candidates.

See also
IFileReader
FileReaderRegistry
FileWriterSelector
MimeType

Definition at line 45 of file mitkFileReaderSelector.h.

Constructor & Destructor Documentation

◆ FileReaderSelector() [1/2]

mitk::FileReaderSelector::FileReaderSelector ( const FileReaderSelector &  other)

Copy constructor.

Parameters
[in]otherThe FileReaderSelector to copy.

◆ FileReaderSelector() [2/2]

mitk::FileReaderSelector::FileReaderSelector ( const std::string &  path)

Construct a selector for the given file path.

Parameters
[in]pathThe absolute file path to find readers for.

Queries the service registry for all IFileReader services matching the file's mime-type(s) and evaluates their confidence levels. If the file does not exist, the selector will be empty.

◆ ~FileReaderSelector()

mitk::FileReaderSelector::~FileReaderSelector ( )

Member Function Documentation

◆ Get() [1/2]

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

Get a sorted list of all file reader items.

Items are sorted in ascending order by:

  1. Confidence level
  2. MimeType ordering
  3. File reader service ranking

The best-matching item is at the back of the returned container.

Returns
A sorted vector of Item objects.

◆ Get() [2/2]

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

Get a reader 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::FileReaderSelector::GetDefault ( ) const

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

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

◆ GetDefaultId()

long mitk::FileReaderSelector::GetDefaultId ( ) const

Get the service id of the best-matching reader.

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

◆ GetMimeTypes()

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

Get all mime-types that matched the file path.

Returns
A vector of MimeType objects.

◆ GetSelected()

Item mitk::FileReaderSelector::GetSelected ( ) const

Get the currently selected reader item.

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

◆ GetSelectedId()

long mitk::FileReaderSelector::GetSelectedId ( ) const

Get the service id of the currently selected reader.

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

◆ IsEmpty()

bool mitk::FileReaderSelector::IsEmpty ( ) const

Check whether any suitable readers were found.

Returns
true if no readers are available for the given file.

◆ operator=()

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

Copy assignment operator.

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

◆ Select() [1/2]

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

Select a reader by Item.

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

◆ Select() [2/2]

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

Select a reader by its service id.

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

◆ Swap()

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

Swap the contents of this selector with another.

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

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