MeVisLab Toolbox 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 
25 ML_START_NAMESPACE
26 
27 class PageRequest;
28 class PageRequestProcessor;
29 
32 {
33 public:
35 
36  virtual ~GetTileJobBase();
37 
39  virtual MLErrorCode init(PageRequestProcessor& processor) = 0;
40 
42  double getProgress() const;
43 
45  bool hasFinished() { return _request->hasFinished(); }
46 
48  bool hasError() const { return _request->hasError(); }
49 
51  MLErrorCode getError() const { return _request->getError(); }
52 
54  void setTileRequestFinishedCB(TileRequestFinishedCB* cb, void* data) { _request->setTileRequestFinishedCB(cb, data); }
55 
57  void cancel();
58 
62 
64  virtual void delegateProgressUpdate(double /*progress*/) {};
65 
67  void setProgressCB(MLRequestProgressCB* progressCallback, void* progressCallbackUserData);
68 
69 protected:
74  double _lastProgress;
75 };
76 
77 //-------------------------------------------------------------------------------------------
79 //-------------------------------------------------------------------------------------------
81 {
82 public:
86  GetTileJob(PagedImage& image, const SubImageBox& box, MLDataType datatype,
87  const ScaleShiftData& scaleShiftData = ScaleShiftData());
88 
90  ~GetTileJob() override;
91 
96  MLErrorCode init(PageRequestProcessor& processor) override;
97 
101  void setAllocationPolicy(TileRequest::AllocationPolicy policy) { _request->setAllocationPolicy(policy); }
102 
108  void setRequestAsReadOnlyPage() { _request->setUseTileReadOnly(true); setAllocationPolicy(TileRequest::NoAllocation); }
109 
112  void setExternalDataBuffer(void* data) {
113  _request->setAllocationPolicy(TileRequest::ExternalBuffer);
114  _request->setExternalDataBuffer(data);
115  }
116 
119  return _request->getSubImage();
120  }
121 
122 };
123 
124 ML_END_NAMESPACE
125 
126 #endif //of __mlGetTileJob_H
127 
Base class for TileRequest based jobs.
Definition: mlGetTileJob.h:32
void updateProgress()
Called by host to allow custom progress updates.
TileRequest * _request
The root TileRequest that is used internally.
Definition: mlGetTileJob.h:71
bool hasFinished()
Returns if the request has finished (If an error happened, true will be returned as well).
Definition: mlGetTileJob.h:45
void setTileRequestFinishedCB(TileRequestFinishedCB *cb, void *data)
Sets the tile request finished cb, which is called when the tile is ready.
Definition: mlGetTileJob.h:54
void * _progressCBUserData
Definition: mlGetTileJob.h:73
MLRequestProgressCB * _progressCB
Definition: mlGetTileJob.h:72
virtual MLErrorCode init(PageRequestProcessor &processor)=0
Initializes the tile request and add it to the processor if no error occurs.
virtual void delegateProgressUpdate(double)
Emits the progress when it changes, to be reimplemented in derived classes.
Definition: mlGetTileJob.h:64
bool hasError() const
Returns if the request has an error (and the data is thus unusable/invalid).
Definition: mlGetTileJob.h:48
virtual ~GetTileJobBase()
MLErrorCode getError() const
Returns the error that happened (return ML_RESULT_OK if everything is ok).
Definition: mlGetTileJob.h:51
void setProgressCB(MLRequestProgressCB *progressCallback, void *progressCallbackUserData)
Set 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...
Public interface for requesting a tile from a an ML PagedImage using the PageRequestProcessor.
Definition: mlGetTileJob.h:81
MLErrorCode init(PageRequestProcessor &processor) override
Initializes the tile request and add it to the processor if no error occurs.
const SubImage & getSubImage()
Returns access to the stored subimage (including the data, which is allocated using the AllocationPol...
Definition: mlGetTileJob.h:118
GetTileJob(PagedImage &image, const SubImageBox &box, MLDataType datatype, const ScaleShiftData &scaleShiftData=ScaleShiftData())
Creates a GetTileJob for the given PagedImage image with the requested box, datatype and optional shi...
void setAllocationPolicy(TileRequest::AllocationPolicy policy)
Sets which allocation policy should be used.
Definition: mlGetTileJob.h:101
void setRequestAsReadOnlyPage()
Sets that the tile is used read-only (so that a ML page can be passed directly as tile data) This wil...
Definition: mlGetTileJob.h:108
void setExternalDataBuffer(void *data)
This allows to set the data buffer from an external buffer.
Definition: mlGetTileJob.h:112
~GetTileJob() override
Destructor.
Abstract base class for page request processors.
Class which represents an image, which manages properties of an image and image data which is located...
Definition: mlPagedImage.h:70
This class manages/represents a rectangular 6d image region which is organized linearly in memory.
Definition: mlSubImage.h:75
A TileRequest either represents the input sub image that is needed by a PageRequest or if it is a roo...
Definition: mlTileRequest.h:50
AllocationPolicy
Defines how the TileRequest will allocate its memory.
Definition: mlTileRequest.h:86
MLint32 MLDataType
MLDataType.
Definition: mlTypeDefs.h:684
MLint32 MLErrorCode
Type of an ML Error code.
Definition: mlTypeDefs.h:818
#define MLEXPORT
To export symbols from a dll/shared object, we need to mark them with the MLEXPORT symbol.
void MLRequestProgressCB(void *usrData, double progress)
Definition: mlTypeDefs.h:1318
void TileRequestFinishedCB(void *data, TileRequest *request)
Callback for a finished TileRequest.
Definition: mlTileRequest.h:34
TScaleShiftData< MLdouble > ScaleShiftData
Double version of TScaleShiftData for maximum reasonable precision.