mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Code cleanup
This commit is contained in:
parent
7348f5eb6e
commit
b2d245016a
@ -35,8 +35,11 @@ extern CRainmeter* Rainmeter;
|
||||
** The constructor. This is the base class for the net-meters.
|
||||
**
|
||||
*/
|
||||
CMeasureNet::CMeasureNet(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
|
||||
CMeasureNet::CMeasureNet(CMeterWindow* meterWindow, const WCHAR* name, NET type) : CMeasure(meterWindow, name),
|
||||
m_Net(type),
|
||||
m_Interface(),
|
||||
m_Octets(),
|
||||
m_FirstTime(true),
|
||||
m_Cumulative(false)
|
||||
{
|
||||
}
|
||||
@ -408,25 +411,68 @@ ULONG64 CMeasureNet::GetNetStatsValue(NET net)
|
||||
}
|
||||
|
||||
/*
|
||||
** Read the options specified in the ini file. Base implementation for In/Out/Total.
|
||||
** Updates the current value.
|
||||
**
|
||||
*/
|
||||
void CMeasureNet::ReadOptions(CConfigParser& parser, const WCHAR* section, NET net)
|
||||
void CMeasureNet::UpdateValue()
|
||||
{
|
||||
if (c_Table == NULL) return;
|
||||
|
||||
if (m_Cumulative)
|
||||
{
|
||||
m_Value = (double)(__int64)GetNetStatsValue(m_Net);
|
||||
}
|
||||
else
|
||||
{
|
||||
ULONG64 value = 0;
|
||||
|
||||
if (!m_FirstTime)
|
||||
{
|
||||
value = GetNetOctets(m_Net);
|
||||
if (value > m_Octets)
|
||||
{
|
||||
ULONG64 tmpValue = value;
|
||||
value -= m_Octets;
|
||||
m_Octets = tmpValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Octets = value;
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Octets = GetNetOctets(m_Net);
|
||||
m_FirstTime = false;
|
||||
}
|
||||
|
||||
m_Value = (double)(__int64)value;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Read the options specified in the ini file.
|
||||
**
|
||||
*/
|
||||
void CMeasureNet::ReadOptions(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
CMeasure::ReadOptions(parser, section);
|
||||
|
||||
double value;
|
||||
const WCHAR* netName = NULL;
|
||||
|
||||
if (net == NET_IN)
|
||||
if (m_Net == NET_IN)
|
||||
{
|
||||
netName = L"NetInSpeed";
|
||||
value = Rainmeter->GetGlobalOptions().netInSpeed;
|
||||
}
|
||||
else if (net == NET_OUT)
|
||||
else if (m_Net == NET_OUT)
|
||||
{
|
||||
netName = L"NetOutSpeed";
|
||||
value = Rainmeter->GetGlobalOptions().netOutSpeed;
|
||||
}
|
||||
else
|
||||
else // if (m_Net == NET_TOTAL)
|
||||
{
|
||||
netName = L"NetTotalSpeed";
|
||||
value = Rainmeter->GetGlobalOptions().netInSpeed + Rainmeter->GetGlobalOptions().netOutSpeed;
|
||||
|
@ -30,16 +30,6 @@ typedef VOID (NETIOAPI_API_ * FPFREEMIBTABLE)(PVOID Memory);
|
||||
class CMeasureNet : public CMeasure
|
||||
{
|
||||
public:
|
||||
enum NET
|
||||
{
|
||||
NET_IN,
|
||||
NET_OUT,
|
||||
NET_TOTAL
|
||||
};
|
||||
|
||||
CMeasureNet(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeasureNet();
|
||||
|
||||
virtual UINT GetTypeID() { return TypeID<CMeasureNet>(); }
|
||||
|
||||
static void UpdateIFTable();
|
||||
@ -53,12 +43,28 @@ public:
|
||||
static void FinalizeNewApi();
|
||||
|
||||
protected:
|
||||
void ReadOptions(CConfigParser& parser, const WCHAR* section, CMeasureNet::NET net);
|
||||
enum NET
|
||||
{
|
||||
NET_IN,
|
||||
NET_OUT,
|
||||
NET_TOTAL
|
||||
};
|
||||
|
||||
CMeasureNet(CMeterWindow* meterWindow, const WCHAR* name, NET type);
|
||||
virtual ~CMeasureNet();
|
||||
|
||||
virtual void ReadOptions(CConfigParser& parser, const WCHAR* section);
|
||||
virtual void UpdateValue();
|
||||
|
||||
private:
|
||||
ULONG64 GetNetOctets(NET net);
|
||||
ULONG64 GetNetStatsValue(NET net);
|
||||
|
||||
NET m_Net;
|
||||
UINT m_Interface;
|
||||
|
||||
ULONG64 m_Octets;
|
||||
bool m_FirstTime;
|
||||
bool m_Cumulative;
|
||||
|
||||
static std::vector<ULONG64> c_OldStatValues;
|
||||
|
@ -23,9 +23,7 @@
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeasureNetIn::CMeasureNetIn(CMeterWindow* meterWindow, const WCHAR* name) : CMeasureNet(meterWindow, name),
|
||||
m_FirstTime(true),
|
||||
m_InOctets()
|
||||
CMeasureNetIn::CMeasureNetIn(CMeterWindow* meterWindow, const WCHAR* name) : CMeasureNet(meterWindow, name, NET_IN)
|
||||
{
|
||||
}
|
||||
|
||||
@ -35,56 +33,4 @@ CMeasureNetIn::CMeasureNetIn(CMeterWindow* meterWindow, const WCHAR* name) : CMe
|
||||
*/
|
||||
CMeasureNetIn::~CMeasureNetIn()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** Updates the current net in value.
|
||||
**
|
||||
*/
|
||||
void CMeasureNetIn::UpdateValue()
|
||||
{
|
||||
if (c_Table == NULL) return;
|
||||
|
||||
if (m_Cumulative)
|
||||
{
|
||||
m_Value = (double)(__int64)GetNetStatsValue(NET_IN);
|
||||
}
|
||||
else
|
||||
{
|
||||
ULONG64 value = 0;
|
||||
|
||||
if (!m_FirstTime)
|
||||
{
|
||||
value = GetNetOctets(NET_IN);
|
||||
if (value > m_InOctets)
|
||||
{
|
||||
ULONG64 tmpValue = value;
|
||||
value -= m_InOctets;
|
||||
m_InOctets = tmpValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_InOctets = value;
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_InOctets = GetNetOctets(NET_IN);
|
||||
m_FirstTime = false;
|
||||
}
|
||||
|
||||
m_Value = (double)(__int64)value;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Read the options specified in the ini file.
|
||||
**
|
||||
*/
|
||||
void CMeasureNetIn::ReadOptions(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
CMeasure::ReadOptions(parser, section);
|
||||
CMeasureNet::ReadOptions(parser, section, NET_IN);
|
||||
}
|
||||
|
||||
}
|
@ -16,8 +16,8 @@
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __METERNET_H__
|
||||
#define __METERNET_H__
|
||||
#ifndef __MEASURENETIN_H__
|
||||
#define __MEASURENETIN_H__
|
||||
|
||||
#include "MeasureNet.h"
|
||||
|
||||
@ -26,14 +26,6 @@ class CMeasureNetIn : public CMeasureNet
|
||||
public:
|
||||
CMeasureNetIn(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeasureNetIn();
|
||||
|
||||
protected:
|
||||
virtual void ReadOptions(CConfigParser& parser, const WCHAR* section);
|
||||
virtual void UpdateValue();
|
||||
|
||||
private:
|
||||
bool m_FirstTime;
|
||||
ULONG64 m_InOctets;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -23,9 +23,7 @@
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeasureNetOut::CMeasureNetOut(CMeterWindow* meterWindow, const WCHAR* name) : CMeasureNet(meterWindow, name),
|
||||
m_FirstTime(true),
|
||||
m_OutOctets()
|
||||
CMeasureNetOut::CMeasureNetOut(CMeterWindow* meterWindow, const WCHAR* name) : CMeasureNet(meterWindow, name, NET_OUT)
|
||||
{
|
||||
}
|
||||
|
||||
@ -36,54 +34,3 @@ CMeasureNetOut::CMeasureNetOut(CMeterWindow* meterWindow, const WCHAR* name) : C
|
||||
CMeasureNetOut::~CMeasureNetOut()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** Updates the current net out value.
|
||||
**
|
||||
*/
|
||||
void CMeasureNetOut::UpdateValue()
|
||||
{
|
||||
if (c_Table == NULL) return;
|
||||
|
||||
if (m_Cumulative)
|
||||
{
|
||||
m_Value = (double)(__int64)GetNetStatsValue(NET_OUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
ULONG64 value = 0;
|
||||
|
||||
if (!m_FirstTime)
|
||||
{
|
||||
value = GetNetOctets(NET_OUT);
|
||||
if (value > m_OutOctets)
|
||||
{
|
||||
ULONG64 tmpValue = value;
|
||||
value -= m_OutOctets;
|
||||
m_OutOctets = tmpValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_OutOctets = value;
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_OutOctets = GetNetOctets(NET_OUT);
|
||||
m_FirstTime = false;
|
||||
}
|
||||
|
||||
m_Value = (double)(__int64)value;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Read the options specified in the ini file.
|
||||
**
|
||||
*/
|
||||
void CMeasureNetOut::ReadOptions(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
CMeasure::ReadOptions(parser, section);
|
||||
CMeasureNet::ReadOptions(parser, section, NET_OUT);
|
||||
}
|
||||
|
@ -16,8 +16,8 @@
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __METERNETOUT_H__
|
||||
#define __METERNETOUT_H__
|
||||
#ifndef __MEASURENETOUT_H__
|
||||
#define __MEASURENETOUT_H__
|
||||
|
||||
#include "MeasureNet.h"
|
||||
|
||||
@ -26,14 +26,6 @@ class CMeasureNetOut : public CMeasureNet
|
||||
public:
|
||||
CMeasureNetOut(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeasureNetOut();
|
||||
|
||||
protected:
|
||||
virtual void ReadOptions(CConfigParser& parser, const WCHAR* section);
|
||||
virtual void UpdateValue();
|
||||
|
||||
private:
|
||||
bool m_FirstTime;
|
||||
ULONG64 m_OutOctets;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -23,9 +23,7 @@
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeasureNetTotal::CMeasureNetTotal(CMeterWindow* meterWindow, const WCHAR* name) : CMeasureNet(meterWindow, name),
|
||||
m_FirstTime(true),
|
||||
m_TotalOctets()
|
||||
CMeasureNetTotal::CMeasureNetTotal(CMeterWindow* meterWindow, const WCHAR* name) : CMeasureNet(meterWindow, name, NET_TOTAL)
|
||||
{
|
||||
}
|
||||
|
||||
@ -36,54 +34,3 @@ CMeasureNetTotal::CMeasureNetTotal(CMeterWindow* meterWindow, const WCHAR* name)
|
||||
CMeasureNetTotal::~CMeasureNetTotal()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** Updates the current net total value.
|
||||
**
|
||||
*/
|
||||
void CMeasureNetTotal::UpdateValue()
|
||||
{
|
||||
if (c_Table == NULL) return;
|
||||
|
||||
if (m_Cumulative)
|
||||
{
|
||||
m_Value = (double)(__int64)GetNetStatsValue(NET_TOTAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
ULONG64 value = 0;
|
||||
|
||||
if (!m_FirstTime)
|
||||
{
|
||||
value = GetNetOctets(NET_TOTAL);
|
||||
if (value > m_TotalOctets)
|
||||
{
|
||||
ULONG64 tmpValue = value;
|
||||
value -= m_TotalOctets;
|
||||
m_TotalOctets = tmpValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TotalOctets = value;
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TotalOctets = GetNetOctets(NET_TOTAL);
|
||||
m_FirstTime = false;
|
||||
}
|
||||
|
||||
m_Value = (double)(__int64)value;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Read the options specified in the ini file.
|
||||
**
|
||||
*/
|
||||
void CMeasureNetTotal::ReadOptions(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
CMeasure::ReadOptions(parser, section);
|
||||
CMeasureNet::ReadOptions(parser, section, NET_TOTAL);
|
||||
}
|
||||
|
@ -16,8 +16,8 @@
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __METERNETTOTAL_H__
|
||||
#define __METERNETTOTAL_H__
|
||||
#ifndef __MEASURENETTOTAL_H__
|
||||
#define __MEASURENETTOTAL_H__
|
||||
|
||||
#include "MeasureNet.h"
|
||||
|
||||
@ -26,14 +26,6 @@ class CMeasureNetTotal : public CMeasureNet
|
||||
public:
|
||||
CMeasureNetTotal(CMeterWindow* meterWindow, const WCHAR* name);
|
||||
virtual ~CMeasureNetTotal();
|
||||
|
||||
protected:
|
||||
virtual void ReadOptions(CConfigParser& parser, const WCHAR* section);
|
||||
virtual void UpdateValue();
|
||||
|
||||
private:
|
||||
bool m_FirstTime;
|
||||
ULONG64 m_TotalOctets;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user