MeVisLabToolboxReference
MeVis/Foundation/Sources/MLBackgroundTasks/mlBackgroundTaskTileProcessor.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00009 //----------------------------------------------------------------------------------
00010 
00011 
00012 #ifndef __mlBackgroundTaskTileProcessor_H
00013 #define __mlBackgroundTaskTileProcessor_H
00014 
00015 
00016 // Local includes
00017 #include "MLBackgroundTasksSystem.h"
00018 
00019 #include "mlImagingBackgroundTask.h"
00020 #include "mlTileIterator.h"
00021 
00022 #include <deque>
00023 
00024 ML_START_NAMESPACE
00025 
00026 //-----------------------------------------------------------------------
00027 
00028 class ModuleBackgroundTask;
00029 
00032 class MLBACKGROUNDTASKS_EXPORT BackgroundTaskTileProcessorBase
00033 {
00034 public:
00035   BackgroundTaskTileProcessorBase();
00036 
00037   //--------------------------------------------------------------------------------------------
00038   //
00040 
00041   //
00042   //--------------------------------------------------------------------------------------------
00043 
00045   virtual SubImageBox getNextTileBox() = 0;
00046 
00048   virtual bool processTile(ManagedSubImage& image) = 0;
00049 
00052   virtual ManagedSubImage* createExternalBuffer(const SubImageBox& box);
00053 
00055 
00056   //--------------------------------------------------------------------------------------------
00057   //
00059 
00060   //
00061   //--------------------------------------------------------------------------------------------
00062 
00064   void setDataType(MLDataType dt) { _dataType = dt; }
00066   MLDataType getDataType() const { return _dataType; }
00067 
00069   void setInputImageIndex(int index) { _inputImageIndex = index; }
00071   int  getInputImageIndex() const { return _inputImageIndex; }
00072 
00074   void setAllocationPolicy(TileRequest::AllocationPolicy policy) { _allocationPolicy = policy; }
00075 
00077   void setMaximumQueuedTiles(int size) { _maxQueuedTiles = size; }
00078 
00080 
00081   //--------------------------------------------------------------------------------------------
00082   //
00084 
00085   //
00086   //--------------------------------------------------------------------------------------------
00087 
00089   virtual bool doProcessing(ModuleBackgroundTask& task);
00090 
00092 
00093 protected:
00095   virtual bool setupProcessing(ModuleBackgroundTask& /*task*/) { return true; }
00096 
00098   virtual bool cleanupProcessing(ModuleBackgroundTask& /*task*/) { return true; }
00099 
00101   void setNumTiles(MLint tiles) { _numTiles = tiles; }
00102 
00103 private:
00104   int        _maxQueuedTiles;
00105   std::deque<ImagingBackgroundTask::AsyncTileRequest > _queue;
00106 
00107   int        _inputImageIndex;
00108   MLDataType _dataType;
00109   TileRequest::AllocationPolicy _allocationPolicy;
00110 
00111   MLint      _numTiles;
00112 };
00113 
00114 
00115 //----------------------------------------------------------------------------------------------
00116 
00121 class MLBACKGROUNDTASKS_EXPORT BackgroundTaskTileProcessor : public BackgroundTaskTileProcessorBase
00122 {
00123 public:
00124   BackgroundTaskTileProcessor();
00125 
00126   //--------------------------------------------------------------------------------------------
00127   //
00129 
00130   //
00131   //--------------------------------------------------------------------------------------------
00132 
00134   void setRegion(const SubImageBox& box) { _box = box; }
00135 
00137   void setTileExtent(const ImageVector& extent) { _tileExtent = extent; }
00138 
00141   void setClipTilesToRegion(bool clip) { _clipTiles = clip; }
00142 
00144 
00146   virtual SubImageBox getNextTileBox();
00147 
00149   virtual bool setupProcessing(ModuleBackgroundTask& task);
00150 
00151 private:
00152   TileIterator _iterator;
00153   SubImageBox  _box;
00154   ImageVector  _tileExtent;
00155   bool         _clipTiles;
00156 };
00157 
00158 ML_END_NAMESPACE
00159 
00160 #endif
00161 
00162