ML Reference
ml::PageRequest Class Reference

A PageRequest represents the request for the calculation of a single page of a PagedImage. More...

#include <mlPageRequest.h>

List of all members.

Public Member Functions

void init (PagedImage *outputImage, MLint pageId, int processingScope)
 Inits a PageRequests for the given pageId on the given outputImage.
Setup and dependency to TileRequest
void createInputTileRequests ()
 Creates the TileRequests that are needed for this PageRequest.
void addNeededBy (TileRequest *request)
 Adds that the given TileRequest request depends on this page.
bool tileRequestFinished ()
 Called when one of the tile requests has finished, returns true if all input tiles are finished.
bool isNeededByTiles ()
 Returns if this PageRequest is needed by any tiles (if not, it should not be deleted).
Processing and queuing
bool isReadyForProcessing ()
 Returns if the request is ready for the page calculation and can be placed in the work queue.
MLErrorCode runCalculateOutputSubImage (UserThreadData *userThreadData)
 Allocates the page and call Module::calculateOutputSubImage with given output page and input tiles (may only be called when isReadyForProcessing() returns true).
void copyPageToTileRequests (PageRequestQueueInterface &queue)
 Copies data to dependent tile requests (may only be called after a successful runCalculateOutputSubImage()) and adds new PageRequests that have no more pending dependencies to the queue.
PagedImage * getPagedImage ()
 Get access to the associated paged image (never NULL!)
MLint getPageId ()
 Get the page id.
int getProcessingScope () const
 Get the assigned processing scope.
Error handling
void propagateErrorUpwards (MLErrorCode error)
 Propagates an error upwards through the request tree, sets the error on all dependend TileRequest and PageRequests up to the root TileRequests.
bool propagateCancellationDownIfRequestNotNeededAnymore ()
 Recursively walks up to all tree roots and checks whether they are canceled.
void collectPageRequestsWithErrors (std::set< PageRequest * > &result)
 Collects all page requests that have error()!=ML_RESULT_OK up to the roots of the tree.
bool hasError () const
 Returns if the request has an error (and the data is thus unusable/invalid).
void setError (MLErrorCode error)
 Sets the error that happened (on this single request, not an the tree).
MLErrorCode getError ()
 Returns the error that happened.

Static Public Member Functions

static PageRequestallocate ()
 Page requests are allocated via the allocate method, they can not be created with new.
static void deallocate (PageRequest *request)
 Page requests are deallocated with the deallocate method, they can not be deleted directly.
static void clearFreeList ()
 Clear the internal free list of deallocated PageRequests.

Protected Member Functions

void freeInputTiles ()
 Frees the input tiles and their data.

Protected Attributes

std::vector< TileRequest * > _inputTiles
 Array of input tiles, may contain NULL for empty boxes (array is empty on data sources).
int _inputTilesNeeded
 The number of still needed input tiles (without empty tiles) (is decremented whenever a tile has finished).
Mutex _inputTilesNeededMutex
int _totalInputTilesNeeded
 The total number of input tiles (without empty tiles)
int _traversalCursorPosition
 Offset into _inputTiles to indicate the next tile request to fill with pages.
int _traversalCreatedTiles
 Number of tiles that has already been created.
MLMemoryBlockHandle _page
 The page data (which locks the data in the cache, since it uses a MLMemoryBlockHandle).
PagedImage * _image
 The image from which the page should be requested.
MLint _pageId
 The pageid that should be requested.
MLErrorCode _error
 The error that happened.
int _processingScope
 the processing scope
std::vector< TileRequest * > _neededByTiles
 A list of links to the dependend TileRequests which need this PageRequest to complete.
bool _needsToBeRemovedFromPagedImage
 flag if we need to be removed from the paged image

Friends

class PageRequestCursor
 PageRequestCursor is a friend, since it directly accesses the traversal state.

Detailed Description

A PageRequest represents the request for the calculation of a single page of a PagedImage.

It defines the work item that the PageRequestProcessor queues and executes.

Definition at line 29 of file mlPageRequest.h.


Member Function Documentation

void ml::PageRequest::addNeededBy ( TileRequest *  request) [inline]

Adds that the given TileRequest request depends on this page.

When the PageRequest has finished, it will notify the TileRequest. Multiple TileRequests can depend on the same PageRequest (and thus share a PageRequest).

Definition at line 74 of file mlPageRequest.h.

static PageRequest* ml::PageRequest::allocate ( ) [static]

Page requests are allocated via the allocate method, they can not be created with new.

static void ml::PageRequest::clearFreeList ( ) [static]

Clear the internal free list of deallocated PageRequests.

