MeVisLab Toolbox Reference
ml::FileReaderPluginsBase Class Referenceabstract

Base class for a generic file reader plugin with factory interface. More...

#include <mlFileReaderPluginsBase.h>

Inheritance diagram for ml::FileReaderPluginsBase:
ml::DMFileReaderPlugin ml::XYLibReaderPlugin

Public Member Functions

 FileReaderPluginsBase ()
 Constructor.
 
virtual ~FileReaderPluginsBase ()
 Destructor cleaning up allocated structures and closing a possibly open file.
 
virtual bool isSupported (const std::string &fileName) const =0
 Applies a fast check whether the file is probably supported or not, for
example via the suffix.
 
virtual double getPluginPriority () const
 Returns a priority over other loader plugins, low priorities mean that other loader plugins with higher priorities which can also read the file should be preferred if there are any.
 
virtual MLErrorCode loadFile (const std::string &fileName)=0
 Opens and loads a file such that getPagedImageProperties() and fillSubImage() can be used to retrieve information from the file.
 
virtual size_t getNumberOfImagesInFile ()=0
 Returns the number of images which are accessible in the loaded file; normally one, but some formats can contain more than on image per file.
 
virtual std::string getCodedImageIndexString (unsigned int imgIdx)
 If getNumberOfImagesInFile() is <=1 then the plugin string id getTypeId()->getName() is returned, otherwise the string getTypeId()->getName() plus "*#" and the imgIdx.
 
virtual unsigned int extractImageIndexValue (const std::string &codedLoaderPluginString)
 From a string of the format "LoaderPluginName+#IDX" extract "IDX" as unsigned int, check whether it is smaller than the number of images in getNumberOfImagesInFile() and if yes then return it.
 
virtual void setSelectedImageIndex (size_t idx=0)
 Selects which image from inside the loaded file shall be used.
 
virtual size_t getSelectedImageIndex () const
 Returns the currently selected image from inside the loaded file.
 
virtual const PagedImagegetPagedImageProperties ()=0
 Returns the properties of the currently loaded image.
 
virtual MLErrorCode fillSubImage (SubImage &dstSubImage)=0
 Copy overlapping regions in dstSubImage with image data from the loaded file; note that the calculation of the overlapping region depends on whether a PagedImage was set with setReferenceForFillingInReferenceCoordinates or not.
 
virtual std::string getTagDump (const size_t maxNumBinaryEntries=8, const size_t maxNumStringEntries=20)
 This function returns a tag or meta data dump of the loaded file or an empty string if not possible (default implementation).
 
virtual void close ()=0
 Closes the file and cleans up data structures.
 
virtual void setReferenceForFillingInReferenceCoordinates (const PagedImage *refImg=nullptr)
 If a valid PagedImage pointer is passed then each fillSubImage operation will take into account the difference between the world origin of the given reference PagedImage and ensure that the copySubImage operation fills dstSubImg in world coordinates of refImg; if nullptr is passed then subimage data will be copied from the file assuming that it is located at voxel coordinates (0,0,0,0,0,0) Loaders which do not support world coordinates will silently ignore the given reference image.
 
virtual const PagedImagegetReferenceForFillingInReferenceCoordinates () const
 Returns the recently set "enabled" state set with setSubImageFillingInReferenceCoordinates().
 
virtual bool supportsFillingInReferenceCoordinates () const
 Returns true if the loader instance support SubImage filling in reference coordinates, otherwise false.
 

Static Public Member Functions

static FileReaderPluginsBasecreateLoaderInstance (const std::string &fileName)
 Factory functionality: Instantiate a loader for the file name fileName and return a new instance of it or return nullptr if no loader can be created.
 

Protected Member Functions

ImageVector _determineWorldDifferenceAsVoxelShift (const PagedImage &destination) const
 Determines a translation vector for SubImages boxes which represents the world difference between the given two PagedImage.
 

Detailed Description

Base class for a generic file reader plugin with factory interface.

