ImFusion SDK 4.3
FileLoader Class Reference

#include <ImFusion/IO/FileLoader.h>

This class provides a very high level of abstraction for loading data from files independent of their type. More...

+ Inheritance diagram for FileLoader:

Detailed Description

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.

See also
FolderLoader, FactoryRegistry, IoAlgorithm

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< OwningDataListload (const Filesystem::Path &filePath, Flags< Options > loadOptions=Options::None)
 Attempts to load the file(s) at filePath.
 
std::optional< OwningDataListloadInteractive (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< OwningDataListloadRawImage (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::stringfindIoAlgorithms (const Filesystem::Path &filename)
 Returns the IDs of all registered IO algorithms supporting filename.
 

Additional Inherited Members

- Protected Member Functions inherited from NotCopyable
 NotCopyable (NotCopyable &&) noexcept=default
 
NotCopyableoperator= (NotCopyable &&) noexcept=default
 
 NotCopyable (const NotCopyable &)=delete
 
NotCopyableoperator= (const NotCopyable &)=delete
 

Member Enumeration Documentation

◆ Options

enum class Options
strong

Bitflag enumeration of options to customize the behavior of FileLoader.

Enumerator
None 

Use Default options.

LoadList 

If the file ends with .list, if this is set then this file is interpreted as a list of files to load, which are then again loaded with the same options.

Warning
This can cause infinite loops if two .list files point to each other.
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.

Deprecated
Use IO::FolderLoader instead

◆ Status

enum class Status
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 Options::AllowSpawnGUI was not set.

LoadListNotSet 

The file name ends with .list, but LoadList was not set.

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 Options::AllowSpawnGUI is not set, we then return Status::InvalidOptions.

AlgorithmBlacklisted 

The file might be loadable but the corresponding IoAlgorithm was blacklisted.

Error 

Other unspecified error occurred when loading.

Unknown 

load() was not called

Member Function Documentation

◆ hasHandler()

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.

◆ load()

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().

Parameters
filePathPath to the file to load on the filesystem.
loadOptionsEnables you to customize the behavior or configure what file/directory types are accepted.

◆ loadInteractive()

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().

Note
The AllowSpawnGUI option is ignored by this function.
Parameters
filePathPath to the file to load on the filesystem.
loadOptionsEnables you to customize the behavior or configure what file/directory types are accepted.

◆ loadRawImage()

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.

Parameters
filePathPath to the file to load on the filesystem.
loadOptionsEnables you to customize the behavior or configure what file/directory types are accepted.
rawImageIoConfigCan be used to configure the RawImageIoAlgorithm (cf. RawImageIoAlgorithm::configure). You can additionally set the transformation parameter to set a transformation matrix.

◆ addBlacklistedAlgorithm()

void addBlacklistedAlgorithm ( const std::string & factoryName)

Marks the given algorithm that it shall not be considered when choosing an appropriate IoAlgorithm during load().

Parameters
factoryNameAlgorithm name as registered with the parent IoAlgorithmFactory

The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close