Hardware/Hardware.cs
changeset 110 411b72b73d8f
parent 64 15181001ee61
child 165 813d8bc3192f
     1.1 --- a/Hardware/Hardware.cs	Thu May 06 19:20:38 2010 +0000
     1.2 +++ b/Hardware/Hardware.cs	Sun May 09 16:22:13 2010 +0000
     1.3 @@ -37,11 +37,13 @@
     1.4  
     1.5  using System;
     1.6  using System.Collections.Generic;
     1.7 +using System.Drawing;
     1.8 +using OpenHardwareMonitor.Utilities;
     1.9  
    1.10  namespace OpenHardwareMonitor.Hardware {
    1.11 -  public abstract class Hardware {
    1.12 +  public abstract class Hardware : IHardware {
    1.13  
    1.14 -    private List<ISensor> active = new List<ISensor>();
    1.15 +    private ListSet<ISensor> active = new ListSet<ISensor>();
    1.16  
    1.17      public IHardware[] SubHardware {
    1.18        get { return new IHardware[0]; }
    1.19 @@ -52,24 +54,39 @@
    1.20      }
    1.21  
    1.22      protected void ActivateSensor(Sensor sensor) {
    1.23 -      if (!active.Contains(sensor)) {
    1.24 -        active.Add(sensor);
    1.25 +      if (active.Add(sensor)) 
    1.26          if (SensorAdded != null)
    1.27            SensorAdded(sensor);
    1.28 -      }
    1.29      }
    1.30  
    1.31      protected void DeactivateSensor(Sensor sensor) {
    1.32 -      if (active.Contains(sensor)) {
    1.33 -        active.Remove(sensor);
    1.34 +      if (active.Remove(sensor))
    1.35          if (SensorRemoved != null)
    1.36 -          SensorRemoved(sensor);
    1.37 -      }
    1.38 +          SensorRemoved(sensor);     
    1.39      }
    1.40  
    1.41      #pragma warning disable 67
    1.42      public event SensorEventHandler SensorAdded;
    1.43      public event SensorEventHandler SensorRemoved;
    1.44      #pragma warning restore 67
    1.45 +  
    1.46 +    public abstract string Name { get; }
    1.47 +    public abstract Identifier Identifier { get; }
    1.48 +    public abstract Image Icon { get; }
    1.49 +
    1.50 +    public virtual string GetReport() {
    1.51 +      return null;
    1.52 +    }
    1.53 +
    1.54 +    public abstract void Update();
    1.55 +
    1.56 +    public void Accept(IVisitor visitor) {
    1.57 +      visitor.VisitHardware(this);
    1.58 +    }
    1.59 +
    1.60 +    public void Traverse(IVisitor visitor) {
    1.61 +      foreach (ISensor sensor in active)
    1.62 +        sensor.Accept(visitor);
    1.63 +    }
    1.64    }
    1.65  }