Add generic PercentageStat.

Not yet used.
connector_plugin
Justin Clark-Casey (justincc) 2012-10-04 01:27:40 +01:00
parent e717398f6c
commit 3d36a6d55c
2 changed files with 34 additions and 3 deletions

View File

@ -153,9 +153,9 @@ namespace OpenSim.Framework.Monitoring
public string ShortName { get; private set; }
public string Name { get; private set; }
public string Description { get; private set; }
public string UnitName { get; private set; }
public virtual string UnitName { get; private set; }
public double Value { get; set; }
public virtual double Value { get; set; }
public Stat(
string shortName, string name, string unitName, string category, string container, StatVerbosity verbosity, string description)
@ -176,4 +176,35 @@ namespace OpenSim.Framework.Monitoring
return string.Format("{0}+{1}+{2}", container, category, shortName);
}
}
public class PercentageStat : Stat
{
public int Antecedent { get; set; }
public int Consequent { get; set; }
public override double Value
{
get
{
int c = Consequent;
// Avoid any chance of a multi-threaded divide-by-zero
if (c == 0)
return 0;
return (double)Antecedent / c;
}
set
{
throw new Exception("Cannot set value on a PercentageStat");
}
}
public PercentageStat(
string shortName, string name, string category, string container, StatVerbosity verbosity, string description)
: base(shortName, name, " %", category, container, verbosity, description)
{
}
}
}