FLImaging 6.5.8.1
ProcessingUtilities.h
1#pragma once
2
3namespace FLImaging
4{
5 namespace GUI
6 {
7 static CGUIToast* g_pToast;
8 static Base::CPerformanceCounter g_performanceCounter;
9
10 static inline void BeginWaitingMode(const wchar_t* pWcsMessage = nullptr)
11 {
12 CGUIManager::BeginWaitCursor();
13
14 if(g_pToast)
15 delete g_pToast;
16
17 if(!pWcsMessage)
18 g_pToast = new CGUIToast(L"Processing....");
19 else
20 g_pToast = new CGUIToast(pWcsMessage);
21 }
22
23 static inline void BeginProcessing()
24 {
25 g_performanceCounter.Clear();
26 g_performanceCounter.Start();
27 }
28
29 static inline double GetEndProcessingTime()
30 {
31 double f64Time = 0;
32
33 if(g_performanceCounter.GetCheckPointCount())
34 f64Time = g_performanceCounter.GetCheckPointInMilliSecond();
35
36 return f64Time;
37 }
38
39 static inline double EndProcessing()
40 {
41 g_performanceCounter.CheckPoint();
42 return GetEndProcessingTime();
43 }
44
45 static inline void EndWaitingMode()
46 {
47 if(g_pToast)
48 {
49 delete g_pToast;
50 g_pToast = nullptr;
51 }
52
53 CGUIManager::EndWaitCursor();
54 }
55
56 static inline const CResult SetResultMessage(CGUIMenuItemProperty* pProperty, const CResult resThis, const wchar_t* pWcsAdditionalMessage = nullptr, bool bDisplayEndProcessingTime = true)
57 {
58 CResult res;
59
60 if(pProperty)
61 {
62 Base::CFLString<wchar_t> strMessage;
63
64 if(pWcsAdditionalMessage)
65 {
66 if(bDisplayEndProcessingTime)
67 strMessage.AppendFormat(L"%s [%.03lfms] %s", resThis.GetString(), GetEndProcessingTime(), pWcsAdditionalMessage);
68 else
69 strMessage.AppendFormat(L"%s %s", resThis.GetString(), pWcsAdditionalMessage);
70 }
71 else
72 {
73 if(bDisplayEndProcessingTime)
74 strMessage.AppendFormat(L"%s [%.03lfms]", resThis.GetString(), GetEndProcessingTime());
75 else
76 strMessage.AppendFormat(L"%s", resThis.GetString());
77 }
78
79 res = pProperty->SetStatusMessage(strMessage);
80 }
81 else
83
84 return res;
85 }
86 }
87}
double GetCheckPointInMilliSecond(int64_t i64Index=0) const
Get milli second of checkpoint.
size_t GetCheckPointCount() const
Get the number of checkpoints.
void Clear()
Clear checkpoint.
void Start()
Set performance count start time.
@ EResult_NullPointer
Null pointer.
Definition ResultsDef.h:145