ML Reference
|
00001 // **InsertLicense** code 00002 //------------------------------------------------------------------------- 00017 //------------------------------------------------------------------------- 00018 #ifndef __mlHost_H 00019 #define __mlHost_H 00020 00021 //ML-includes 00022 #ifndef __mlInitSystemML_H 00023 #include "mlInitSystemML.h" 00024 #endif 00025 #ifndef __mlBasics_H 00026 #include "mlBasics.h" 00027 #endif 00028 #ifndef __mlPagedImage_H 00029 #include "mlPagedImage.h" 00030 #endif 00031 #ifndef __mlSubImage_H 00032 #include "mlSubImage.h" 00033 #endif 00034 #ifndef __mlFields_H 00035 #include "mlFields.h" 00036 #endif 00037 #ifndef __mlWaitCondition_H 00038 #include "mlWaitCondition.h" 00039 #endif 00040 #ifndef __mlThread_H 00041 #include "mlThread.h" 00042 #endif 00043 00044 ML_START_NAMESPACE 00045 00047 class Module; 00048 class ThreadDataClass; 00049 class ProcessAllPagesHandler; 00050 class ClassicHost; 00051 class PageRequestProcessorBase; 00052 class PageRequestProcessor; 00053 class ProcessingTimeLine; 00055 00056 //------------------------------------------------------------------------- 00127 //------------------------------------------------------------------------- 00128 class MLEXPORT Host 00129 { 00130 00131 public: 00132 00133 friend class PageRequestProcessor; 00134 friend class SingleThreadedPageRequestProcessor; 00135 friend class MultiThreadedPageRequestProcessor; 00136 friend class ClassicHost; 00137 00138 //------------------------------------------------------ 00140 00141 //------------------------------------------------------ 00144 static void registerWithMemoryManager(); 00145 00149 Host(); 00150 00152 virtual ~Host(); 00154 00155 //--- Progress Callback 00157 void setProgressCB(void *userData, MLHostProgressCB *callback); 00158 00160 MLHostProgressCB *getProgressCB() const; 00161 00163 void *getProgressCBUserData() const; 00164 00171 void updateProgress(const char* info1, const char* info2); 00172 00173 //--- Break check callback 00175 void setBreakCheckCB(void *userData, MLHostBreakCheckCB *callback); 00176 00178 MLHostBreakCheckCB *getBreakCheckCB() const; 00179 00181 void *getBreakCheckCBUserData() const; 00182 00183 00186 bool shouldTerminate() const; 00187 00192 Field *getPressedNotifyField(); 00193 00195 static Host &getDefaultHost(); 00196 00198 static void destroyDefaultHost(); 00199 00203 static MLErrorCode pushDefaultHost(); 00204 00211 static MLErrorCode popDefaultHost(); 00212 00217 void setMaxNumThreads(MLint32 numThreads); 00218 00220 MLint32 getMaxNumThreads() const; 00221 00226 void setRestrictMaxNumThreads(MLint32 numThreads); 00227 00229 MLint32 getRestrictMaxNumThreads() const { return _restrictMaxNumThreads; } 00230 00232 MLuint32 isProcessingActive() const; 00233 00234 00235 protected: 00238 void _setProcessingActive(); 00239 00243 void _unsetProcessingActive(); 00244 00245 public: 00246 //------------------------------------------------------ 00248 00249 //------------------------------------------------------ 00250 00263 MLErrorCode getTile(PagedImage& outputImage, 00264 SubImageBox location, 00265 MLDataType dataType, 00266 void** data, 00267 const ScaleShiftData& scaleShiftData=ScaleShiftData()) ML_RETURN_VALUE_SHOULD_BE_USED; 00268 00269 00286 MLErrorCode getTile(PagedImage& outputImage, 00287 SubImage& subImage, 00288 const ScaleShiftData& scaleShiftData=ScaleShiftData()) ML_RETURN_VALUE_SHOULD_BE_USED; 00289 00293 void freeTile(void* data); 00295 00296 //--------------------------------------------------------------------------- 00298 00299 //--------------------------------------------------------------------------- 00301 //--------------------------------------------------------------------------- 00302 MLErrorCode processAllPages(Module& module, 00303 MLint outputIndex, 00304 SubImageBox region=SubImageBox()) ML_RETURN_VALUE_SHOULD_BE_USED; 00305 00306 //------------------------------------------------------------------------------ 00309 //------------------------------------------------------------------------------ 00310 MLErrorCode processAllPages(Module& module, 00311 ProcessAllPagesHandler& handler, 00312 SubImageBox region=SubImageBox()) ML_RETURN_VALUE_SHOULD_BE_USED; 00313 00314 //------------------------------------------------------------------------------ 00316 //------------------------------------------------------------------------------ 00317 MLErrorCode processMissingPages(Module& module, MLint outputIndex, SubImageBox region=SubImageBox()) ML_RETURN_VALUE_SHOULD_BE_USED; 00318 00320 00321 //------------------------------------------------------ 00323 00324 //------------------------------------------------------ 00325 00334 MLErrorCode updateImageProperties(Module &module, MLint outputIndex) ML_RETURN_VALUE_SHOULD_BE_USED; 00335 00342 MLErrorCode updateImageProperties(PagedImage& outputImage) ML_RETURN_VALUE_SHOULD_BE_USED; 00344 00346 static inline unsigned int getMemoryManagerId() { return _memoryManagerId; } 00347 00350 static SubImageBox calculateInputSubImageBoxDebug(Module& module, int inIndex, const SubImageBox& outputSubImageBox, int outputIndex); 00351 00353 ClassicHost* getClassicHostDebug() { return _classicHost; } 00354 00356 void setUseClassicHost(bool flag); 00357 00359 bool getUseClassicHost() const { return _useClassicMLHost; } 00360 00362 PageRequestProcessor* getPageRequestProcessor(); 00363 00365 ProcessingTimeLine& getProcessingTimeLine(); 00366 00368 void enableTimeLineProfiling(bool flag); 00369 00370 #ifdef ML_DEPRECATED 00371 00373 00374 00375 public: 00376 00379 ML_DEPRECATED MLErrorCode getTile(Module &op, 00380 MLint outIndex, 00381 SubImageBox loc, 00382 MLDataType dataType, 00383 void **data, 00384 const ScaleShiftData &scaleShiftData=ScaleShiftData()) ML_RETURN_VALUE_SHOULD_BE_USED; 00387 ML_DEPRECATED MLErrorCode getTile(Module &op, 00388 MLint outIndex, 00389 SubImage &subImg, 00390 const ScaleShiftData &scaleShiftData=ScaleShiftData()) ML_RETURN_VALUE_SHOULD_BE_USED; 00393 inline ML_DEPRECATED MLErrorCode updateImageProps(Module &op, MLint outIndex) ML_RETURN_VALUE_SHOULD_BE_USED { return updateImageProperties(op, outIndex); } 00394 00397 inline static ML_DEPRECATED SubImageBox calcInSubImageBoxDebug(Module& module, 00398 int inIndex, 00399 const SubImageBox& outSubImgBox, 00400 int outIndex) 00401 { 00402 return calculateInputSubImageBoxDebug(module, inIndex, outSubImgBox, outIndex); 00403 } 00404 00405 #endif // ML_DEPRECATED 00406 00407 00408 private: 00409 ML_DISALLOW_COPY_AND_ASSIGN(Host) 00410 00411 // ------------------------------------------------------------------------------ 00413 // ------------------------------------------------------------------------------ 00414 MLErrorCode _processAllPages(Module& module, 00415 MLint outputIndex, 00416 SubImageBox region, 00417 ProcessAllPagesHandler* handler, 00418 bool clearPages = true 00419 ) ML_RETURN_VALUE_SHOULD_BE_USED; 00420 00424 MLErrorCode _requiredTypesRegisteredAndSupported(PagedImage* outputImage); 00425 00429 MLErrorCode _updateImageProperties(PagedImage* outputImage) ML_RETURN_VALUE_SHOULD_BE_USED; 00430 00431 //------------------------------------------------------ 00433 00434 //------------------------------------------------------ 00436 void* _userData; 00437 00439 MLHostProgressCB* _progressCB; 00440 00442 void* _breakCheckUserData; 00443 00445 MLHostBreakCheckCB* _breakCheckCB; 00446 00448 MLint32 _maxNumThreads; 00449 00451 MLint32 _restrictMaxNumThreads; 00452 00454 MLuint32 _isProcessingActive; 00455 00458 static unsigned int _memoryManagerId; 00459 00461 ClassicHost* _classicHost; 00462 00464 PageRequestProcessorBase* _processor; 00465 00466 bool _useClassicMLHost; 00467 00469 00470 }; //End of class Host 00471 00472 ML_END_NAMESPACE 00473 00474 //----------------------------------------------------------------------------------- 00475 // Stream output for std::ostream 00476 //----------------------------------------------------------------------------------- 00477 namespace std { 00478 00480 MLEXPORT ostream& operator<<(ostream& s, const ML_NAMESPACE::Host &host); 00481 00482 } 00483 00484 #endif //of __mlHost_H 00485 00486 00487