ML Reference
|
00001 // **InsertLicense** code 00002 //------------------------------------------------------------------------- 00010 //------------------------------------------------------------------------- 00011 #ifndef __mlMemoryImage_H 00012 #define __mlMemoryImage_H 00013 00014 // ML-includes 00015 #ifndef __mlInitSystemML_H 00016 #include "mlInitSystemML.h" 00017 #endif 00018 #ifndef __mlRuntime_H 00019 #include "mlRuntime.h" 00020 #endif 00021 #ifndef __mlRuntimeSubClass_H 00022 #include "mlRuntimeSubClass.h" 00023 #endif 00024 #ifndef __mlSubImage_H 00025 #include "mlSubImage.h" 00026 #endif 00027 00028 #include <mlMetaProfilePtr.h> 00029 00030 00031 ML_START_NAMESPACE 00032 00034 class MemoryImageCurrentlyUsedMemoryTracker; 00035 class Module; 00036 class PagedImage; 00038 00039 //------------------------------------------------------------------------- 00050 //------------------------------------------------------------------------- 00051 class ML_UNIX_ONLY_EXPORT(MLEXPORT) MemoryImage 00052 { 00053 00054 public: 00055 00056 //------------------------------------------------------ 00058 00059 //------------------------------------------------------ 00061 inline MemoryImage() : 00062 _subImg(), 00063 _isValid(false), 00064 _userControlled(false), 00065 _calculationPending(false), 00066 _currentlyUsedMemoryTracker(NULL) 00067 { 00068 ML_TRACE_IN( "MemoryImage::MemoryImage( )" ); 00069 } 00070 00072 MLEXPORT virtual ~MemoryImage(); 00074 00075 00076 //------------------------------------------------------ 00078 00079 //------------------------------------------------------ 00081 inline SubImage& getImage() { return _subImg; } 00082 00084 inline const SubImage& getImage() const { return _subImg; } 00085 00087 inline void setValid(bool valid) 00088 { 00089 ML_TRACE_IN( "MemoryImage::setValid( )" ); 00090 ML_TRY 00091 { 00092 _isValid = valid; 00093 } 00094 ML_CATCH_RETHROW; 00095 } 00096 00098 inline bool isValid() const { return _isValid; } 00099 00102 inline MLint getSizeInBytes() const 00103 { 00104 ML_TRACE_IN( "MemoryImage::getSizeInBytes( )" ); 00105 ML_TRY 00106 { 00107 return _subImg.getSizeInBytes(); 00108 } 00109 ML_CATCH_RETHROW; 00110 } 00111 00124 inline void setUserControlled(bool userControlled) 00125 { 00126 _userControlled = userControlled; 00127 } 00128 00131 inline bool isUserControlled() const 00132 { 00133 return _userControlled; 00134 } 00135 00138 inline void setCalculationPending(bool flag) 00139 { 00140 _calculationPending = flag; 00141 } 00142 00144 inline bool isCalculationPending() const 00145 { 00146 return _calculationPending; 00147 } 00148 00150 MLEXPORT std::string getAsString() const; 00151 00154 MLEXPORT void clear(); 00156 00157 //----------------------------------------------------------------------------- 00166 //----------------------------------------------------------------------------- 00167 MLEXPORT MLErrorCode update(PagedImage* image, const SubImageBox& roi, MLDataType newDataType) ML_RETURN_VALUE_SHOULD_BE_USED; 00168 00169 //----------------------------------------------------------------------------- 00173 //----------------------------------------------------------------------------- 00174 MLEXPORT void updateWithSubImage(const SubImage& image); 00175 00177 MLEXPORT MLMetaProfilePtr& getMetaProfile() const; 00178 00179 private: 00180 void updateProfilingData(); 00181 00183 SubImage _subImg; 00184 00186 bool _isValid; 00187 00189 bool _userControlled; 00190 00192 bool _calculationPending; 00193 00195 MemoryImageCurrentlyUsedMemoryTracker* _currentlyUsedMemoryTracker; 00196 00198 mutable MLMetaProfilePtr _metaProfilePtr; 00199 00200 friend class MemoryImageCurrentlyUsedMemoryTracker; 00201 00202 #ifdef ML_DEPRECATED 00203 00205 00206 00207 public: 00208 00211 MLEXPORT ML_DEPRECATED MLErrorCode update(Module *op, MLint outIndex, const SubImageBox &roi, MLDataType newDT); 00214 inline ML_DEPRECATED SubImage& getImg() { return getImage(); } 00217 inline ML_DEPRECATED const SubImage& getConstImg() const { return getImage(); } 00220 inline ML_DEPRECATED MLint getMemoryImgSize() const { return getSizeInBytes(); } 00223 inline MLEXPORT ML_DEPRECATED void clearMemoryImg() { clear(); } 00226 inline MLEXPORT ML_DEPRECATED void updateWithSubImg(const SubImage& image) { updateWithSubImage(image); } 00229 inline ML_DEPRECATED void setManualControl(bool flag) { return setUserControlled(flag); } 00232 inline ML_DEPRECATED bool getManualControl() const { return isUserControlled(); } 00233 00235 00236 #endif // ML_DEPRECATED 00237 00238 }; 00239 00240 00241 #ifdef ML_DEPRECATED 00242 00243 00244 00245 00246 ML_DEPRECATED typedef MemoryImage MemoryImg; 00248 #endif // ML_DEPRECATED 00249 00250 00251 ML_END_NAMESPACE 00252 00253 00254 00255 //----------------------------------------------------------------------------------- 00256 // Stream output for std::ostream 00257 //----------------------------------------------------------------------------------- 00258 namespace std { 00259 00261 inline ostream& operator<<(ostream& s, const ML_NAMESPACE::MemoryImage &mi) 00262 { 00263 return s << mi.getAsString().c_str(); 00264 } 00265 00266 } 00267 00268 00269 #endif // __mlMemoryImage_H 00270 00271 00272