MeVisLab Toolbox Reference
|
A TileRequest either represents the input subimage that is needed by a PageRequest or if it is a root TileRequest, it represents the request by a user to get that tile. More...
#include <mlTileRequest.h>
Public Types | |
enum | AllocationPolicy { UseMemoryManager = 0 , UseMLAlloc = 1 , NoAllocation = 2 , ExternalBuffer = 3 } |
Defines how the TileRequest will allocate its memory. More... | |
Public Member Functions | |
void | init (PagedImage *inputImage, const SubImageBox &box, MLDataType dataType, const ScaleShiftData &scaleShift, bool readOnlyInputTile=false, bool tryToBecomeMemoryImage=false) |
Creates a TileRequest for inputImage with given box , dataType , and scaleShift . More... | |
Setup and dependency to PageRequest | |
bool | prepareForCursorVisit () |
This is called before a cursor steps down into the TileRequest and may return false , which means that the Tile needs no to visit but instead needs a sendTileRequestFinished() to proceed. More... | |
void | createInputPageIds () |
Creates the page IDs for all required input pages. More... | |
void | setNeededBy (PageRequest *request) |
Stores the PageRequest that needs this TileRequest. More... | |
bool | isBlockedByMemoryImage () |
Checks whether the tile request is blocked by a pending memory image being calculated by another TileRequest. More... | |
void | pageRequestFinished (SubImage &pageImage, PageRequestQueueInterface &queue) |
Called by all finished PageRequests that may be copied to output buffer. More... | |
Data handling | |
void | setAllocationPolicy (AllocationPolicy policy) |
Sets which allocation policy should be used. More... | |
AllocationPolicy | getAllocationPolicy () const |
Returns the allocation policy. More... | |
void | allocateData () |
Allocates the data using the internal AllocationPolicy. More... | |
void | forgetData () |
Tells the tile to forget its data so that it is not freed in freeData(). More... | |
void | freeData () |
Frees the allocated data using SubImage::free(), except if the AllocationPolicy is UserAllocation. More... | |
const SubImage & | getSubImage () const |
Returns the stored subimage including the data pointer. More... | |
void | setExternalDataBuffer (void *data) |
This allows to set the data buffer from an external buffer. More... | |
void | setUseTileReadOnly (bool flag) |
This allows to make read-only use of input pages or memory image if box/data type match and shift/scale are the default. More... | |
Progress/Completion | |
bool | hasFinished () const |
Returns whether the request has finished. If an error happened, this returns true as well. More... | |
void | setTileRequestFinishedCB (TileRequestFinishedCB *cb, void *data) |
Sets the tile request finished callback. More... | |
void | setInternalTileRequestFinishedCB (TileRequestFinishedCB *cb, void *data) |
Sets the internal tile request finished callback. More... | |
double | getProgress () const |
Returns the progress of this tile (TODO: not very detailed yet, only the ratio of copied/total pages). More... | |
Error handling | |
bool | hasError () const |
Returns whether the request has an error (and the data is thus unusable/invalid). More... | |
void | setError (MLErrorCode error) |
Sets the error that happened. More... | |
MLErrorCode | getError () const |
Returns the error that happened (or ML_RESULT_OK). More... | |
void | propagateErrorUpwards (MLErrorCode error) |
Propagates an error upwards through the PageRequest it depends on. More... | |
bool | propagateCancellationDownIfRequestNotNeededAnymore () |
Recursively walks up to all tree roots and checks whether they are canceled. More... | |
void | collectPageRequestsWithErrors (std::set< PageRequest * > &result) |
Collects all page requests that have error()!=ML_RESULT_OK up to the roots of the tree. More... | |
Helper methods | |
MLErrorCode | updateImageProperties () |
Updates the image properties of the complete graph starting at this tile request via the host. More... | |
int | getProcessingScope () const |
Returns the assigned processing scope. More... | |
void | setProcessingScope (int scope) |
Returns the assigned processing scope. More... | |
const SubImageBox & | getBox () const |
Returns the box that this tile request covers. More... | |
bool | intersectsPagedImage () const |
Returns whether the request has an intersection with the paged image. More... | |
void | updateSourceImageExtent () |
Updates the source image extent according to the image. More... | |
Static Public Member Functions | |
static TileRequest * | allocate () |
Tile requests are allocated via the allocate method, they can not be created with new . More... | |
static void | deallocate (TileRequest *request) |
Tile requests are deallocated with the deallocate method, they can not be deleted directly. More... | |
static void | clearFreeList () |
Clears the internal free list of deallocated TileRequests. More... | |
static void | enableAllocationFailure (int count=1) |
Enables failing on every count allocation. More... | |
static void | disableAllocationFailure () |
Disables allocation failure (default!). More... | |
Protected Member Functions | |
PageRequest * | createPageRequest (MLint pageId, PageRequestQueueInterface &queue) |
Creates a new page request and queues it if it has no dependencies. More... | |
bool | copyDataFromSubImg (SubImage &pageImage) |
Copies the data from the given image. More... | |
void | sendTileRequestFinished (PageRequestQueueInterface &queue) |
Tells the dependend page requests that the tile request has finished. More... | |
void | emitFinishedCallback () |
Calls the finished callbacks. More... | |
Protected Attributes | |
SubImage | _subImage |
The subimage that represents the TileRequest's box, data type, and data. More... | |
AllocationPolicy | _allocationPolicy |
Defines which allocation method to use. More... | |
ScaleShiftData | _scaleShiftData |
The additional scale/shift information. More... | |
bool | _readOnlyInputTile |
Flag that the TileRequest should try to not copy data, since it will not be written to. More... | |
bool | _tileWillBecomeMemoryImage |
Flag that the TileRequest should become the MemoryImage when it has finished. More... | |
PagedImage * | _image |
The image from which the data should be requested. More... | |
MLint | _inputPagesNeeded |
Overall number of pages needed. This is getNumPages() of _inputPageIds at the beginning and will decrement to 0. More... | |
Mutex | _inputPagesNeededMutex |
TODO: replace above with atomic counter and remove the mutex. More... | |
PageIDIterator | _inputPageIds |
Since a tile can have many page requests, we use a PageIdIterator to generate the IDs on the fly. More... | |
MLint | _traversalCursorPosition |
Current _inputPageIds position to indicate the next page request to create. More... | |
PageRequest * | _neededByPageRequest |
The PageRequest that depends on this TileRequest (or NULL if it is a root TileRequest). More... | |
MLErrorCode | _error |
The current error state. More... | |
int | _processingScope |
The processing scope. More... | |
TileRequestFinishedCB * | _finishedCB |
Callback to signal that the TileRequest has finished. More... | |
void * | _finishedCBData |
Callback data to signal that the TileRequest has finished. More... | |
TileRequestFinishedCB * | _internalFinishedCB |
Callback to signal that the TileRequest has finished. More... | |
void * | _internalFinishedCBData |
Callback data to signal that the TileRequest has finished. More... | |
Friends | |
class | PageRequestCursor |
The cursor needs to be our friend, since it has to access the internal traversal state. More... | |
A TileRequest either represents the input subimage that is needed by a PageRequest or if it is a root TileRequest, it represents the request by a user to get that tile.
A TileRequest typically consists of a number of pages that need to be calculated. These pages are requested by the TileRequest using the PageRequests. Alternatively, a page can already be in the cache and just needs to be copied to the tile. Another option is to make use of a MemoryImage, which means that the entire tile can be filled from the MemoryImage without requesting any pages. A TileRequest can be read-only, in which case it does not attempt to copy the data but instead use the data of a page or MemoryImage directly. This is only possible in the special situation where a TileRequest's data type and box exactly match the input page or the MemoryImage.
Definition at line 49 of file mlTileRequest.h.
Defines how the TileRequest will allocate its memory.
Enumerator | |
---|---|
UseMemoryManager | |
UseMLAlloc | |
NoAllocation | |
ExternalBuffer |
Definition at line 86 of file mlTileRequest.h.
|
static |
Tile requests are allocated via the allocate method, they can not be created with new
.
void ml::TileRequest::allocateData | ( | ) |
Allocates the data using the internal AllocationPolicy.
|
static |
Clears the internal free list of deallocated TileRequests.
void ml::TileRequest::collectPageRequestsWithErrors | ( | std::set< PageRequest * > & | result | ) |
Collects all page requests that have error()!=ML_RESULT_OK up to the roots of the tree.
|
protected |
Copies the data from the given image.
If in read-only mode, the data might as well be stored instead of being copied. Returns true
if the data was not copied but shared instead.
void ml::TileRequest::createInputPageIds | ( | ) |
Creates the page IDs for all required input pages.
|
protected |
Creates a new page request and queues it if it has no dependencies.
It returns the request if necessary; otherwise, it returns NULL. A new page request is only returned if the page does not yet exist in the cache and if there is no pending page request registered yet. If the page does exist, it is copied to its tile requests directly. If a pending page request is available, this request is shared and NULL is returned. A PageRequest is only returned if it first needs cursor work, this method never returns a PageRequest that was added to the queue.
|
static |
Tile requests are deallocated with the deallocate method, they can not be deleted directly.
|
inlinestatic |
Disables allocation failure (default!).
Definition at line 317 of file mlTileRequest.h.
|
protected |
Calls the finished callbacks.
|
static |
Enables failing on every count
allocation.
|
inline |
Tells the tile to forget its data so that it is not freed in freeData().
Definition at line 142 of file mlTileRequest.h.
|
inline |
Frees the allocated data using SubImage::free(), except if the AllocationPolicy is UserAllocation.
Definition at line 145 of file mlTileRequest.h.
|
inline |
Returns the allocation policy.
Definition at line 136 of file mlTileRequest.h.
|
inline |
Returns the box that this tile request covers.
Definition at line 232 of file mlTileRequest.h.
|
inline |
Returns the error that happened (or ML_RESULT_OK).
Definition at line 201 of file mlTileRequest.h.
|
inline |
Returns the assigned processing scope.
Definition at line 226 of file mlTileRequest.h.
double ml::TileRequest::getProgress | ( | ) | const |
Returns the progress of this tile (TODO: not very detailed yet, only the ratio of copied/total pages).
|
inline |
Returns the stored subimage including the data pointer.
Definition at line 148 of file mlTileRequest.h.
|
inline |
Returns whether the request has an error (and the data is thus unusable/invalid).
Definition at line 195 of file mlTileRequest.h.
References ML_RESULT_OK.
bool ml::TileRequest::hasFinished | ( | ) | const |
Returns whether the request has finished. If an error happened, this returns true
as well.
void ml::TileRequest::init | ( | PagedImage * | inputImage, |
const SubImageBox & | box, | ||
MLDataType | dataType, | ||
const ScaleShiftData & | scaleShift, | ||
bool | readOnlyInputTile = false , |
||
bool | tryToBecomeMemoryImage = false |
||
) |
Creates a TileRequest for inputImage
with given box
, dataType
, and scaleShift
.
readOnlyInputTile
can be used to specify that the TileRequest should not attempt to copy the data. tryToBecomeMemoryImage
sets that this TileRequest should attempt to become the MemoryImage of inputImage
when it has finished.
bool ml::TileRequest::intersectsPagedImage | ( | ) | const |
Returns whether the request has an intersection with the paged image.
bool ml::TileRequest::isBlockedByMemoryImage | ( | ) |
Checks whether the tile request is blocked by a pending memory image being calculated by another TileRequest.
void ml::TileRequest::pageRequestFinished | ( | SubImage & | pageImage, |
PageRequestQueueInterface & | queue | ||
) |
Called by all finished PageRequests that may be copied to output buffer.
This can lead to the completion of the TileRequest, which can lead to a new PageRequest being ready for processing, which will then be added to the queue
.
bool ml::TileRequest::prepareForCursorVisit | ( | ) |
This is called before a cursor steps down into the TileRequest and may return false
, which means that the Tile needs no to visit but instead needs a sendTileRequestFinished() to proceed.
bool ml::TileRequest::propagateCancellationDownIfRequestNotNeededAnymore | ( | ) |
Recursively walks up to all tree roots and checks whether they are canceled.
Returns true
if all encountered tree roots have been canceled and sets the error to ML_OPERATION_INTERRUPTED if true
is returned.
void ml::TileRequest::propagateErrorUpwards | ( | MLErrorCode | error | ) |
Propagates an error upwards through the PageRequest it depends on.
It first calls setError(), then emits the finished callbacks, and then propagates the error upwards.
|
protected |
Tells the dependend page requests that the tile request has finished.
|
inline |
Sets which allocation policy should be used.
Note: this can only be changed directly after the constructor of the class, it has no effect if the data is already allocated. The default policy is to use the MLMemoryManager.
Definition at line 133 of file mlTileRequest.h.
void ml::TileRequest::setError | ( | MLErrorCode | error | ) |
Sets the error that happened.
|
inline |
This allows to set the data buffer from an external buffer.
The buffer will not be managed by the GetTileJob; the ownership stays with the user. This will switch the AllocationPolicy to TileRequest::ExternalBuffer.
Definition at line 152 of file mlTileRequest.h.
|
inline |
Sets the internal tile request finished callback.
Note: this should only be used by the request processor.
Definition at line 179 of file mlTileRequest.h.
|
inline |
Stores the PageRequest that needs this TileRequest.
Except for the MemoryImage, a TileRequest can currently not be shared between different PageRequest, so it has only one dependend PageRequest.
Definition at line 109 of file mlTileRequest.h.
|
inline |
Returns the assigned processing scope.
Definition at line 229 of file mlTileRequest.h.
|
inline |
Sets the tile request finished callback.
Note: in the current implementation, the TileRequest may not be deleted from inside of the TileRequestFinishedCB!
Definition at line 172 of file mlTileRequest.h.
|
inline |
This allows to make read-only use of input pages or memory image if box/data type match and shift/scale are the default.
Definition at line 158 of file mlTileRequest.h.
MLErrorCode ml::TileRequest::updateImageProperties | ( | ) |
Updates the image properties of the complete graph starting at this tile request via the host.
void ml::TileRequest::updateSourceImageExtent | ( | ) |
Updates the source image extent according to the image.
|
friend |
The cursor needs to be our friend, since it has to access the internal traversal state.
Definition at line 244 of file mlTileRequest.h.
|
protected |
Defines which allocation method to use.
Definition at line 268 of file mlTileRequest.h.
|
protected |
The current error state.
Definition at line 298 of file mlTileRequest.h.
|
protected |
Callback to signal that the TileRequest has finished.
Definition at line 304 of file mlTileRequest.h.
|
protected |
Callback data to signal that the TileRequest has finished.
Definition at line 306 of file mlTileRequest.h.
|
protected |
The image from which the data should be requested.
Definition at line 279 of file mlTileRequest.h.
|
protected |
Since a tile can have many page requests, we use a PageIdIterator to generate the IDs on the fly.
Definition at line 289 of file mlTileRequest.h.
|
protected |
Overall number of pages needed. This is getNumPages() of _inputPageIds at the beginning and will decrement to 0.
Definition at line 282 of file mlTileRequest.h.
|
protected |
TODO: replace above with atomic counter and remove the mutex.
Definition at line 285 of file mlTileRequest.h.
|
protected |
Callback to signal that the TileRequest has finished.
Definition at line 309 of file mlTileRequest.h.
|
protected |
Callback data to signal that the TileRequest has finished.
Definition at line 311 of file mlTileRequest.h.
|
protected |
The PageRequest that depends on this TileRequest (or NULL if it is a root TileRequest).
Definition at line 295 of file mlTileRequest.h.
|
protected |
The processing scope.
Definition at line 301 of file mlTileRequest.h.
|
protected |
Flag that the TileRequest should try to not copy data, since it will not be written to.
Definition at line 274 of file mlTileRequest.h.
|
protected |
The additional scale/shift information.
Definition at line 271 of file mlTileRequest.h.
|
protected |
The subimage that represents the TileRequest's box, data type, and data.
Definition at line 265 of file mlTileRequest.h.
|
protected |
Flag that the TileRequest should become the MemoryImage when it has finished.
Definition at line 276 of file mlTileRequest.h.
|
protected |
Current _inputPageIds position to indicate the next page request to create.
Definition at line 292 of file mlTileRequest.h.