StatReporter.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System.Collections.Generic;
  2. using System.Collections.ObjectModel;
  3. namespace com.zibra.common.Solver
  4. {
  5. /// <summary>
  6. /// Interface that allows querying various stats from an object.
  7. /// </summary>
  8. public interface StatReporter
  9. {
  10. #region Public interface
  11. /// <summary>
  12. /// Return various stats of an object.
  13. /// </summary>
  14. /// <remarks>
  15. /// This is implemented by simulation volumes and return values specific to that type of simulation.
  16. /// </remarks>
  17. public List<string> GetStats();
  18. #endregion
  19. }
  20. /// <summary>
  21. /// Class that hold references to all objects that implement <see cref="StatReporter"/>.
  22. /// </summary>
  23. /// <remarks>
  24. /// Classes that implement <see cref="StatReporter"/> are responsible for adding and removing references.
  25. /// </remarks>
  26. public static class StatReporterCollection
  27. {
  28. #region Public interface
  29. /// <summary>
  30. /// Return all active objects that implement <see cref="StatReporter"/>.
  31. /// </summary>
  32. public static ReadOnlyCollection<StatReporter> GetStatReporters()
  33. {
  34. return StatReporters.AsReadOnly();
  35. }
  36. /// <summary>
  37. /// Adds reference to <see cref="StatReporter"/>.
  38. /// </summary>
  39. public static void Add(StatReporter obj)
  40. {
  41. StatReporters.Add(obj);
  42. }
  43. /// <summary>
  44. /// Removes reference to <see cref="StatReporter"/>.
  45. /// </summary>
  46. public static void Remove(StatReporter obj)
  47. {
  48. StatReporters.Remove(obj);
  49. }
  50. #endregion
  51. #region Implementation details
  52. private static List<StatReporter> StatReporters = new List<StatReporter>();
  53. #endregion
  54. }
  55. }