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