MeVisLab Toolbox Reference
ml::MemoryImage Class Reference

A memory cache for the complete output image of an output connector. More...

#include <mlMemoryImage.h>

Public Member Functions

MLEXPORT MLErrorCode update (PagedImage *image, const SubImageBox &roi, MLDataType newDataType, MLRequestProgressCB *progressCallback=nullptr, void *progressCallbackUserData=nullptr)
 Updates the given image.
 
MLEXPORT void updateWithSubImage (const SubImage &image)
 Sets the memory image to the given image and clears the previous data.
 
MLEXPORT MLMetaProfilePtrgetMetaProfile () const
 Returns the profiling meta profile pointer.
 
Construction/Destruction
 MemoryImage ()
 Defines a memory image always as member of a paged image with empty content.
 
virtual MLEXPORT ~MemoryImage ()
 Destructor. Cleans up allocated memory.
 
Access to members and state
SubImagegetImage ()
 Returns a subimage representing the data.
 
const SubImagegetImage () const
 Returns a constant subimage representing the data.
 
void setValid (bool valid)
 If set to true, the image data is valid, otherwise not.
 
bool isValid () const
 Returns true if image contents is valid. Otherwise false is returned.
 
MLint getSizeInBytes () const
 Returns the currently used size of memory image in bytes.
 
void setUserControlled (bool userControlled)
 Sets the control modes for the memory image to userControlled.
 
bool isUserControlled () const
 Returns who controls the memory image.
 
void setCalculationPending (bool flag, int processingScope=-1)
 Sets a flag that the memory image is being calculated by somebody and that is is best to wait until that is finished.
 
bool isCalculationPending (int processingScope) const
 Returns if a calculation is pending on the given processingScope.
 
MLEXPORT std::string getAsString () const
 Returns an info string about memory image.
 
MLEXPORT void clear ()
 Clears the memory image if it is handled by the ML.
 

Friends

class MemoryImageCurrentlyUsedMemoryTracker
 

Detailed Description

A memory cache for the complete output image of an output connector.

This cache can be used as a memory image output controlled and set by the user. If the user leaves it unused the host can use it as an automatic cache if any appended operator requests a memory cached input. It is basically used as a member of the OutputConnector class.

Definition at line 48 of file mlMemoryImage.h.

Constructor & Destructor Documentation

◆ MemoryImage()

ml::MemoryImage::MemoryImage ( )
inline

Defines a memory image always as member of a paged image with empty content.

Definition at line 58 of file mlMemoryImage.h.

◆ ~MemoryImage()

virtual MLEXPORT ml::MemoryImage::~MemoryImage ( )
virtual

Destructor. Cleans up allocated memory.

Member Function Documentation

◆ clear()

MLEXPORT void ml::MemoryImage::clear ( )

Clears the memory image if it is handled by the ML.

A user controlled memory image is not changed.

◆ getAsString()

MLEXPORT std::string ml::MemoryImage::getAsString ( ) const

Returns an info string about memory image.

◆ getImage() [1/2]

SubImage & ml::MemoryImage::getImage ( )
inline

Returns a subimage representing the data.

Definition at line 78 of file mlMemoryImage.h.

◆ getImage() [2/2]

const SubImage & ml::MemoryImage::getImage ( ) const
inline

Returns a constant subimage representing the data.

Definition at line 81 of file mlMemoryImage.h.

◆ getMetaProfile()

MLEXPORT MLMetaProfilePtr & ml::MemoryImage::getMetaProfile ( ) const

Returns the profiling meta profile pointer.

◆ getSizeInBytes()

MLint ml::MemoryImage::getSizeInBytes ( ) const
inline

Returns the currently used size of memory image in bytes.

Signed return type is only used for safer signed arithmetics; result will not be less than 0.

Definition at line 95 of file mlMemoryImage.h.

◆ isCalculationPending()

bool ml::MemoryImage::isCalculationPending ( int processingScope) const
inline

Returns if a calculation is pending on the given processingScope.

See also setCalculationPending().

Definition at line 137 of file mlMemoryImage.h.

◆ isUserControlled()

bool ml::MemoryImage::isUserControlled ( ) const
inline

Returns who controls the memory image.

false=host, true=Module. See also setUserControlled(bool).

Definition at line 119 of file mlMemoryImage.h.

◆ isValid()

bool ml::MemoryImage::isValid ( ) const
inline

Returns true if image contents is valid. Otherwise false is returned.

Definition at line 91 of file mlMemoryImage.h.

◆ setCalculationPending()

void ml::MemoryImage::setCalculationPending ( bool flag,
int processingScope = -1 )
inline

Sets a flag that the memory image is being calculated by somebody and that is is best to wait until that is finished.

The processing scope can be used to store on which processing scope of the ML host the calculation is pending.

Definition at line 128 of file mlMemoryImage.h.

References mlrange_cast().

◆ setUserControlled()

void ml::MemoryImage::setUserControlled ( bool userControlled)
inline

Sets the control modes for the memory image to userControlled.

  • The default mode is false, where the host uses this buffer for caching when appended operators request memory mapped input tiles.
  • The user mode does not change anything in the memory output until the user changes it. The Module itself does not change by default. Sets the mode how the memory image output shall be used. Default mode false is that the host uses that image for caching if appended operators request buffered input pages. If manually is set to true then the Module is responsible for the memory output.

Definition at line 112 of file mlMemoryImage.h.

References mlrange_cast().

◆ setValid()

void ml::MemoryImage::setValid ( bool valid)
inline

If set to true, the image data is valid, otherwise not.

Definition at line 84 of file mlMemoryImage.h.

◆ update()

MLEXPORT MLErrorCode ml::MemoryImage::update ( PagedImage * image,
const SubImageBox & roi,
MLDataType newDataType,
MLRequestProgressCB * progressCallback = nullptr,
void * progressCallbackUserData = nullptr )

Updates the given image.

Usually this method is called by the user. On success it returns ML_RESULT_OK, otherwise the error code. If a roi is passed, the memory image is set to that size, otherwise the output image size is used. The user must pass the memory image's data type in newDatType. It is strongly recommended to use the data type of the PagedImage which uses this memory image.

◆ updateWithSubImage()

MLEXPORT void ml::MemoryImage::updateWithSubImage ( const SubImage & image)

Sets the memory image to the given image and clears the previous data.

The memory image is valid after this step if the image contains data. Note: The data in image should be passed as MLMemoryBlockHandle. Thread-safe and synchronized with isValid()/setValid()/isCalculationPending()/setCalculationPending(). Clears calculation pending flag as well.

Friends And Related Symbol Documentation

◆ MemoryImageCurrentlyUsedMemoryTracker

friend class MemoryImageCurrentlyUsedMemoryTracker
friend

Definition at line 205 of file mlMemoryImage.h.


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