openhardwaremonitor/Hardware/SensorVisitor.cs

44 lines
1.1 KiB
C#
Raw Permalink Normal View History

2010-08-04 19:10:20 +00:00
/*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
2010-08-04 19:10:20 +00:00
Copyright (C) 2009-2010 Michael Möller <mmoeller@openhardwaremonitor.org>
2010-08-04 19:10:20 +00:00
*/
using System;
using System.Collections.Generic;
namespace OpenHardwareMonitor.Hardware {
public class SensorVisitor : IVisitor {
private readonly SensorEventHandler handler;
2010-08-04 19:10:20 +00:00
public SensorVisitor(SensorEventHandler handler) {
2010-08-15 14:46:58 +00:00
if (handler == null)
throw new ArgumentNullException("handler");
2010-08-04 19:10:20 +00:00
this.handler = handler;
}
public void VisitComputer(IComputer computer) {
2010-08-15 14:46:58 +00:00
if (computer == null)
throw new ArgumentNullException("computer");
2010-08-04 19:10:20 +00:00
computer.Traverse(this);
}
public void VisitHardware(IHardware hardware) {
2010-08-15 14:46:58 +00:00
if (hardware == null)
throw new ArgumentNullException("hardware");
2010-08-04 19:10:20 +00:00
hardware.Traverse(this);
}
public void VisitSensor(ISensor sensor) {
handler(sensor);
}
public void VisitParameter(IParameter parameter) { }
}
}