void ml::PageRequest::collectPageRequestsWithErrors ( std::set< PageRequest * > &  result)

Collects all page requests that have error()!=ML_RESULT_OK up to the roots of the tree.

void ml::PageRequest::copyPageToTileRequests ( PageRequestQueueInterface queue)

Copies data to dependent tile requests (may only be called after a successful runCalculateOutputSubImage()) and adds new PageRequests that have no more pending dependencies to the queue.

void ml::PageRequest::createInputTileRequests ( )

Creates the TileRequests that are needed for this PageRequest.

Pages on modules without inputs will not have any TileRequests. Empty input boxes will also not generate TileRequest.

static void ml::PageRequest::deallocate ( PageRequest request) [static]

Page requests are deallocated with the deallocate method, they can not be deleted directly.

void ml::PageRequest::freeInputTiles ( ) [protected]

Frees the input tiles and their data.

MLErrorCode ml::PageRequest::getError ( ) [inline]

Returns the error that happened.

Definition at line 138 of file mlPageRequest.h.

PagedImage* ml::PageRequest::getPagedImage ( ) [inline]

Get access to the associated paged image (never NULL!)

Definition at line 104 of file mlPageRequest.h.

MLint ml::PageRequest::getPageId ( ) [inline]

Get the page id.

Definition at line 107 of file mlPageRequest.h.

int ml::PageRequest::getProcessingScope ( ) const [inline]

Get the assigned processing scope.

Definition at line 110 of file mlPageRequest.h.

bool ml::PageRequest::hasError ( ) const [inline]

Returns if the request has an error (and the data is thus unusable/invalid).

Definition at line 132 of file mlPageRequest.h.

References ML_RESULT_OK.

void ml::PageRequest::init ( PagedImage *  outputImage,
MLint  pageId,
int  processingScope 
)

Inits a PageRequests for the given pageId on the given outputImage.

bool ml::PageRequest::isNeededByTiles ( ) [inline]

Returns if this PageRequest is needed by any tiles (if not, it should not be deleted).

Definition at line 82 of file mlPageRequest.h.

bool ml::PageRequest::isReadyForProcessing ( )

Returns if the request is ready for the page calculation and can be placed in the work queue.

bool ml::PageRequest::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 when true is returned.

void ml::PageRequest::propagateErrorUpwards ( MLErrorCode  error)

Propagates an error upwards through the request tree, sets the error on all dependend TileRequest and PageRequests up to the root TileRequests.

MLErrorCode ml::PageRequest::runCalculateOutputSubImage ( UserThreadData userThreadData)

Allocates the page and call Module::calculateOutputSubImage with given output page and input tiles (may only be called when isReadyForProcessing() returns true).

void ml::PageRequest::setError ( MLErrorCode  error) [inline]

Sets the error that happened (on this single request, not an the tree).

Definition at line 135 of file mlPageRequest.h.

bool ml::PageRequest::tileRequestFinished ( )

Called when one of the tile requests has finished, returns true if all input tiles are finished.


Friends And Related Function Documentation

friend class PageRequestCursor [friend]

PageRequestCursor is a friend, since it directly accesses the traversal state.

Definition at line 147 of file mlPageRequest.h.


Member Data Documentation

The error that happened.

Definition at line 173 of file mlPageRequest.h.

PagedImage* ml::PageRequest::_image [protected]

The image from which the page should be requested.

Definition at line 168 of file mlPageRequest.h.

std::vector<TileRequest*> ml::PageRequest::_inputTiles [protected]

Array of input tiles, may contain NULL for empty boxes (array is empty on data sources).

Definition at line 150 of file mlPageRequest.h.

The number of still needed input tiles (without empty tiles) (is decremented whenever a tile has finished).

Definition at line 152 of file mlPageRequest.h.

Definition at line 155 of file mlPageRequest.h.

std::vector<TileRequest*> ml::PageRequest::_neededByTiles [protected]

A list of links to the dependend TileRequests which need this PageRequest to complete.

Definition at line 179 of file mlPageRequest.h.

flag if we need to be removed from the paged image

Definition at line 182 of file mlPageRequest.h.

The page data (which locks the data in the cache, since it uses a MLMemoryBlockHandle).

Definition at line 166 of file mlPageRequest.h.

The pageid that should be requested.

Definition at line 170 of file mlPageRequest.h.

the processing scope

Definition at line 176 of file mlPageRequest.h.

The total number of input tiles (without empty tiles)

Definition at line 158 of file mlPageRequest.h.

Number of tiles that has already been created.

Definition at line 163 of file mlPageRequest.h.

Offset into _inputTiles to indicate the next tile request to fill with pages.

Definition at line 161 of file mlPageRequest.h.


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