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

 PageRequest (PagedImage *outputImage, MLint pageId)
 Creates a PageRequests for the given pageId on the given outputImage.
 ~PageRequest ()
 Destructor.
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 ()
 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.
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.

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).
int _totalInputTilesNeeded
 The total number of input tiles (without empty tiles) (is decremented whenever a tile has finished).
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.
std::vector< TileRequest * > _neededByTiles
 A list of links to the dependend TileRequests which need this PageRequest to complete.

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.


Constructor & Destructor Documentation

ml::PageRequest::PageRequest ( PagedImage *  outputImage,
MLint  pageId 
)

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

ml::PageRequest::~PageRequest ( )

Destructor.


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 52 of file mlPageRequest.h.

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.

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 107 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 101 of file mlPageRequest.h.

References ML_RESULT_OK.

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

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

Definition at line 60 of file mlPageRequest.h.

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

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

Definition at line 71 of file mlPageRequest.h.

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 ( )

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 104 of file mlPageRequest.h.

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

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

Definition at line 57 of file mlPageRequest.h.


Friends And Related Function Documentation

friend class PageRequestCursor [friend]

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

Definition at line 121 of file mlPageRequest.h.


Member Data Documentation

The error that happened.

Definition at line 143 of file mlPageRequest.h.

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

The image from which the page should be requested.

Definition at line 138 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 124 of file mlPageRequest.h.

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

Definition at line 126 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 146 of file mlPageRequest.h.

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

Definition at line 136 of file mlPageRequest.h.

The pageid that should be requested.

Definition at line 140 of file mlPageRequest.h.

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

Definition at line 128 of file mlPageRequest.h.

Number of tiles that has already been created.

Definition at line 133 of file mlPageRequest.h.

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

Definition at line 131 of file mlPageRequest.h.


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