From 9623766a619377273e27592adfa6892f0ec985f9 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Wed, 30 May 2012 09:46:11 +0300 Subject: [PATCH] Fixed: IfActions not fired when measure is disabled --- Library/Measure.cpp | 147 ++++++++++++++---------------- Library/Measure.h | 6 +- Library/MeasureCPU.cpp | 50 +++++----- Library/MeasureCPU.h | 3 +- Library/MeasureCalc.cpp | 6 +- Library/MeasureCalc.h | 3 +- Library/MeasureDiskSpace.cpp | 6 +- Library/MeasureDiskSpace.h | 2 +- Library/MeasureMemory.cpp | 6 +- Library/MeasureMemory.h | 3 +- Library/MeasureNet.cpp | 6 +- Library/MeasureNet.h | 4 +- Library/MeasureNetIn.cpp | 8 +- Library/MeasureNetIn.h | 3 +- Library/MeasureNetOut.cpp | 8 +- Library/MeasureNetOut.h | 3 +- Library/MeasureNetTotal.cpp | 8 +- Library/MeasureNetTotal.h | 3 +- Library/MeasurePhysicalMemory.cpp | 6 +- Library/MeasurePhysicalMemory.h | 3 +- Library/MeasurePlugin.cpp | 6 +- Library/MeasurePlugin.h | 2 +- Library/MeasureRegistry.cpp | 6 +- Library/MeasureRegistry.h | 2 +- Library/MeasureScript.cpp | 9 +- Library/MeasureScript.h | 2 +- Library/MeasureTime.cpp | 6 +- Library/MeasureTime.h | 2 +- Library/MeasureUptime.cpp | 6 +- Library/MeasureUptime.h | 2 +- Library/MeasureVirtualMemory.cpp | 9 +- Library/MeasureVirtualMemory.h | 3 +- 32 files changed, 125 insertions(+), 214 deletions(-) diff --git a/Library/Measure.cpp b/Library/Measure.cpp index fcc12ac6..173622e3 100644 --- a/Library/Measure.cpp +++ b/Library/Measure.cpp @@ -424,85 +424,74 @@ std::wstring CMeasure::ExtractWord(std::wstring& buffer) return ret; } -/* -** The base implementation of the update method. This includes the code -** that is common for all measures. This is called every time the measure -** is updated. The inherited classes must call the base implementation if -** they overwrite this method. If this method returns false, the update -** needs not to be done. -** -*/ -bool CMeasure::PreUpdate() +bool CMeasure::Update() { - if (IsDisabled()) + bool update = !IsDisabled(); + + if (update) { - m_Value = 0.0; // Disable measures return 0 as value - return false; + // Only update the counter if the divider + ++m_UpdateCounter; + if (m_UpdateCounter < m_UpdateDivider) return false; + m_UpdateCounter = 0; + + // If we're logging the maximum value of the measure, check if + // the new value is greater than the old one, and update if necessary. + if (m_LogMaxValue) + { + if (m_MedianMaxValues.empty()) + { + m_MedianMaxValues.resize(MEDIAN_SIZE, 0); + m_MedianMinValues.resize(MEDIAN_SIZE, 0); + } + + m_MedianMaxValues[m_MedianPos] = m_Value; + m_MedianMinValues[m_MedianPos] = m_Value; + ++m_MedianPos; + m_MedianPos %= MEDIAN_SIZE; + + std::vector medianArray; + + medianArray = m_MedianMaxValues; + std::sort(medianArray.begin(), medianArray.end()); + m_MaxValue = max(m_MaxValue, medianArray[MEDIAN_SIZE / 2]); + + medianArray = m_MedianMinValues; + std::sort(medianArray.begin(), medianArray.end()); + m_MinValue = min(m_MinValue, medianArray[MEDIAN_SIZE / 2]); + } + + // Call derived method to update value + UpdateValue(); + + if (m_AverageSize > 0) + { + size_t averageValuesSize = m_AverageValues.size(); + + if (m_AverageSize != averageValuesSize) + { + m_AverageValues.resize(m_AverageSize, m_Value); + averageValuesSize = m_AverageValues.size(); + if (m_AveragePos >= averageValuesSize) m_AveragePos = 0; + } + m_AverageValues[m_AveragePos] = m_Value; + + ++m_AveragePos; + m_AveragePos %= averageValuesSize; + + // Calculate the average value + m_Value = 0; + for (size_t i = 0; i < averageValuesSize; ++i) + { + m_Value += m_AverageValues[i]; + } + m_Value /= (double)averageValuesSize; + } } - - // Only update the counter if the divider - ++m_UpdateCounter; - if (m_UpdateCounter < m_UpdateDivider) return false; - m_UpdateCounter = 0; - - // If we're logging the maximum value of the measure, check if - // the new value is greater than the old one, and update if necessary. - if (m_LogMaxValue) + else { - if (m_MedianMaxValues.empty()) - { - m_MedianMaxValues.resize(MEDIAN_SIZE, 0); - m_MedianMinValues.resize(MEDIAN_SIZE, 0); - } - - m_MedianMaxValues[m_MedianPos] = m_Value; - m_MedianMinValues[m_MedianPos] = m_Value; - ++m_MedianPos; - m_MedianPos %= MEDIAN_SIZE; - - std::vector medianArray; - - medianArray = m_MedianMaxValues; - std::sort(medianArray.begin(), medianArray.end()); - m_MaxValue = max(m_MaxValue, medianArray[MEDIAN_SIZE / 2]); - - medianArray = m_MedianMinValues; - std::sort(medianArray.begin(), medianArray.end()); - m_MinValue = min(m_MinValue, medianArray[MEDIAN_SIZE / 2]); - } - - return true; -} - -/* -** Does post measuring things to the value. All measures must call this -** after they have set the m_Value. -** -*/ -bool CMeasure::PostUpdate() -{ - if (m_AverageSize > 0) - { - size_t averageValuesSize = m_AverageValues.size(); - - if (m_AverageSize != averageValuesSize) - { - m_AverageValues.resize(m_AverageSize, m_Value); - averageValuesSize = m_AverageValues.size(); - if (m_AveragePos >= averageValuesSize) m_AveragePos = 0; - } - m_AverageValues[m_AveragePos] = m_Value; - - ++m_AveragePos; - m_AveragePos %= averageValuesSize; - - // Calculate the average value - m_Value = 0; - for (size_t i = 0; i < averageValuesSize; ++i) - { - m_Value += m_AverageValues[i]; - } - m_Value /= (double)averageValuesSize; + // Disabled measures have 0 as value + m_Value = 0.0; } if (m_MeterWindow) @@ -513,7 +502,7 @@ bool CMeasure::PostUpdate() { if (!m_IfEqualCommitted) { - m_IfEqualCommitted = true; // To avoid crashing by !Update due to infinite loop + m_IfEqualCommitted = true; // To avoid infinite loop from !Update Rainmeter->ExecuteCommand(m_IfEqualAction.c_str(), m_MeterWindow); } } @@ -529,7 +518,7 @@ bool CMeasure::PostUpdate() { if (!m_IfAboveCommitted) { - m_IfAboveCommitted= true; // To avoid crashing by !Update due to infinite loop + m_IfAboveCommitted= true; // To avoid infinite loop from !Update Rainmeter->ExecuteCommand(m_IfAboveAction.c_str(), m_MeterWindow); } } @@ -545,7 +534,7 @@ bool CMeasure::PostUpdate() { if (!m_IfBelowCommitted) { - m_IfBelowCommitted = true; // To avoid crashing by !Update due to infinite loop + m_IfBelowCommitted = true; // To avoid infinite loop from !Update Rainmeter->ExecuteCommand(m_IfBelowAction.c_str(), m_MeterWindow); } } @@ -556,7 +545,7 @@ bool CMeasure::PostUpdate() } } - return true; + return update; } /* diff --git a/Library/Measure.h b/Library/Measure.h index 51e79792..b2ba88c4 100644 --- a/Library/Measure.h +++ b/Library/Measure.h @@ -52,7 +52,7 @@ public: void ReadConfig(CConfigParser& parser) { ReadConfig(parser, GetName()); } virtual void Initialize(); - virtual bool Update() = 0; + bool Update(); const WCHAR* GetName() { return m_Name.c_str(); } const std::wstring& GetOriginalName() { return m_Name; } @@ -86,9 +86,7 @@ public: protected: virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); - - virtual bool PreUpdate(); - virtual bool PostUpdate(); + virtual void UpdateValue() = 0; bool ParseSubstitute(std::wstring buffer); std::wstring ExtractWord(std::wstring& buffer); diff --git a/Library/MeasureCPU.cpp b/Library/MeasureCPU.cpp index 78a0ce5c..8cd0ea60 100644 --- a/Library/MeasureCPU.cpp +++ b/Library/MeasureCPU.cpp @@ -117,10 +117,8 @@ void CMeasureCPU::ReadConfig(CConfigParser& parser, const WCHAR* section) ** Updates the current CPU utilization value. ** */ -bool CMeasureCPU::Update() +void CMeasureCPU::UpdateValue() { - if (!CMeasure::PreUpdate()) return false; - if (m_Processor == 0) { BOOL status; @@ -128,7 +126,7 @@ bool CMeasureCPU::Update() // get new CPU's idle/kernel/user time status = GetSystemTimes(&ftIdleTime, &ftKernelTime, &ftUserTime); - if (status == 0) return false; + if (status == 0) return; CalcUsage(Ft2Double(ftIdleTime), Ft2Double(ftKernelTime) + Ft2Double(ftUserTime)); @@ -146,9 +144,7 @@ bool CMeasureCPU::Update() ULONG size = 0; status = c_NtQuerySystemInformation(SystemProcessorPerformanceInformation, buf, bufSize, &size); - if (status == STATUS_SUCCESS || status != STATUS_INFO_LENGTH_MISMATCH) break; - - else // status == STATUS_INFO_LENGTH_MISMATCH + if (status == STATUS_INFO_LENGTH_MISMATCH) { if (size == 0) // Returned required buffer size is always 0 on Windows 2000/XP. { @@ -176,37 +172,33 @@ bool CMeasureCPU::Update() delete [] buf; buf = new BYTE[bufSize]; } + else + { + break; + } + ++loop; } while (loop < 5); - if (status != STATUS_SUCCESS) // failed + if (status == STATUS_SUCCESS) { - delete [] buf; - return false; + if (bufSize != c_BufferSize) + { + // Store the new buffer size + c_BufferSize = bufSize; + } + + SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* systemPerfInfo = (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION*)buf; + + int processor = m_Processor - 1; + + CalcUsage(Li2Double(systemPerfInfo[processor].IdleTime), + Li2Double(systemPerfInfo[processor].KernelTime) + Li2Double(systemPerfInfo[processor].UserTime)); } - if (bufSize != c_BufferSize) - { - // Store the new buffer size - c_BufferSize = bufSize; - } - - SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* systemPerfInfo = (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION*)buf; - - int processor = m_Processor - 1; - - CalcUsage(Li2Double(systemPerfInfo[processor].IdleTime), - Li2Double(systemPerfInfo[processor].KernelTime) + Li2Double(systemPerfInfo[processor].UserTime)); - delete [] buf; } - else - { - return false; - } - - return PostUpdate(); } /* diff --git a/Library/MeasureCPU.h b/Library/MeasureCPU.h index fef2b687..65e20eb7 100644 --- a/Library/MeasureCPU.h +++ b/Library/MeasureCPU.h @@ -31,10 +31,9 @@ public: virtual UINT GetTypeID() { return TypeID(); } - virtual bool Update(); - protected: virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); + virtual void UpdateValue(); private: void CalcUsage(double idleTime, double systemTime); diff --git a/Library/MeasureCalc.cpp b/Library/MeasureCalc.cpp index 6f432487..0edeaea3 100644 --- a/Library/MeasureCalc.cpp +++ b/Library/MeasureCalc.cpp @@ -54,10 +54,8 @@ CMeasureCalc::~CMeasureCalc() ** Updates the calculation ** */ -bool CMeasureCalc::Update() +void CMeasureCalc::UpdateValue() { - if (!CMeasure::PreUpdate()) return false; - const WCHAR* errMsg = MathParser::Parse(m_Formula.c_str(), this, &m_Value); if (errMsg != NULL) { @@ -71,8 +69,6 @@ bool CMeasureCalc::Update() { m_ParseError = false; } - - return PostUpdate(); } /* diff --git a/Library/MeasureCalc.h b/Library/MeasureCalc.h index 5f28ec20..b5a64722 100644 --- a/Library/MeasureCalc.h +++ b/Library/MeasureCalc.h @@ -29,12 +29,11 @@ public: virtual UINT GetTypeID() { return TypeID(); } - virtual bool Update(); - bool GetMeasureValue(const WCHAR* str, int len, double* value); protected: virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); + virtual void UpdateValue(); private: void FormulaReplace(); diff --git a/Library/MeasureDiskSpace.cpp b/Library/MeasureDiskSpace.cpp index 7e1edd54..fa3369ed 100644 --- a/Library/MeasureDiskSpace.cpp +++ b/Library/MeasureDiskSpace.cpp @@ -59,10 +59,8 @@ CMeasureDiskSpace::~CMeasureDiskSpace() ** Updates the current disk free space value. ** */ -bool CMeasureDiskSpace::Update() +void CMeasureDiskSpace::UpdateValue() { - if (!CMeasure::PreUpdate()) return false; - if (!m_Drive.empty()) { const WCHAR* drive = m_Drive.c_str(); @@ -161,8 +159,6 @@ bool CMeasureDiskSpace::Update() } } } - - return PostUpdate(); } /* diff --git a/Library/MeasureDiskSpace.h b/Library/MeasureDiskSpace.h index d6d52380..28fb9778 100644 --- a/Library/MeasureDiskSpace.h +++ b/Library/MeasureDiskSpace.h @@ -29,11 +29,11 @@ public: virtual UINT GetTypeID() { return TypeID(); } - virtual bool Update(); virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual); protected: virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); + virtual void UpdateValue(); private: std::wstring m_Drive; diff --git a/Library/MeasureMemory.cpp b/Library/MeasureMemory.cpp index 286aa946..6c69fa1e 100644 --- a/Library/MeasureMemory.cpp +++ b/Library/MeasureMemory.cpp @@ -41,10 +41,8 @@ CMeasureMemory::~CMeasureMemory() ** Updates the current total memory value. ** */ -bool CMeasureMemory::Update() +void CMeasureMemory::UpdateValue() { - if (!CMeasure::PreUpdate()) return false; - MEMORYSTATUSEX stat; stat.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&stat); // Doesn't measure values > 4GB. Should use GlobalMemoryStatusEx instead, but that requires Win2k. @@ -56,8 +54,6 @@ bool CMeasureMemory::Update() { m_Value = (double)(__int64)(stat.ullTotalPageFile + stat.ullTotalPhys - stat.ullAvailPageFile - stat.ullAvailPhys); } - - return PostUpdate(); } /* diff --git a/Library/MeasureMemory.h b/Library/MeasureMemory.h index 130bd796..6f0faf9e 100644 --- a/Library/MeasureMemory.h +++ b/Library/MeasureMemory.h @@ -29,10 +29,9 @@ public: virtual UINT GetTypeID() { return TypeID(); } - virtual bool Update(); - protected: virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); + virtual void UpdateValue(); private: bool m_Total; diff --git a/Library/MeasureNet.cpp b/Library/MeasureNet.cpp index 7ab1444b..9b45d8ed 100644 --- a/Library/MeasureNet.cpp +++ b/Library/MeasureNet.cpp @@ -55,10 +55,8 @@ CMeasureNet::~CMeasureNet() ** Checks if Action should be executed. ** */ -bool CMeasureNet::Update() +void CMeasureNet::UpdateValue() { - if (!CMeasure::PreUpdate()) return false; - if (m_MeterWindow) { if (!m_TrafficAction.empty()) @@ -72,8 +70,6 @@ bool CMeasureNet::Update() m_CurrentTraffic += m_Value; } } - - return PostUpdate(); } /* diff --git a/Library/MeasureNet.h b/Library/MeasureNet.h index 1ec2d518..4e4c66ad 100644 --- a/Library/MeasureNet.h +++ b/Library/MeasureNet.h @@ -41,8 +41,6 @@ public: virtual ~CMeasureNet(); virtual UINT GetTypeID() { return TypeID(); } - - virtual bool Update(); static void UpdateIFTable(); @@ -56,6 +54,8 @@ public: protected: void ReadConfig(CConfigParser& parser, const WCHAR* section, CMeasureNet::NET net); + void UpdateValue(); + ULONG64 GetNetOctets(NET net); ULONG64 GetNetStatsValue(NET net); diff --git a/Library/MeasureNetIn.cpp b/Library/MeasureNetIn.cpp index 9a727916..d633bca0 100644 --- a/Library/MeasureNetIn.cpp +++ b/Library/MeasureNetIn.cpp @@ -41,11 +41,9 @@ CMeasureNetIn::~CMeasureNetIn() ** Updates the current net in value. ** */ -bool CMeasureNetIn::Update() +void CMeasureNetIn::UpdateValue() { - if (!CMeasureNet::PreUpdate()) return false; - - if (c_Table == NULL) return false; + if (c_Table == NULL) return; if (m_Cumulative) { @@ -78,8 +76,6 @@ bool CMeasureNetIn::Update() m_Value = (double)(__int64)value; } - - return PostUpdate(); } /* diff --git a/Library/MeasureNetIn.h b/Library/MeasureNetIn.h index dce56bfe..e9397cb4 100644 --- a/Library/MeasureNetIn.h +++ b/Library/MeasureNetIn.h @@ -27,10 +27,9 @@ public: CMeasureNetIn(CMeterWindow* meterWindow, const WCHAR* name); virtual ~CMeasureNetIn(); - virtual bool Update(); - protected: virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); + virtual void UpdateValue(); private: bool m_FirstTime; diff --git a/Library/MeasureNetOut.cpp b/Library/MeasureNetOut.cpp index 91195950..0b6a083a 100644 --- a/Library/MeasureNetOut.cpp +++ b/Library/MeasureNetOut.cpp @@ -41,11 +41,9 @@ CMeasureNetOut::~CMeasureNetOut() ** Updates the current net out value. ** */ -bool CMeasureNetOut::Update() +void CMeasureNetOut::UpdateValue() { - if (!CMeasureNet::PreUpdate()) return false; - - if (c_Table == NULL) return false; + if (c_Table == NULL) return; if (m_Cumulative) { @@ -78,8 +76,6 @@ bool CMeasureNetOut::Update() m_Value = (double)(__int64)value; } - - return PostUpdate(); } /* diff --git a/Library/MeasureNetOut.h b/Library/MeasureNetOut.h index e3b5c526..44421e5c 100644 --- a/Library/MeasureNetOut.h +++ b/Library/MeasureNetOut.h @@ -27,10 +27,9 @@ public: CMeasureNetOut(CMeterWindow* meterWindow, const WCHAR* name); virtual ~CMeasureNetOut(); - virtual bool Update(); - protected: virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); + virtual void UpdateValue(); private: bool m_FirstTime; diff --git a/Library/MeasureNetTotal.cpp b/Library/MeasureNetTotal.cpp index 85966b84..6092a64f 100644 --- a/Library/MeasureNetTotal.cpp +++ b/Library/MeasureNetTotal.cpp @@ -41,11 +41,9 @@ CMeasureNetTotal::~CMeasureNetTotal() ** Updates the current net total value. ** */ -bool CMeasureNetTotal::Update() +void CMeasureNetTotal::UpdateValue() { - if (!CMeasureNet::PreUpdate()) return false; - - if (c_Table == NULL) return false; + if (c_Table == NULL) return; if (m_Cumulative) { @@ -78,8 +76,6 @@ bool CMeasureNetTotal::Update() m_Value = (double)(__int64)value; } - - return PostUpdate(); } /* diff --git a/Library/MeasureNetTotal.h b/Library/MeasureNetTotal.h index eb310bbb..63850997 100644 --- a/Library/MeasureNetTotal.h +++ b/Library/MeasureNetTotal.h @@ -27,10 +27,9 @@ public: CMeasureNetTotal(CMeterWindow* meterWindow, const WCHAR* name); virtual ~CMeasureNetTotal(); - virtual bool Update(); - protected: virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); + virtual void UpdateValue(); private: bool m_FirstTime; diff --git a/Library/MeasurePhysicalMemory.cpp b/Library/MeasurePhysicalMemory.cpp index 1303eefc..db45082a 100644 --- a/Library/MeasurePhysicalMemory.cpp +++ b/Library/MeasurePhysicalMemory.cpp @@ -41,10 +41,8 @@ CMeasurePhysicalMemory::~CMeasurePhysicalMemory() ** Updates the current physical memory value. ** */ -bool CMeasurePhysicalMemory::Update() +void CMeasurePhysicalMemory::UpdateValue() { - if (!CMeasure::PreUpdate()) return false; - MEMORYSTATUSEX stat; stat.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&stat); @@ -56,8 +54,6 @@ bool CMeasurePhysicalMemory::Update() { m_Value = (double)(__int64)(stat.ullTotalPhys - stat.ullAvailPhys); } - - return PostUpdate(); } /* diff --git a/Library/MeasurePhysicalMemory.h b/Library/MeasurePhysicalMemory.h index 20dcf60d..2b6df1fc 100644 --- a/Library/MeasurePhysicalMemory.h +++ b/Library/MeasurePhysicalMemory.h @@ -29,10 +29,9 @@ public: virtual UINT GetTypeID() { return TypeID(); } - virtual bool Update(); - protected: virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); + virtual void UpdateValue(); private: bool m_Total; diff --git a/Library/MeasurePlugin.cpp b/Library/MeasurePlugin.cpp index 3106fd1c..7e156722 100644 --- a/Library/MeasurePlugin.cpp +++ b/Library/MeasurePlugin.cpp @@ -70,10 +70,8 @@ CMeasurePlugin::~CMeasurePlugin() ** Gets the current value from the plugin ** */ -bool CMeasurePlugin::Update() +void CMeasurePlugin::UpdateValue() { - if (!CMeasure::PreUpdate()) return false; - if (m_UpdateFunc) { if (IsNewApi()) @@ -95,8 +93,6 @@ bool CMeasurePlugin::Update() // Reset to default CSystem::ResetWorkingDirectory(); } - - return PostUpdate(); } /* diff --git a/Library/MeasurePlugin.h b/Library/MeasurePlugin.h index b24ea070..0e6d825f 100644 --- a/Library/MeasurePlugin.h +++ b/Library/MeasurePlugin.h @@ -44,12 +44,12 @@ public: virtual UINT GetTypeID() { return TypeID(); } - virtual bool Update(); virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual); virtual void Command(const std::wstring& command); protected: virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); + virtual void UpdateValue(); private: bool IsNewApi() { return m_ReloadFunc != NULL; } diff --git a/Library/MeasureRegistry.cpp b/Library/MeasureRegistry.cpp index b4366263..6b0a5e5a 100644 --- a/Library/MeasureRegistry.cpp +++ b/Library/MeasureRegistry.cpp @@ -45,10 +45,8 @@ CMeasureRegistry::~CMeasureRegistry() ** Gets the current value from the registry ** */ -bool CMeasureRegistry::Update() +void CMeasureRegistry::UpdateValue() { - if (!CMeasure::PreUpdate()) return false; - if (m_RegKey != NULL) { DWORD size = 4096; @@ -99,8 +97,6 @@ bool CMeasureRegistry::Update() { RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey); } - - return PostUpdate(); } /* diff --git a/Library/MeasureRegistry.h b/Library/MeasureRegistry.h index 75ab8659..acfd2b8b 100644 --- a/Library/MeasureRegistry.h +++ b/Library/MeasureRegistry.h @@ -29,11 +29,11 @@ public: virtual UINT GetTypeID() { return TypeID(); } - virtual bool Update(); virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual); protected: virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); + virtual void UpdateValue(); private: std::wstring m_RegKeyName; diff --git a/Library/MeasureScript.cpp b/Library/MeasureScript.cpp index a5d5a4e9..7387db0e 100644 --- a/Library/MeasureScript.cpp +++ b/Library/MeasureScript.cpp @@ -78,13 +78,8 @@ void CMeasureScript::Initialize() ** Updates the current disk free space value. ** */ -bool CMeasureScript::Update() +void CMeasureScript::UpdateValue() { - if (!CMeasure::PreUpdate()) - { - return false; - } - if (m_HasUpdateFunction) { m_ValueType = m_LuaScript->RunFunctionWithReturn(g_UpdateFunctionName, m_Value, m_StringValue); @@ -95,8 +90,6 @@ bool CMeasureScript::Update() m_ValueType = m_LuaScript->RunFunctionWithReturn(g_GetStringFunctionName, m_Value, m_StringValue); } } - - return PostUpdate(); } /* diff --git a/Library/MeasureScript.h b/Library/MeasureScript.h index 6560026b..2ec261ef 100644 --- a/Library/MeasureScript.h +++ b/Library/MeasureScript.h @@ -30,7 +30,6 @@ public: virtual UINT GetTypeID() { return TypeID(); } virtual void Initialize(); - virtual bool Update(); virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual); virtual void Command(const std::wstring& command); @@ -38,6 +37,7 @@ public: protected: virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); + virtual void UpdateValue(); private: LuaScript* m_LuaScript; diff --git a/Library/MeasureTime.cpp b/Library/MeasureTime.cpp index df9f2a53..37d0df11 100644 --- a/Library/MeasureTime.cpp +++ b/Library/MeasureTime.cpp @@ -91,10 +91,8 @@ void CMeasureTime::TimeToString(WCHAR* buf, size_t bufLen, const WCHAR* format, ** Updates the current time ** */ -bool CMeasureTime::Update() +void CMeasureTime::UpdateValue() { - if (!CMeasure::PreUpdate()) return false; - FILETIME ftUTCTime; GetSystemTimeAsFileTime(&ftUTCTime); @@ -152,8 +150,6 @@ bool CMeasureTime::Update() { m_Value = (double)(m_Time.QuadPart / 10000000); } - - return PostUpdate(); } diff --git a/Library/MeasureTime.h b/Library/MeasureTime.h index 317ff1a1..59161713 100644 --- a/Library/MeasureTime.h +++ b/Library/MeasureTime.h @@ -29,11 +29,11 @@ public: virtual UINT GetTypeID() { return TypeID(); } - virtual bool Update(); virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual); protected: virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); + virtual void UpdateValue(); private: void TimeToString(WCHAR* buf, size_t bufLen, const WCHAR* format, const struct tm* time); diff --git a/Library/MeasureUptime.cpp b/Library/MeasureUptime.cpp index 402808ac..4d6f51ce 100644 --- a/Library/MeasureUptime.cpp +++ b/Library/MeasureUptime.cpp @@ -62,14 +62,10 @@ void CMeasureUptime::ReadConfig(CConfigParser& parser, const WCHAR* section) ** Updates the current uptime ** */ -bool CMeasureUptime::Update() +void CMeasureUptime::UpdateValue() { - if (!CMeasure::PreUpdate()) return false; - ULONGLONG ticks = CSystem::GetTickCount64(); m_Value = (double)(__int64)(ticks / 1000); - - return PostUpdate(); } /* diff --git a/Library/MeasureUptime.h b/Library/MeasureUptime.h index a8a67880..ad2dcbe3 100644 --- a/Library/MeasureUptime.h +++ b/Library/MeasureUptime.h @@ -29,11 +29,11 @@ public: virtual UINT GetTypeID() { return TypeID(); } - virtual bool Update(); virtual const WCHAR* GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual); protected: virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); + virtual void UpdateValue(); private: bool m_AddDaysToHours; diff --git a/Library/MeasureVirtualMemory.cpp b/Library/MeasureVirtualMemory.cpp index 6b2902b0..f3e617f6 100644 --- a/Library/MeasureVirtualMemory.cpp +++ b/Library/MeasureVirtualMemory.cpp @@ -41,13 +41,11 @@ CMeasureVirtualMemory::~CMeasureVirtualMemory() ** Updates the current virtual memory value. ** */ -bool CMeasureVirtualMemory::Update() +void CMeasureVirtualMemory::UpdateValue() { - if (!CMeasure::PreUpdate()) return false; - MEMORYSTATUSEX stat; stat.dwLength = sizeof(MEMORYSTATUSEX); - GlobalMemoryStatusEx(&stat); // Doesn't measure values > 4GB. Should use GlobalMemoryStatusEx instead, but that requires Win2k. + GlobalMemoryStatusEx(&stat); if (m_Total) { m_Value = (double)(__int64)stat.ullTotalPageFile; @@ -56,9 +54,6 @@ bool CMeasureVirtualMemory::Update() { m_Value = (double)(__int64)(stat.ullTotalPageFile - stat.ullAvailPageFile); } - - - return PostUpdate(); } /* diff --git a/Library/MeasureVirtualMemory.h b/Library/MeasureVirtualMemory.h index 3b0adae1..51de7877 100644 --- a/Library/MeasureVirtualMemory.h +++ b/Library/MeasureVirtualMemory.h @@ -29,10 +29,9 @@ public: virtual UINT GetTypeID() { return TypeID(); } - virtual bool Update(); - protected: virtual void ReadConfig(CConfigParser& parser, const WCHAR* section); + virtual void UpdateValue(); private: bool m_Total;