ML Reference
mlGetTileJob.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_GET_TILE_JOB_H
14#define ML_GET_TILE_JOB_H
15
17
18// ML-includes
19#include "mlInitSystemML.h"
20
21#include "mlPagedImage.h"
22#include "mlTileRequest.h"
23#include "mlPageRequestCursor.h"
24
25ML_START_NAMESPACE
26
27class PageRequest;
28class PageRequestProcessor;
29
32{
33public:
35
36 virtual ~GetTileJobBase();
37
39 virtual MLErrorCode init(PageRequestProcessor& processor) = 0;
40
42 double getProgress() const;
43
46 bool hasFinished() { return _request->hasFinished(); }
47
49 bool hasError() const { return _request->hasError(); }
50
52 MLErrorCode getError() const { return _request->getError(); }
53
55 void setTileRequestFinishedCB(TileRequestFinishedCB* cb, void* data) { _request->setTileRequestFinishedCB(cb, data); }
56
58 void cancel();
59
63
65 virtual void delegateProgressUpdate(double /*progress*/) {};
66
68 void setProgressCB(MLRequestProgressCB* progressCallback, void* progressCallbackUserData);
69
70protected:
76};
77
78//-------------------------------------------------------------------------------------------
80//-------------------------------------------------------------------------------------------
82{
83public:
87 GetTileJob(PagedImage& image, const SubImageBox& box, MLDataType datatype,
88 const ScaleShiftData& scaleShiftData = ScaleShiftData());
89
91 ~GetTileJob() override;
92
98
102 void setAllocationPolicy(TileRequest::AllocationPolicy policy) { _request->setAllocationPolicy(policy); }
103
110
113 void setExternalDataBuffer(void* data) {
114 _request->setAllocationPolicy(TileRequest::ExternalBuffer);
115 _request->setExternalDataBuffer(data);
116 }
117
120 return _request->getSubImage();
121 }
122
123};
124
125ML_END_NAMESPACE
126
127#endif //of __mlGetTileJob_H
128
TileRequest * _request
The root TileRequest that is used internally.
void setTileRequestFinishedCB(TileRequestFinishedCB *cb, void *data)
Sets the tile request finished callback that is called when the tile is ready.
MLRequestProgressCB * _progressCB
virtual MLErrorCode init(PageRequestProcessor &processor)=0
Initializes the tile request and adds it to the processor if no error occurs.
virtual void delegateProgressUpdate(double)
Emits the progress when it changes, to be reimplemented in derived classes.
bool hasError() const
Returns whether the request has an error and the data is thus unusable/invalid.
virtual ~GetTileJobBase()
MLErrorCode getError() const
Returns the error that happened. It returns ML_RESULT_OK if everything is ok.
void setProgressCB(MLRequestProgressCB *progressCallback, void *progressCallbackUserData)
Sets the progress callback. It will be called when updateProgress() is called.
double getProgress() const
Returns the current progress of the tile request ([0..1] range).
void cancel()
Cancels the GetTileJob. This only sets the flag, the real cancellation needs to be done on the PageRe...
MLErrorCode init(PageRequestProcessor &processor) override
const SubImage & getSubImage()
Returns access to the stored subimage including the data, which is allocated using the AllocationPoli...
GetTileJob(PagedImage &image, const SubImageBox &box, MLDataType datatype, const ScaleShiftData &scaleShiftData=ScaleShiftData())
void setAllocationPolicy(TileRequest::AllocationPolicy policy)
void setRequestAsReadOnlyPage()
void setExternalDataBuffer(void *data)
~GetTileJob() override
Destructor.
Abstract base class for page request processors.
AllocationPolicy
Defines how the TileRequest will allocate its memory.
MLint32 MLDataType
Definition mlTypeDefs.h:595
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:715
#define MLEXPORT
Code it as import symbol if compiled elsewhere.
void MLRequestProgressCB(void *usrData, double progress)
void TileRequestFinishedCB(void *data, TileRequest *request)
Callback for a finished TileRequest.
TScaleShiftData< MLdouble > ScaleShiftData
Double version of TScaleShiftData for maximum reasonable precision.
TSubImageBox< MLint > SubImageBox
Defines the standard SubImageBox type used in the ML. Its size varies with the size of the MLint type...