Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::DataReaderType< T > Class Template Referenceabstract

Template base class for file readers designating what type of data object the reader returns. More...

#include <inviwo/core/io/datareader.h>

+ Inheritance diagram for inviwo::DataReaderType< T >:

Public Member Functions

virtual DataReaderType * clone () const override=0
 
 DataReaderType (const DataReaderType &rhs)=default
 
 DataReaderType (DataReaderType &&rhs) noexcept=default
 
DataReaderType & operator= (const DataReaderType &that)=default
 
DataReaderType & operator= (DataReaderType &&that) noexcept=default
 
virtual std::shared_ptr< T > readData (const std::filesystem::path &filePath)=0
 
virtual std::shared_ptr< T > readData (const std::filesystem::path &filePath, MetaDataOwner *)
 
virtual std::shared_ptr< T > readData (const std::filesystem::path &filePath, MetaDataOwner *owner, std::stop_token stop)
 
- Public Member Functions inherited from inviwo::DataReader
void addExtension (FileExtension ext)
 
 DataReader (const DataReader &rhs)=default
 
 DataReader (DataReader &&rhs) noexcept=default
 
const std::vector< FileExtension > & getExtensions () const
 
virtual std::any getOption (std::string_view key)
 Query the value of an reader specific option.
 
DataReader & operator= (const DataReader &that)=default
 
DataReader & operator= (DataReader &&that) noexcept=default
 
template<typename T >
bool readsType () const
 
virtual bool setOption (std::string_view key, std::any value)
 Set reader specific options See the documentation of the specific reader for the available options.
 

Protected Member Functions

virtual bool canRead (const std::type_index &index) const override
 

Additional Inherited Members

- Static Protected Member Functions inherited from inviwo::DataReader
static void checkExists (const std::filesystem::path &path)
 
static std::filesystem::path downloadAndCacheIfUrl (const std::filesystem::path &url)
 
static filesystem::FileHandle fopen (const std::filesystem::path &path, const char *mode)
 
static filesystem::FileHandle fopenAndCacheIfUrl (const std::filesystem::path &path, const char *mode)
 
static std::ifstream open (const std::filesystem::path &path, std::ios_base::openmode mode=std::ios_base::in)
 
static std::ifstream openAndCacheIfUrl (const std::filesystem::path &path, std::ios_base::openmode mode=std::ios_base::in)
 
static std::string readFileContents (const std::filesystem::path &path)
 
- Protected Attributes inherited from inviwo::DataReader
std::vector< FileExtension > extensions_
 

Detailed Description

template<typename T>
class inviwo::DataReaderType< T >

Template base class for file readers designating what type of data object the reader returns.

Member Function Documentation

◆ canRead()

template<typename T >
virtual bool inviwo::DataReaderType< T >::canRead ( const std::type_index & index) const
inlineoverrideprotectedvirtual

Implements inviwo::DataReader.

◆ clone()

template<typename T >
virtual DataReaderType * inviwo::DataReaderType< T >::clone ( ) const
overridepure virtual

Implements inviwo::DataReader.

◆ readData() [1/3]

template<typename T >
virtual std::shared_ptr< T > inviwo::DataReaderType< T >::readData ( const std::filesystem::path & filePath)
pure virtual

◆ readData() [2/3]

template<typename T >
virtual std::shared_ptr< T > inviwo::DataReaderType< T >::readData ( const std::filesystem::path & filePath,
MetaDataOwner *  )
inlinevirtual

Optional overload that passed a MetaDataOwner to facilitate saving/loading state in the data reader the use is optional and the pointer can be null.

See also
RawVolumeReader

Reimplemented in inviwo::JSONReader, and inviwo::RawVolumeReader.

◆ readData() [3/3]

template<typename T >
virtual std::shared_ptr< T > inviwo::DataReaderType< T >::readData ( const std::filesystem::path & filePath,
MetaDataOwner * owner,
std::stop_token stop )
inlinevirtual

Optional overload supporting cancellation. Readers that can abort a long running read should override this, poll stop.stop_requested() at natural checkpoints, and return nullptr as soon as a stop is requested. Note that nullptr is thus a valid, non-exceptional result.

Overriding readers should implement the pure virtual single argument overload by delegating to this one, and add using DataReaderType<T>::readData; to avoid hiding the other overloads.

The default implementation ignores stop and performs an uninterruptible read.

Reimplemented in inviwo::JSONReader.


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