Classes deriving from FileReaderPluginsBase must implement all pure virtual functions and register themselves in the Runtime type system normally with ML_CLASS_HEADER(DerivedClassName), ML_CLASS_SOURCE(DerivedClassName, FileReaderPluginsBase), and the corresponding DerivedClassName::initClass() call during library load. It is recommended to load the library with a .def file entry such as

PreloadDLL DerivedPluginClassLibrary {}

to make MeVisLab load the class library on startup time to ensure that classes using the createLoaderInstance() functionality surely can find it.

Definition at line 32 of file mlFileReaderPluginsBase.h.

Constructor & Destructor Documentation

◆ FileReaderPluginsBase()

ml::FileReaderPluginsBase::FileReaderPluginsBase ( )

Constructor.

◆ ~FileReaderPluginsBase()

virtual ml::FileReaderPluginsBase::~FileReaderPluginsBase ( )
virtual

Destructor cleaning up allocated structures and closing a possibly open file.

Member Function Documentation

◆ _determineWorldDifferenceAsVoxelShift()

ImageVector ml::FileReaderPluginsBase::_determineWorldDifferenceAsVoxelShift ( const PagedImage & destination) const
protected

Determines a translation vector for SubImages boxes which represents the world difference between the given two PagedImage.

◆ close()

virtual void ml::FileReaderPluginsBase::close ( )
pure virtual

Closes the file and cleans up data structures.

Property requests and fillSubImage calls will not operate successfully any more after this call.

Implemented in ml::DMFileReaderPlugin, and ml::XYLibReaderPlugin.

◆ createLoaderInstance()

static FileReaderPluginsBase * ml::FileReaderPluginsBase::createLoaderInstance ( const std::string & fileName)
static

Factory functionality: Instantiate a loader for the file name fileName and return a new instance of it or return nullptr if no loader can be created.

◆ extractImageIndexValue()

virtual unsigned int ml::FileReaderPluginsBase::extractImageIndexValue ( const std::string & codedLoaderPluginString)
virtual

From a string of the format "LoaderPluginName+#IDX" extract "IDX" as unsigned int, check whether it is smaller than the number of images in getNumberOfImagesInFile() and if yes then return it.

If the "*#" code does not exist it is assumed that the index is not coded and 0 is returned. If "*#" is found but the index cannot be parsed after it or if it outside the number of images in the file then ML_UINT32_MAX is returned.

◆ fillSubImage()

virtual MLErrorCode ml::FileReaderPluginsBase::fillSubImage ( SubImage & dstSubImage)
pure virtual

Copy overlapping regions in dstSubImage with image data from the loaded file; note that the calculation of the overlapping region depends on whether a PagedImage was set with setReferenceForFillingInReferenceCoordinates or not.

Loaders which do not support filling in reference coordinates (which return false on supportsFillingInReferenceCoordinates()) will silently ignore the reference image.

Parameters
dstSubImageThe subimage to be filled with data from the loaded file where the image regions overlap. Non overlapping regions are left unchanged.
Returns
ML_RESULT_OK on success or an error or a descriptive code explaining the error. On error free operation and empty overlapping region also ML_RESULT_OK is returned.

Implemented in ml::DMFileReaderPlugin, and ml::XYLibReaderPlugin.

◆ getCodedImageIndexString()

virtual std::string ml::FileReaderPluginsBase::getCodedImageIndexString ( unsigned int imgIdx)
virtual

If getNumberOfImagesInFile() is <=1 then the plugin string id getTypeId()->getName() is returned, otherwise the string getTypeId()->getName() plus "*#" and the imgIdx.

In case of invalid getTypeId()->getName() "Unknown" is coded as plugin id.

◆ getNumberOfImagesInFile()

virtual size_t ml::FileReaderPluginsBase::getNumberOfImagesInFile ( )
pure virtual

Returns the number of images which are accessible in the loaded file; normally one, but some formats can contain more than on image per file.

Implemented in ml::DMFileReaderPlugin, and ml::XYLibReaderPlugin.

◆ getPagedImageProperties()

virtual const PagedImage & ml::FileReaderPluginsBase::getPagedImageProperties ( )
pure virtual

