// 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/. // Copyright (C) LibreHardwareMonitor and Contributors. // Partial Copyright (C) Michael Möller and Contributors. // All Rights Reserved. using System; namespace LibreHardwareMonitor.Hardware; /// /// Observer making calls to selected component 's. /// public class SensorVisitor : IVisitor { private readonly SensorEventHandler _handler; /// /// Creates a new observer instance. /// /// Instance of the that triggers events during visiting the . public SensorVisitor(SensorEventHandler handler) { _handler = handler ?? throw new ArgumentNullException(nameof(handler)); } /// /// Goes through all the components of the specified with its . /// /// Computer class instance that is derived from the interface. public void VisitComputer(IComputer computer) { if (computer == null) throw new ArgumentNullException(nameof(computer)); computer.Traverse(this); } /// /// Goes through all the components of the specified with its . /// /// Hardware class instance that is derived from the interface. public void VisitHardware(IHardware hardware) { if (hardware == null) throw new ArgumentNullException(nameof(hardware)); hardware.Traverse(this); } /// /// Goes through all the components of the specified using . /// /// Sensor class instance that is derived from the interface. public void VisitSensor(ISensor sensor) { _handler(sensor); } /// /// Goes through all the components of the specified . /// /// /// /// /// Parameter class instance that is derived from the interface. public void VisitParameter(IParameter parameter) { } }