MeVisLab Toolbox Reference
mlPageRequest.h
Go to the documentation of this file.
1
/*************************************************************************************
2
**
3
** Copyright 2009, MeVis Medical Solutions AG
4
**
5
** The user may use this file in accordance with the license agreement provided with
6
** the Software or, alternatively, in accordance with the terms contained in a
7
** written agreement between the user and MeVis Medical Solutions AG.
8
**
9
** For further information use the contact form at https://www.mevislab.de/contact
10
**
11
**************************************************************************************/
12
13
#ifndef ML_PAGE_REQUEST_H
14
#define ML_PAGE_REQUEST_H
15
17
18
#include "
mlPagedImage.h
"
19
20
#include <set>
21
22
ML_START_NAMESPACE
23
24
class
TileRequest;
25
class
PageRequestQueueInterface;
26
27
//-------------------------------------------------------------------------------------------
30
//-------------------------------------------------------------------------------------------
31
class
PageRequest
32
{
33
public
:
35
static
PageRequest
*
allocate
();
36
38
static
void
deallocate
(
PageRequest
*
request
);
39
41
static
void
clearFreeList
();
42
43
private
:
44
PageRequest
();
45
47
void
cleanup();
48
50
PageRequest
* _freeListNext;
51
53
static
PageRequest
* _freeListHead;
55
static
Mutex
_freeListMutex;
56
57
public
:
58
60
void
init
(
PagedImage
*
outputImage
,
MLint
pageId
,
int
processingScope);
61
62
//------------------------------------------------------
65
//------------------------------------------------------
66
70
void
createInputTileRequests
();
71
76
void
addNeededBy
(
TileRequest
*
request
) {
77
_neededByTiles.push_back(
request
);
78
}
79
81
bool
tileRequestFinished
();
82
84
inline
bool
isNeededByTiles
() {
return
_neededByTiles.size()!=0; }
85
87
88
//------------------------------------------------------
91
//------------------------------------------------------
92
95
bool
isReadyForProcessing
();
96
99
MLErrorCode
runCalculateOutputSubImage
(
UserThreadData
*
userThreadData
);
100
103
void
copyPageToTileRequests
(
PageRequestQueueInterface
& queue);
104
106
PagedImage
*
getPagedImage
() {
return
_image; }
107
109
MLint
getPageId
() {
return
_pageId; }
110
112
int
getProcessingScope
()
const
{
return
_processingScope; }
113
115
116
//------------------------------------------------------
119
//------------------------------------------------------
120
123
void
propagateErrorUpwards
(
MLErrorCode
error);
124
128
bool
propagateCancellationDownIfRequestNotNeededAnymore
();
129
131
void
collectPageRequestsWithErrors
(std::set<PageRequest*>&
result
);
132
134
bool
hasError
()
const
{
return
_error!=
ML_RESULT_OK
; }
135
137
void
setError
(
MLErrorCode
error) { _error = error; }
138
140
MLErrorCode
getError
() {
return
_error; }
141
143
144
protected
:
146
void
freeInputTiles
();
147
149
friend
class
PageRequestCursor
;
150
152
std::vector <TileRequest*>
_inputTiles
;
154
int
_inputTilesNeeded
;
155
156
// TODO: replace with atomic counter of _inputTilesNeeded
157
Mutex
_inputTilesNeededMutex
;
158
160
int
_totalInputTilesNeeded
;
161
163
int
_traversalCursorPosition
;
165
int
_traversalCreatedTiles
;
166
168
MLMemoryBlockHandle
_page
;
170
PagedImage
*
_image
;
172
MLint
_pageId
;
173
175
MLErrorCode
_error
;
176
178
int
_processingScope
;
179
181
std::vector <TileRequest*>
_neededByTiles
;
182
184
bool
_needsToBeRemovedFromPagedImage
;
185
};
186
187
188
ML_END_NAMESPACE
189
190
#endif
//of __mlPageRequest_H
191
MLMemoryBlockHandle
The strong handle of a MLMemoryBlock.
Definition
mlMemoryBlockHandle.h:39
ml::PageRequestCursor
A cursor to create page and tile requests in an iterative manner, to allow breaking/resuming at any t...
Definition
mlPageRequestCursor.h:39
ml::PageRequestQueueInterface
Virtual interface for queuing PageRequests that are ready for processing.
Definition
mlPageRequestProcessor.h:33
ml::PageRequest
A PageRequest represents the request for the calculation of a single page of a PagedImage.
Definition
mlPageRequest.h:32
ml::PageRequest::runCalculateOutputSubImage
MLErrorCode runCalculateOutputSubImage(UserThreadData *userThreadData)
Allocates the page and call Module::calculateOutputSubImage with given output page and input tiles (m...
ml::PageRequest::tileRequestFinished
bool tileRequestFinished()
Called when one of the tile requests has finished, returns true if all input tiles are finished.
ml::PageRequest::_needsToBeRemovedFromPagedImage
bool _needsToBeRemovedFromPagedImage
flag if we need to be removed from the paged image
Definition
mlPageRequest.h:184
ml::PageRequest::setError
void setError(MLErrorCode error)
Sets the error that happened (on this single request, not an the tree).
Definition
mlPageRequest.h:137
ml::PageRequest::_traversalCreatedTiles
int _traversalCreatedTiles
Number of tiles that has already been created.
Definition
mlPageRequest.h:165
ml::PageRequest::hasError
bool hasError() const
Returns if the request has an error (and the data is thus unusable/invalid).
Definition
mlPageRequest.h:134
ml::PageRequest::clearFreeList
static void clearFreeList()
Clear the internal free list of deallocated PageRequests.
ml::PageRequest::_traversalCursorPosition
int _traversalCursorPosition
Offset into _inputTiles to indicate the next tile request to fill with pages.
Definition
mlPageRequest.h:163
ml::PageRequest::_error
MLErrorCode _error
The error that happened.
Definition
mlPageRequest.h:175
ml::PageRequest::freeInputTiles
void freeInputTiles()
Frees the input tiles and their data.
ml::PageRequest::isNeededByTiles
bool isNeededByTiles()
Returns if this PageRequest is needed by any tiles (if not, it should not be deleted).
Definition
mlPageRequest.h:84
ml::PageRequest::_totalInputTilesNeeded
int _totalInputTilesNeeded
The total number of input tiles (without empty tiles)
Definition
mlPageRequest.h:160
ml::PageRequest::propagateErrorUpwards
void propagateErrorUpwards(MLErrorCode error)
Propagates an error upwards through the request tree, sets the error on all dependend TileRequest and...
ml::PageRequest::getProcessingScope
int getProcessingScope() const
Get the assigned processing scope.
Definition
mlPageRequest.h:112
ml::PageRequest::propagateCancellationDownIfRequestNotNeededAnymore
bool propagateCancellationDownIfRequestNotNeededAnymore()
Recursively walks up to all tree roots and checks whether they are canceled.
ml::PageRequest::getError
MLErrorCode getError()
Returns the error that happened.
Definition
mlPageRequest.h:140
ml::PageRequest::_image
PagedImage * _image
The image from which the page should be requested.
Definition
mlPageRequest.h:170
ml::PageRequest::deallocate
static void deallocate(PageRequest *request)
Page requests are deallocated with the deallocate method, they can not be deleted directly.
ml::PageRequest::_neededByTiles
std::vector< TileRequest * > _neededByTiles
A list of links to the dependend TileRequests which need this PageRequest to complete.
Definition
mlPageRequest.h:181
ml::PageRequest::copyPageToTileRequests
void copyPageToTileRequests(PageRequestQueueInterface &queue)
Copies data to dependent tile requests (may only be called after a successful runCalculateOutputSubIm...
ml::PageRequest::_inputTilesNeededMutex
Mutex _inputTilesNeededMutex
Definition
mlPageRequest.h:157
ml::PageRequest::createInputTileRequests
void createInputTileRequests()
Creates the TileRequests that are needed for this PageRequest.
ml::PageRequest::_inputTilesNeeded
int _inputTilesNeeded
The number of still needed input tiles (without empty tiles) (is decremented whenever a tile has fini...
Definition
mlPageRequest.h:154
ml::PageRequest::_pageId
MLint _pageId
The pageid that should be requested.
Definition
mlPageRequest.h:172
ml::PageRequest::getPageId
MLint getPageId()
Get the page id.
Definition
mlPageRequest.h:109
ml::PageRequest::getPagedImage
PagedImage * getPagedImage()
Get access to the associated paged image (never NULL!)
Definition
mlPageRequest.h:106
ml::PageRequest::init
void init(PagedImage *outputImage, MLint pageId, int processingScope)
Inits a PageRequests for the given pageId on the given outputImage.
ml::PageRequest::_page
MLMemoryBlockHandle _page
The page data (which locks the data in the cache, since it uses a MLMemoryBlockHandle).
Definition
mlPageRequest.h:168
ml::PageRequest::addNeededBy
void addNeededBy(TileRequest *request)
Adds that the given TileRequest request depends on this page.
Definition
mlPageRequest.h:76
ml::PageRequest::allocate
static PageRequest * allocate()
Page requests are allocated via the allocate method, they can not be created with new.
ml::PageRequest::collectPageRequestsWithErrors
void collectPageRequestsWithErrors(std::set< PageRequest * > &result)
Collects all page requests that have error()!=ML_RESULT_OK up to the roots of the tree.
ml::PageRequest::_inputTiles
std::vector< TileRequest * > _inputTiles
Array of input tiles, may contain NULL for empty boxes (array is empty on data sources).
Definition
mlPageRequest.h:152
ml::PageRequest::_processingScope
int _processingScope
the processing scope
Definition
mlPageRequest.h:178
ml::PageRequest::isReadyForProcessing
bool isReadyForProcessing()
Returns if the request is ready for the page calculation and can be placed in the work queue.
ml::PagedImage
Class which represents an image, which manages properties of an image and image data which is located...
Definition
mlPagedImage.h:66
ml::TileRequest
A TileRequest either represents the input sub image that is needed by a PageRequest or if it is a roo...
Definition
mlTileRequest.h:50
ml::UserThreadData
Base class for thread local data that is passed to CalculateOutputImageHandler::calculateOutputSubIma...
Definition
mlModuleInterfaces.h:31
MLErrorCode
MLint32 MLErrorCode
Type of an ML Error code.
Definition
mlTypeDefs.h:716
ML_RESULT_OK
#define ML_RESULT_OK
No error. Everything seems to be okay.
Definition
mlTypeDefs.h:724
ml::Mutex
boost::mutex Mutex
Defines a non-recursive mutex.
Definition
mlMutex.h:39
mlPagedImage.h
mlrange_cast
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
Definition
mlRangeCasts.h:332
MLint
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition
mlTypeDefs.h:490
MeVis
Foundation
Sources
ML
include
host
mlPageRequest.h
Generated by
1.10.0