![]() |
ImFusion SDK 4.3
|
#include <ImFusion/IO/FileLoader.h>
This class provides a very high level of abstraction for loading data from files independent of their type. More...
This class provides a very high level of abstraction for loading data from files independent of their type.
Internally, this class will query the registered IoAlgorithms whether any of them supports the input file based on its extension. You can specify a bunch of Options in order to customize the behavior and optionally enable/disable extra functionality.
Public Types | |
enum class | Options { None = 0 , LoadList = 1 << 0 , AllowSpawnGUI = 1 << 1 , StoreIOAlgorithms = 1 << 2 , Silent = 1 << 3 , LoadDirectoryAsDICOM = 1 << 4 } |
Bitflag enumeration of options to customize the behavior of FileLoader. More... | |
enum class | Status { Success = 0 , FileNotFound , UnsupportedFileType , FilepathIsDirectory , AdditionalInfoRequired , LoadListNotSet , Canceled , InvalidOptions , AlgorithmBlacklisted , Error , Unknown } |
Known codes indicating the status/result of the last call to one of the load*() functions. More... | |
Public Member Functions | |
bool | hasHandler (const Filesystem::Path &filePath) const |
Returns whether any of the registered IoAlgorithms can handle the file at filePath . | |
std::optional< OwningDataList > | load (const Filesystem::Path &filePath, Flags< Options > loadOptions=Options::None) |
Attempts to load the file(s) at filePath. | |
std::optional< OwningDataList > | loadInteractive (const Filesystem::Path &filePath, Flags< Options > loadOptions=Options::None) |
Attempts to load the file(s) at filePath, but first spawns a GUI dialog asking for the file type. | |
std::optional< OwningDataList > | loadRawImage (const Filesystem::Path &filePath, Flags< Options > loadOptions=Options::None, const Properties *rawImageIoConfig=nullptr) |
Attempts to load the raw image file(s) at filePath using RawImageIoAlgorithm. | |
void | setProgress (Progress *progress) |
Progress interface is forwarded to the used IoAlgorithms. | |
void | addBlacklistedAlgorithm (const std::string &factoryName) |
Marks the given algorithm that it shall not be considered when choosing an appropriate IoAlgorithm during load(). | |
FileLoader::Status | status () |
Get detailed information about the status/result of the most recent call to one of the load*() functions. | |
std::vector< std::unique_ptr< IoAlgorithm > > | usedAlgorithms () |
Retrieve the IoAlgorithm instances used by the load functions in case Options::StoreIoAlgorithms was set. | |
Static Public Member Functions | |
static std::vector< std::string > | findIoAlgorithms (const Filesystem::Path &filename) |
Returns the IDs of all registered IO algorithms supporting filename. | |
Additional Inherited Members | |
![]() | |
NotCopyable (NotCopyable &&) noexcept=default | |
NotCopyable & | operator= (NotCopyable &&) noexcept=default |
NotCopyable (const NotCopyable &)=delete | |
NotCopyable & | operator= (const NotCopyable &)=delete |
|
strong |
Bitflag enumeration of options to customize the behavior of FileLoader.
Enumerator | |
---|---|
None | Use Default options. |
LoadList | If the file ends with
|
AllowSpawnGUI | If set, allow for the loader to spawn a GUI. |
StoreIOAlgorithms | If set, stores used IoAlgorithms which can then be accessed with usedAlgorithms(). |
Silent | Don't emit any warning/error log messages if possible (only applies to FileLoader directly and not to the used IoAlgorithms). |
LoadDirectoryAsDICOM | If the file is a directory, load the file as a DICOM folder.
|
|
strong |
Known codes indicating the status/result of the last call to one of the load*() functions.
Enumerator | |
---|---|
Success | Loading was successful. |
FileNotFound | The specified file does not exist. |
UnsupportedFileType | No algorithm was found that can open the file. |
FilepathIsDirectory | The provided path is a directory, and the LoadDirectoryAsDICOM flag was not set. |
AdditionalInfoRequired | Additional information required to load the file, and asking for this data was not possible because |
LoadListNotSet | The file name ends with |
Canceled | If user canceled loading the file e.g. by closing a dialog, or providing invalid input to a dialog. |
InvalidOptions | The file exists, but the FileLoader::Options prevent us to proceed with loading the file. In some cases, we spawn GUI as a last resort. If |
AlgorithmBlacklisted | The file might be loadable but the corresponding IoAlgorithm was blacklisted. |
Error | Other unspecified error occurred when loading. |
Unknown | load() was not called |
bool hasHandler | ( | const Filesystem::Path & | filePath | ) | const |
Returns whether any of the registered IoAlgorithms can handle the file at filePath
.
If no IoAlgorithm can handle it, trying to load this file will always fail. However, just because a handler exists does not mean that loading will succeed, for example if the file itself does not exist.
std::optional< OwningDataList > load | ( | const Filesystem::Path & | filePath, |
Flags< Options > | loadOptions = Options::None ) |
Attempts to load the file(s) at filePath.
Returns an OwningDataList with the loaded data if successful or an empty Optional on failure. After calling this function you can query details information on the result using status().
filePath | Path to the file to load on the filesystem. |
loadOptions | Enables you to customize the behavior or configure what file/directory types are accepted. |
std::optional< OwningDataList > loadInteractive | ( | const Filesystem::Path & | filePath, |
Flags< Options > | loadOptions = Options::None ) |
Attempts to load the file(s) at filePath, but first spawns a GUI dialog asking for the file type.
Returns an OwningDataList with the loaded data if successful or an empty Optional on failure. After calling this function you can query details information on the result using status().
AllowSpawnGUI
option is ignored by this function.filePath | Path to the file to load on the filesystem. |
loadOptions | Enables you to customize the behavior or configure what file/directory types are accepted. |
std::optional< OwningDataList > loadRawImage | ( | const Filesystem::Path & | filePath, |
Flags< Options > | loadOptions = Options::None, | ||
const Properties * | rawImageIoConfig = nullptr ) |
Attempts to load the raw image file(s) at filePath using RawImageIoAlgorithm.
Returns an OwningDataList with the loaded data if successful or an empty Optional on failure. After calling this function you can query details information on the result using status(). If rawImageIoConfig == nullptr
, and Options::AllowSpwanGUI is set, a dialog is spawned to request the required information.
filePath | Path to the file to load on the filesystem. |
loadOptions | Enables you to customize the behavior or configure what file/directory types are accepted. |
rawImageIoConfig | Can be used to configure the RawImageIoAlgorithm (cf. RawImageIoAlgorithm::configure). You can additionally set the transformation parameter to set a transformation matrix. |
void addBlacklistedAlgorithm | ( | const std::string & | factoryName | ) |
Marks the given algorithm that it shall not be considered when choosing an appropriate IoAlgorithm during load().
factoryName | Algorithm name as registered with the parent IoAlgorithmFactory |