aimsdata  5.1.2
Neuroimaging data handling
aims::Reader< T > Class Template Reference

Generic reader for every format of Aims object. More...

#include <aims/io/reader.h>

Inheritance diagram for aims::Reader< T >:
Collaboration diagram for aims::Reader< T >:

Public Member Functions

 Reader ()
 
 Reader (const std::string &filename)
 
virtual ~Reader ()
 
virtual bool read (T &obj, int border=0, const std::string *format=0, int frame=-1)
 Finds the correct format and reads the object. if format is specified, this format is tried first, so you can use it as a hint if you already kow it (from the Finder check ). IF frame is specified and non-negative, reads only that frame (one temporal positon) of the file into time position zero of the object. More...
 
virtual T * read (int border=0, const std::string *format=0, int frame=-1)
 Creates and reads an object. This function differs from the read( T&, ... ) function in the way that it creates the object and does not just fill it. This enables to create sub-classes of T (factory-like behaviour) on types that allow subclasses. The object is created by new and can be deleted. The default implementation just creates a T and calls the read( T&, ... ) function. More...
 
void setMode (carto::AllocatorStrategy::MappingMode mode)
 set input file mode - soon obsolete More...
 
void setAllocatorContext (const carto::AllocatorContext &ac)
 allocator control (not used by every format yet) More...
 
const carto::AllocatorContext & allocatorContext () const
 
void setFileName (const std::string &fileName)
 set input file name More...
 
const std::string & fileName () const
 get input file name More...
 
void setOptions (carto::Object options)
 
carto::Object options () const
 
carto::Objectoptions ()
 

Static Public Member Functions

static std::string extension (const std::string &filename)
 

Protected Attributes

std::string _filename
 
carto::AllocatorStrategy::MappingMode _mode
 
carto::AllocatorContext _alloccontext
 
carto::Object _options
 

Detailed Description

template<class T>
class aims::Reader< T >

Generic reader for every format of Aims object.

Still a template class, the data type must be switched at upper-level (see Finder or Process). Generic readers offer a plug-in mechanism to allow new formats to be registered. It uses at lower level specific readers of each format (GisReader for GIS, AimsVidaReader for Vida, AimsSpmReader for SPM, AimsDicomReader for DICOM, AimsEcatReader for Ecat..., and readers for other object types (meshes, buckets, textures, ...))

Adding new readers

The standard Aims library includes a set of already compiled formats, using a FileFormatDictionary to provide a common link between Reader and Writer, see FileFormatDictionary for a list

If you need to use other types, you'll have to include aims/io/reader_d.h in order to have the template functions definitions, aims/io/reader.h is only the class declarations. In addition, you may want to specialize the registerBaseFormats() functions of the FileFormatDictionary classes.

See also
FileFormatDictionary Writer Finder Process

Definition at line 69 of file reader.h.

Constructor & Destructor Documentation

◆ Reader() [1/2]

template<class T >
aims::Reader< T >::Reader

Definition at line 67 of file reader_d.h.

◆ Reader() [2/2]

template<class T >
aims::Reader< T >::Reader ( const std::string &  filename)

Definition at line 72 of file reader_d.h.

◆ ~Reader()

template<class T >
virtual aims::Reader< T >::~Reader ( )
inlinevirtual

Definition at line 74 of file reader.h.

Member Function Documentation

◆ allocatorContext()

template<typename T >
const carto::AllocatorContext & aims::Reader< T >::allocatorContext

Definition at line 112 of file reader_d.h.

◆ extension()

template<class T >
static std::string aims::Reader< T >::extension ( const std::string &  filename)
static

◆ fileName()

template<class T >
const std::string& aims::Reader< T >::fileName ( ) const
inline

get input file name

Definition at line 102 of file reader.h.

References aims::Reader< T >::_filename.

◆ options() [1/2]

template<class T >
carto::Object & aims::Reader< T >::options

Definition at line 136 of file reader_d.h.

◆ options() [2/2]

template<class T >
carto::Object aims::Reader< T >::options

Definition at line 130 of file reader_d.h.

◆ read() [1/2]

template<class T >
T * aims::Reader< T >::read ( int  border = 0,
const std::string *  format = 0,
int  frame = -1 
)
virtual

Creates and reads an object. This function differs from the read( T&, ... ) function in the way that it creates the object and does not just fill it. This enables to create sub-classes of T (factory-like behaviour) on types that allow subclasses. The object is created by new and can be deleted. The default implementation just creates a T and calls the read( T&, ... ) function.

Definition at line 451 of file reader_d.h.

References carto::FileUtil::extension(), aims::FileFormatDictionary< T >::extensions(), aims::FileFormatDictionary< T >::fileFormat(), carto::getObjectHeader(), carto::const_ref< class >::isNull(), carto::io_error::keepExceptionPriority(), carto::io_error::launchExcept(), localMsg, carto::none(), aims::Finder::postProcessHeader(), aims::FileFormat< T >::read(), soma::Reader< class >::read(), carto::Object::reference(), soma::Reader< class >::setAllocatorContext(), soma::Reader< class >::setOptions(), aims::Settings::settings(), carto::toString(), carto::FileUtil::uriFilename(), carto::FileUtil::uriOptions(), and carto::Object::value().

◆ read() [2/2]

template<class T >
bool aims::Reader< T >::read ( T &  obj,
int  border = 0,
const std::string *  format = 0,
int  frame = -1 
)
virtual

◆ setAllocatorContext()

template<typename T >
void aims::Reader< T >::setAllocatorContext ( const carto::AllocatorContext &  ac)

allocator control (not used by every format yet)

Definition at line 106 of file reader_d.h.

Referenced by aims::VolumeFormat< T >::read().

◆ setFileName()

template<class T >
void aims::Reader< T >::setFileName ( const std::string &  fileName)

set input file name

Definition at line 118 of file reader_d.h.

◆ setMode()

template<class T >
void aims::Reader< T >::setMode ( carto::AllocatorStrategy::MappingMode  mode)

set input file mode - soon obsolete

Definition at line 79 of file reader_d.h.

◆ setOptions()

template<class T >
void aims::Reader< T >::setOptions ( carto::Object  options)

Definition at line 124 of file reader_d.h.

Referenced by aims::VolumeFormat< T >::read().

Member Data Documentation

◆ _alloccontext

template<class T >
carto::AllocatorContext aims::Reader< T >::_alloccontext
protected

Definition at line 112 of file reader.h.

◆ _filename

template<class T >
std::string aims::Reader< T >::_filename
protected

Definition at line 110 of file reader.h.

Referenced by aims::Reader< T >::fileName().

◆ _mode

template<class T >
carto::AllocatorStrategy::MappingMode aims::Reader< T >::_mode
protected

Definition at line 111 of file reader.h.

◆ _options

template<class T >
carto::Object aims::Reader< T >::_options
protected

Definition at line 113 of file reader.h.


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