Returns the properties of the currently loaded image.

Validity can be determined with isValid() on returned object.

Implemented in ml::DMFileReaderPlugin, and ml::XYLibReaderPlugin.

◆ getPluginPriority()

virtual double ml::FileReaderPluginsBase::getPluginPriority ( ) const
virtual

Returns a priority over other loader plugins, low priorities mean that other loader plugins with higher priorities which can also read the file should be preferred if there are any.

The order of plugins with equal priorities is left undefined. The returned value defaults to 0.5; values should be from [0,1].

Reimplemented in ml::XYLibReaderPlugin.

◆ getReferenceForFillingInReferenceCoordinates()

virtual const PagedImage * ml::FileReaderPluginsBase::getReferenceForFillingInReferenceCoordinates ( ) const
virtual

Returns the recently set "enabled" state set with setSubImageFillingInReferenceCoordinates().

◆ getSelectedImageIndex()

virtual size_t ml::FileReaderPluginsBase::getSelectedImageIndex ( ) const
virtual

Returns the currently selected image from inside the loaded file.

◆ getTagDump()

virtual std::string ml::FileReaderPluginsBase::getTagDump ( const size_t maxNumBinaryEntries = 8,
const size_t maxNumStringEntries = 20 )
virtual

This function returns a tag or meta data dump of the loaded file or an empty string if not possible (default implementation).

If a binary value information is displayed then the number of shown values is controlled with maxNumBinaryEntries; if there are more then "..." is displayed instead. If a string value is displayed then the number of shown characters is controlled with maxNumStringEntries; if there are more then "..." is displayed instead.

Reimplemented in ml::DMFileReaderPlugin, and ml::XYLibReaderPlugin.

◆ isSupported()

virtual bool ml::FileReaderPluginsBase::isSupported ( const std::string & fileName) const
pure virtual

Applies a fast check whether the file is probably supported or not, for
example via the suffix.

If false is returned then file is definitely not loadable; if true then opening with loadFile() is worth a try.

Implemented in ml::DMFileReaderPlugin, and ml::XYLibReaderPlugin.

◆ loadFile()

virtual MLErrorCode ml::FileReaderPluginsBase::loadFile ( const std::string & fileName)
pure virtual

Opens and loads a file such that getPagedImageProperties() and fillSubImage() can be used to retrieve information from the file.

Corresponding close is performed with close() or the destructor.

Parameters
fileNameThe absolute path to the file to be loaded.
Returns
ML_RESULT_OK on successfully opened file or a descriptive code explaining the error.

Implemented in ml::DMFileReaderPlugin, and ml::XYLibReaderPlugin.

◆ setReferenceForFillingInReferenceCoordinates()

virtual void ml::FileReaderPluginsBase::setReferenceForFillingInReferenceCoordinates ( const PagedImage * refImg = nullptr)
virtual

If a valid PagedImage pointer is passed then each fillSubImage operation will take into account the difference between the world origin of the given reference PagedImage and ensure that the copySubImage operation fills dstSubImg in world coordinates of refImg; if nullptr is passed then subimage data will be copied from the file assuming that it is located at voxel coordinates (0,0,0,0,0,0) Loaders which do not support world coordinates will silently ignore the given reference image.

Parameters
refImgThe image providing the reference coordinate system; it's life time must be longer than the last fillSubImage operation. If it is not valid or the matrix is not of rank 4 then operations
will be the same as with refImg = nullptr.

◆ setSelectedImageIndex()

virtual void ml::FileReaderPluginsBase::setSelectedImageIndex ( size_t idx = 0)
virtual

Selects which image from inside the loaded file shall be used.

Typically 0, but some formats can load more than one image from a file whose number can be determined with getNumberOfImagesInFile().

◆ supportsFillingInReferenceCoordinates()

virtual bool ml::FileReaderPluginsBase::supportsFillingInReferenceCoordinates ( ) const
virtual

Returns true if the loader instance support SubImage filling in reference coordinates, otherwise false.

Reimplemented in ml::DMFileReaderPlugin, and ml::XYLibReaderPlugin.


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