Selects the most suitable IFileWriter for a given BaseData object.
More...
#include <mitkFileWriterSelector.h>
|
| class | Item |
| | Represents a single candidate file writer with associated metadata. More...
|
| |
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.
◆ FileWriterSelector() [1/2]
Copy constructor.
- Parameters
-
◆ 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] | baseData | The BaseData object to find writers for. |
| [in] | destMimeType | Optional mime-type name to restrict results. If empty and a path is given, the mime-type is inferred from the path. |
| [in] | path | Optional 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 |
( |
| ) |
|
◆ 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:
- Confidence level
- 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] | mimeType | The 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] | id | The 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=()
Copy assignment operator.
- Parameters
-
- Returns
- Reference to this selector.
◆ Select() [1/3]
| bool mitk::FileWriterSelector::Select |
( |
const Item & |
item | ) |
|
Select a writer by Item.
- Parameters
-
| [in] | item | The 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] | mimeType | The 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] | id | The service id of the writer to select. |
- Returns
true if a writer 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: