Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::DataReaderFactory Class Reference
+ Inheritance diagram for inviwo::DataReaderFactory:

Public Member Functions

bool registerObject (DataReader *reader)
 
bool unRegisterObject (DataReader *reader)
 
virtual std::unique_ptr< DataReadercreate (const FileExtension &key) const override
 
virtual std::unique_ptr< DataReadercreate (std::string_view key) const override
 
virtual bool hasKey (std::string_view key) const override
 
virtual bool hasKey (const FileExtension &key) const override
 
template<typename T >
std::vector< FileExtensiongetExtensionsForType () const
 
template<typename... Ts>
std::vector< FileExtensiongetExtensionsForTypes () const
 
template<typename... Ts>
auto getExtensionsForTypesView () const
 
template<typename T >
std::unique_ptr< DataReaderType< T > > getReaderForTypeAndExtension (const std::filesystem::path &filePathOrExtension) const
 Return a reader matching the file extension of DataReader of type T. Does case insensitive comparison between the last part of filePathOrExtension and each registered extension. Does not check for "." before the extension, so it is valid to pass for example "png".
 
template<typename T >
std::unique_ptr< DataReaderType< T > > getReaderForTypeAndExtension (const FileExtension &ext) const
 
template<typename T >
std::unique_ptr< DataReaderType< T > > getReaderForTypeAndExtension (const FileExtension &ext, const std::filesystem::path &fallbackFilePathOrExtension) const
 
template<typename T >
bool hasReaderForTypeAndExtension (const std::filesystem::path &filePathOrExtension) const
 
template<typename T >
bool hasReaderForTypeAndExtension (const FileExtension &ext) const
 
template<typename T >
std::shared_ptr< T > readDataForTypeAndExtension (const std::filesystem::path &filePath, std::optional< FileExtension > ext=std::nullopt) const
 
- Public Member Functions inherited from inviwo::Factory< DataReader, const FileExtension & >
 Factory (const Factory &)=delete
 
 Factory (Factory &&)=default
 
Factoryoperator= (const Factory &)=delete
 
Factoryoperator= (Factory &&)=default
 
virtual std::unique_ptr< DataReadercreate (const FileExtension &key, Args... args) const=0
 
virtual std::shared_ptr< DataReadercreateShared (const FileExtension &key, Args... args) const
 
- Public Member Functions inherited from inviwo::Factory< DataReader, std::string_view >
 Factory (const Factory &)=delete
 
 Factory (Factory &&)=default
 
Factoryoperator= (const Factory &)=delete
 
Factoryoperator= (Factory &&)=default
 
virtual std::unique_ptr< DataReadercreate (std::string_view key, Args... args) const=0
 
virtual std::shared_ptr< DataReadercreateShared (std::string_view key, Args... args) const
 
- Public Member Functions inherited from inviwo::Observable< FactoryObserver< DataReader > >
 Observable (const Observable< FactoryObserver< DataReader > > &other)
 
 Observable (Observable< FactoryObserver< DataReader > > &&other) noexcept
 
Observable< FactoryObserver< DataReader > > & operator= (const Observable< FactoryObserver< DataReader > > &other)
 
Observable< FactoryObserver< DataReader > > & operator= (Observable< FactoryObserver< DataReader > > &&other) noexcept
 
void addObserver (FactoryObserver< DataReader > *observer)
 
void removeObserver (FactoryObserver< DataReader > *observer)
 
virtual void startBlockingNotifications () override final
 
virtual void stopBlockingNotifications () override final
 
- Public Member Functions inherited from inviwo::ObservableInterface

Protected Attributes

std::map< FileExtension, DataReader * > map_
 

Additional Inherited Members

- Protected Member Functions inherited from inviwo::FactoryObservable< DataReader >
void notifyObserversOnRegister (DataReader *p)
 
void notifyObserversOnUnRegister (DataReader *p)
 
- Protected Member Functions inherited from inviwo::Observable< FactoryObserver< DataReader > >
void forEachObserver (C callback)
 
- Protected Member Functions inherited from inviwo::ObservableInterface
void addObservationHelper (Observer *observer)
 
void removeObservationHelper (Observer *observer)
 

Member Function Documentation

◆ getReaderForTypeAndExtension() [1/2]

template<typename T >
std::unique_ptr< DataReaderType< T > > inviwo::DataReaderFactory::getReaderForTypeAndExtension ( const FileExtension & ext,
const std::filesystem::path & fallbackFilePathOrExtension ) const

First look for a reader using the FileExtension ext, and if no reader was found look for a reader using the fallbackFilePathOrExtension. This is often used with a file open dialog, where the dialog will have a selectedFileExtension that will be used as ext, and the fallbackFilePathOrExtension is taken from the file to be opened. This way any selected reader will have priority over the file extension.

◆ getReaderForTypeAndExtension() [2/2]

template<typename T >
std::unique_ptr< DataReaderType< T > > inviwo::DataReaderFactory::getReaderForTypeAndExtension ( const std::filesystem::path & filePathOrExtension) const

Return a reader matching the file extension of DataReader of type T. Does case insensitive comparison between the last part of filePathOrExtension and each registered extension. Does not check for "." before the extension, so it is valid to pass for example "png".

Parameters
filePathOrExtensionPath to file, or simply the extension.
Returns
First available DataReaderType<T> if found, nullptr otherwise.

◆ hasKey() [1/2]

virtual bool inviwo::DataReaderFactory::hasKey ( const FileExtension & key) const
overridevirtual

◆ hasKey() [2/2]

virtual bool inviwo::DataReaderFactory::hasKey ( std::string_view key) const
overridevirtual

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