ML Reference
MeVis/Foundation/Sources/ML/include/host/mlGetTileJob.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //-------------------------------------------------------------------------
00009 //-------------------------------------------------------------------------
00010 #ifndef __mlGetTileJob_H
00011 #define __mlGetTileJob_H
00012 
00013 // ML-includes
00014 #ifndef __mlInitSystemML_H
00015 #include "mlInitSystemML.h"
00016 #endif
00017 
00018 #include "mlPagedImage.h"
00019 #include "mlTileRequest.h"
00020 #include "mlPageRequestCursor.h"
00021 
00022 ML_START_NAMESPACE
00023 
00024 class PageRequest;
00025 class PageRequestProcessor;
00026 
00028 class MLEXPORT GetTileJobBase
00029 {
00030 public:
00031   GetTileJobBase() { _request = NULL; }
00032 
00033   virtual ~GetTileJobBase();
00034 
00036   virtual MLErrorCode init(PageRequestProcessor& processor) = 0;
00037 
00039   double getProgress() const;
00040 
00042   bool hasFinished() { return _request->hasFinished(); }
00043 
00045   bool hasError() const { return _request->hasError(); }
00046 
00048   MLErrorCode getError() const { return _request->getError(); }
00049 
00051   void setTileRequestFinishedCB(TileRequestFinishedCB* cb, void* data) { _request->setTileRequestFinishedCB(cb, data); }
00052 
00054   void cancel();
00055 
00057   bool isCursorNeeded() { return _cursor.isNeeded(); }
00058 
00059 protected:
00061   TileRequest*         _request;
00063   PageRequestCursor    _cursor;
00064 };
00065 
00066 //-------------------------------------------------------------------------------------------
00068 //-------------------------------------------------------------------------------------------
00069 class MLEXPORT GetTileJob : public GetTileJobBase
00070 {
00071 public:
00075   GetTileJob(PagedImage& image, const SubImageBox& box, MLDataType datatype,
00076     const ScaleShiftData& scaleShiftData = ScaleShiftData()):_localRequest(&image, box, datatype, scaleShiftData)
00077   {
00078     _request = &_localRequest;
00079     _cursor.init(&_localRequest);
00080   }
00081 
00083   ~GetTileJob();
00084 
00086   virtual MLErrorCode init(PageRequestProcessor& processor);
00087 
00091   void setAllocationPolicy(TileRequest::AllocationPolicy policy) { _request->setAllocationPolicy(policy); }
00092 
00098   void setRequestAsReadOnlyPage() { _request->setUseTileReadOnly(true); setAllocationPolicy(TileRequest::NoAllocation); }
00099 
00102   void setExternalDataBuffer(void* data) {
00103     _request->setAllocationPolicy(TileRequest::ExternalBuffer);
00104     _request->setExternalDataBuffer(data);
00105   }
00106 
00108   const SubImage& getSubImage() {
00109     return _request->getSubImage();
00110   }
00111 
00112 
00113 private:
00115   TileRequest          _localRequest;
00116 };
00117 
00118 ML_END_NAMESPACE
00119 
00120 #endif //of __mlGetTileJob_H
00121