DocumentationOverviewBuilding ASL Documentation Library Wiki Docs Indices Browse Perforce More InfoRelease NotesWiki Site Search License Success Stories Contributors MediaDownloadPerforce Depots SupportASL SourceForge HomeMailing Lists Discussion Forums Report Bugs Suggest Features Contribute to ASL RSSShort-text newsFull-text news File releases Other Adobe ProjectsAdobe AirAdobe GIL Adobe Labs Adobe Media Gallery Adobe XMP Tamarin project (Mozilla Foundation) Other ResourcesBoostRIAForge SGI STL |
dng_abort_sniffer.hGo to the documentation of this file.00001 /*****************************************************************************/ 00002 // Copyright 2006-2008 Adobe Systems Incorporated 00003 // All Rights Reserved. 00004 // 00005 // NOTICE: Adobe permits you to use, modify, and distribute this file in 00006 // accordance with the terms of the Adobe license agreement accompanying it. 00007 /*****************************************************************************/ 00008 00009 /* $Id: //mondo/workarea/stern/camera_raw/dng_sdk/source/dng_abort_sniffer.h#8 $ */ 00010 /* $DateTime: 2008/03/05 13:02:36 $ */ 00011 /* $Change: 430507 $ */ 00012 /* $Author: stern $ */ 00013 00018 /*****************************************************************************/ 00019 00020 #ifndef __dng_abort_sniffer__ 00021 #define __dng_abort_sniffer__ 00022 00023 /*****************************************************************************/ 00024 00025 #include "dng_flags.h" 00026 #include "dng_types.h" 00027 00028 /*****************************************************************************/ 00029 00030 // Thread priority level. 00031 00032 enum dng_priority 00033 { 00034 00035 dng_priority_low, 00036 dng_priority_medium, 00037 dng_priority_high, 00038 00039 dng_priority_count, 00040 00041 dng_priority_minimum = dng_priority_low, 00042 dng_priority_maximum = dng_priority_high, 00043 00044 }; 00045 00046 /*****************************************************************************/ 00047 00048 class dng_set_minimum_priority 00049 { 00050 00051 private: 00052 00053 dng_priority fPriority; 00054 00055 public: 00056 00057 dng_set_minimum_priority (dng_priority priority); 00058 00059 ~dng_set_minimum_priority (); 00060 00061 }; 00062 00063 /*****************************************************************************/ 00064 00071 class dng_abort_sniffer 00072 { 00073 00074 friend class dng_sniffer_task; 00075 00076 private: 00077 00078 dng_priority fPriority; 00079 00080 public: 00081 00082 dng_abort_sniffer (); 00083 00084 virtual ~dng_abort_sniffer (); 00085 00087 00088 dng_priority Priority () const 00089 { 00090 return fPriority; 00091 } 00092 00094 00095 void SetPriority (dng_priority priority) 00096 { 00097 fPriority = priority; 00098 } 00099 00106 00107 static void SniffForAbort (dng_abort_sniffer *sniffer); 00108 00109 // A way to call Sniff while bypassing the priority wait. 00110 00111 void SniffNoPriorityWait () 00112 { 00113 Sniff (); 00114 } 00115 00116 protected: 00117 00120 00121 virtual void Sniff () = 0; 00122 00128 00129 virtual void StartTask (const char *name, 00130 real64 fract); 00131 00133 00134 virtual void EndTask (); 00135 00139 00140 virtual void UpdateProgress (real64 fract); 00141 00142 }; 00143 00144 /******************************************************************************/ 00145 00149 00150 class dng_sniffer_task 00151 { 00152 00153 private: 00154 00155 dng_abort_sniffer *fSniffer; 00156 00157 public: 00158 00165 00166 dng_sniffer_task (dng_abort_sniffer *sniffer, 00167 const char *name = NULL, 00168 real64 fract = 0.0) 00169 00170 : fSniffer (sniffer) 00171 00172 { 00173 if (fSniffer) 00174 fSniffer->StartTask (name, fract); 00175 } 00176 00177 ~dng_sniffer_task () 00178 { 00179 if (fSniffer) 00180 fSniffer->EndTask (); 00181 } 00182 00185 00186 void Sniff () 00187 { 00188 dng_abort_sniffer::SniffForAbort (fSniffer); 00189 } 00190 00194 00195 void UpdateProgress (real64 fract) 00196 { 00197 if (fSniffer) 00198 fSniffer->UpdateProgress (fract); 00199 } 00200 00204 00205 void UpdateProgress (uint32 done, 00206 uint32 total) 00207 { 00208 UpdateProgress ((real64) done / 00209 (real64) total); 00210 } 00211 00213 00214 void Finish () 00215 { 00216 UpdateProgress (1.0); 00217 } 00218 00219 private: 00220 00221 // Hidden copy constructor and assignment operator. 00222 00223 dng_sniffer_task (const dng_sniffer_task &task); 00224 00225 dng_sniffer_task & operator= (const dng_sniffer_task &task); 00226 00227 }; 00228 00229 /*****************************************************************************/ 00230 00231 #endif 00232 00233 /*****************************************************************************/ |