Selects the most suitable IFileReader for a given file path.
More...
#include <mitkFileReaderSelector.h>
|
| class | Item |
| | Represents a single candidate file reader with associated metadata. More...
|
| |
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.
◆ FileReaderSelector() [1/2]
Copy constructor.
- Parameters
-
◆ FileReaderSelector() [2/2]
| mitk::FileReaderSelector::FileReaderSelector |
( |
const std::string & |
path | ) |
|
Construct a selector for the given file path.
- Parameters
-
| [in] | path | The 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 |
( |
| ) |
|
◆ 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:
- Confidence level
- MimeType ordering
- 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] | id | The 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=()
Copy assignment operator.
- Parameters
-
- Returns
- Reference to this selector.
◆ Select() [1/2]
| bool mitk::FileReaderSelector::Select |
( |
const Item & |
item | ) |
|
Select a reader by Item.
- Parameters
-
| [in] | item | The 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] | id | The service id of the reader to select. |
- Returns
true if a reader with the given id exists and was selected.
◆ Swap()
Swap the contents of this selector with another.
- Parameters
-
The documentation for this class was generated from the following file: