/// <summary> /// Constructor /// </summary> /// <param name='shortName'>Short name for the stat. Must not contain spaces. e.g. "LongFrames"</param> /// <param name='name'>Human readable name for the stat. e.g. "Long frames"</param> /// <param name='description'>Description of stat</param> /// <param name='unitName'> /// Unit name for the stat. Should be preceeded by a space if the unit name isn't normally appeneded immediately to the value. /// e.g. " frames" /// </param> /// <param name='category'>Category under which this stat should appear, e.g. "scene". Do not capitalize.</param> /// <param name='container'>Entity to which this stat relates. e.g. scene name if this is a per scene stat.</param> /// <param name='type'>Push or pull</param> /// <param name='pullAction'>Pull stats need an action to update the stat on request. Push stats should set null here.</param> /// <param name='moi'>Measures of interest</param> /// <param name='verbosity'>Verbosity of stat. Controls whether it will appear in short stat display or only full display.</param> public Stat( string shortName, string name, string description, string unitName, string category, string container, StatType type, MeasuresOfInterest moi, Action <Stat> pullAction, StatVerbosity verbosity) { if (StatsManager.SubCommands.Contains(category)) { throw new Exception( string.Format("Stat cannot be in category '{0}' since this is reserved for a subcommand", category)); } foreach (char c in DisallowedShortNameCharacters) { if (shortName.IndexOf(c) != -1) { shortName = shortName.Replace(c, '#'); } // throw new Exception(string.Format("Stat name {0} cannot contain character {1}", shortName, c)); } ShortName = shortName; Name = name; Description = description; UnitName = unitName; Category = category; Container = container; StatType = type; if (StatType == StatType.Push && pullAction != null) { throw new Exception("A push stat cannot have a pull action"); } else { PullAction = pullAction; } MeasuresOfInterest = moi; if ((moi & MeasuresOfInterest.AverageChangeOverTime) == MeasuresOfInterest.AverageChangeOverTime) { m_samples = new Queue <double>(m_maxSamples); } Verbosity = verbosity; }
private void MakeStat(string pName, string pDesc, string pUnit, string pContainer, Action <Stat> act, MeasuresOfInterest moi) { string desc = pDesc; if (desc == null) { desc = pName; } Stat stat = new Stat(pName, pName, desc, pUnit, CategoryServer, pContainer, StatType.Pull, moi, act, StatVerbosity.Debug); StatsManager.RegisterStat(stat); RegisteredStats.Add(pName, stat); }
/// <summary> /// Constructor /// </summary> /// <param name='shortName'>Short name for the stat. Must not contain spaces. e.g. "LongFrames"</param> /// <param name='name'>Human readable name for the stat. e.g. "Long frames"</param> /// <param name='description'>Description of stat</param> /// <param name='unitName'> /// Unit name for the stat. Should be preceeded by a space if the unit name isn't normally appeneded immediately to the value. /// e.g. " frames" /// </param> /// <param name='category'>Category under which this stat should appear, e.g. "scene". Do not capitalize.</param> /// <param name='container'>Entity to which this stat relates. e.g. scene name if this is a per scene stat.</param> /// <param name='type'>Push or pull</param> /// <param name='pullAction'>Pull stats need an action to update the stat on request. Push stats should set null here.</param> /// <param name='moi'>Measures of interest</param> /// <param name='verbosity'>Verbosity of stat. Controls whether it will appear in short stat display or only full display.</param> public Stat( string shortName, string name, string description, string unitName, string category, string container, StatType type, MeasuresOfInterest moi, Action<Stat> pullAction, StatVerbosity verbosity) { if (StatsManager.SubCommands.Contains(category)) throw new Exception( string.Format("Stat cannot be in category '{0}' since this is reserved for a subcommand", category)); foreach (char c in DisallowedShortNameCharacters) { if (shortName.IndexOf(c) != -1) throw new Exception(string.Format("Stat name {0} cannot contain character {1}", shortName, c)); } ShortName = shortName; Name = name; Description = description; UnitName = unitName; Category = category; Container = container; StatType = type; if (StatType == StatType.Push && pullAction != null) throw new Exception("A push stat cannot have a pull action"); else PullAction = pullAction; MeasuresOfInterest = moi; if ((moi & MeasuresOfInterest.AverageChangeOverTime) == MeasuresOfInterest.AverageChangeOverTime) m_samples = new Queue<double>(m_maxSamples); Verbosity = verbosity; }
private void MakeStat(string pName, string pDesc, string pUnit, string pContainer, Action<Stat> act, MeasuresOfInterest moi) { string desc = pDesc; if (desc == null) desc = pName; Stat stat = new Stat(pName, pName, desc, pUnit, CategoryServer, pContainer, StatType.Pull, moi, act, StatVerbosity.Debug); StatsManager.RegisterStat(stat); RegisteredStats.Add(pName, stat); }