[Feature] Update library documentation (#580)

* Minor IHardware doc fixes

* Add XML with documentation to NuGet and output

* Update Software namespace docs

* Update some internal classes

* Update main Computer class docs

* Update interfaces docs

* Update Computer class documentation

* Update motherboard docs

* Update hardware docs

* Fix code formatting

* Update SensorVisitor handler doc
This commit is contained in:
Pomian
2021-10-18 13:23:43 +02:00
committed by GitHub
parent 9df5a2de05
commit 3cf5fe92fd
17 changed files with 354 additions and 81 deletions
+33 -51
View File
@@ -28,38 +28,46 @@ namespace LibreHardwareMonitor.Hardware
/// </summary>
public class Computer : IComputer
{
/// <inheritdoc />
public event HardwareEventHandler HardwareAdded;
/// <inheritdoc />
public event HardwareEventHandler HardwareRemoved;
private readonly object _lock = new object();
private readonly List<IGroup> _groups = new List<IGroup>();
private readonly ISettings _settings;
private bool _controllerEnabled;
private bool _cpuEnabled;
private bool _gpuEnabled;
private readonly object _lock = new object();
private bool _memoryEnabled;
private bool _motherboardEnabled;
private bool _networkEnabled;
private bool _open;
private SMBios _smbios;
private bool _storageEnabled;
private bool _psuEnabled;
private SMBios _smbios;
/// <summary>
/// Creates a new <see cref="IComputer"/> instance with basic initial <see cref="Settings"/>.
/// </summary>
public Computer()
{
_settings = new Settings();
}
/// <summary>
/// Creates a new <see cref="IComputer"/> instance with additional <see cref="ISettings"/>.
/// </summary>
/// <param name="settings">Computer settings that will be transferred to each <see cref="IHardware"/>.</param>
public Computer(ISettings settings)
{
_settings = settings ?? new Settings();
}
/// <summary>
/// Gets a list of all known <see cref="IHardware"/> after calling <see cref="Open"/>.
/// <para>Can be updated by <see cref="IVisitor"/>.</para>
/// </summary>
/// <returns>List of all enabled devices.</returns>
/// <inheritdoc />
public IList<IHardware> Hardware
{
get
@@ -90,10 +98,7 @@ namespace LibreHardwareMonitor.Hardware
}
}
/// <summary>
/// Gets or sets a value indicating whether collecting information about <see cref="HardwareType.Cpu"/> devices should be enabled and updated.
/// </summary>
/// <returns><see langword="true"/> if a given category of devices is already enabled.</returns>
/// <inheritdoc />
public bool IsCpuEnabled
{
get { return _cpuEnabled; }
@@ -111,18 +116,7 @@ namespace LibreHardwareMonitor.Hardware
}
}
/// <summary>
/// Gets or sets a value indicating whether collecting information about:
/// <list>
/// <item><see cref="TBalancerGroup"/></item>
/// <item><see cref="HeatmasterGroup"/></item>
/// <item><see cref="AquaComputerGroup"/></item>
/// <item><see cref="AeroCoolGroup"/></item>
/// <item><see cref="NzxtGroup"/></item>
/// </list>
/// devices should be enabled and updated.
/// </summary>
/// <returns><see langword="true"/> if a given category of devices is already enabled.</returns>
/// <inheritdoc />
public bool IsControllerEnabled
{
get { return _controllerEnabled; }
@@ -152,10 +146,7 @@ namespace LibreHardwareMonitor.Hardware
}
}
/// <summary>
/// Gets or sets a value indicating whether collecting information about <see cref="HardwareType.GpuAmd"/> or <see cref="HardwareType.GpuNvidia"/> devices should be enabled and updated.
/// </summary>
/// <returns><see langword="true"/> if a given category of devices is already enabled.</returns>
/// <inheritdoc />
public bool IsGpuEnabled
{
get { return _gpuEnabled; }
@@ -179,10 +170,7 @@ namespace LibreHardwareMonitor.Hardware
}
}
/// <summary>
/// Gets or sets a value indicating whether collecting information about <see cref="HardwareType.Memory"/> devices should be enabled and updated.
/// </summary>
/// <returns><see langword="true"/> if a given category of devices is already enabled.</returns>
/// <inheritdoc />
public bool IsMemoryEnabled
{
get { return _memoryEnabled; }
@@ -200,10 +188,7 @@ namespace LibreHardwareMonitor.Hardware
}
}
/// <summary>
/// Gets or sets a value indicating whether collecting information about <see cref="HardwareType.Motherboard"/> devices should be enabled and updated.
/// </summary>
/// <returns><see langword="true"/> if a given category of devices is already enabled.</returns>
/// <inheritdoc />
public bool IsMotherboardEnabled
{
get { return _motherboardEnabled; }
@@ -221,10 +206,7 @@ namespace LibreHardwareMonitor.Hardware
}
}
/// <summary>
/// Gets or sets a value indicating whether collecting information about <see cref="HardwareType.Network"/> devices should be enabled and updated.
/// </summary>
/// <returns><see langword="true"/> if a given category of devices is already enabled.</returns>
/// <inheritdoc />
public bool IsNetworkEnabled
{
get { return _networkEnabled; }
@@ -242,10 +224,7 @@ namespace LibreHardwareMonitor.Hardware
}
}
/// <summary>
/// Gets or sets a value indicating whether collecting information about <see cref="HardwareType.Storage"/> devices should be enabled and updated.
/// </summary>
/// <returns><see langword="true"/> if a given category of devices is already enabled.</returns>
/// <inheritdoc />
public bool IsStorageEnabled
{
get { return _storageEnabled; }
@@ -263,10 +242,7 @@ namespace LibreHardwareMonitor.Hardware
}
}
/// <summary>
/// Gets or sets a value indicating whether collecting information about <see cref="HardwareType.Psu"/> devices should be enabled and updated.
/// </summary>
/// <returns><see langword="true"/> if a given category of devices is already enabled.</returns>
/// <inheritdoc />
public bool IsPsuEnabled
{
get { return _psuEnabled; }
@@ -287,10 +263,7 @@ namespace LibreHardwareMonitor.Hardware
}
}
/// <summary>
/// Generates full LibreHardwareMonitor report for devices that have been enabled.
/// </summary>
/// <returns>A formatted text string with library, OS and hardware information.</returns>
//// <inheritdoc />
public string GetReport()
{
lock (_lock)
@@ -610,6 +583,9 @@ namespace LibreHardwareMonitor.Hardware
ReportHardware(subHardware, w);
}
/// <summary>
/// If opened before, removes all <see cref="IGroup"/> and triggers <see cref="OpCode.Close"/>, <see cref="InpOut.Close"/> and <see cref="Ring0.Close"/>.
/// </summary>
public void Close()
{
if (!_open)
@@ -633,6 +609,9 @@ namespace LibreHardwareMonitor.Hardware
_open = false;
}
/// <summary>
/// If opened before, removes all <see cref="IGroup"/> and recreates it.
/// </summary>
public void Reset()
{
if (!_open)
@@ -655,6 +634,9 @@ namespace LibreHardwareMonitor.Hardware
}
}
/// <summary>
/// <see cref="Computer"/> specific additional settings passed to its <see cref="IHardware"/>.
/// </summary>
private class Settings : ISettings
{
public bool Contains(string name)
@@ -10,6 +10,12 @@ using System.Linq;
namespace LibreHardwareMonitor.Hardware
{
/// <summary>
/// Object representing a component of the computer.
/// <para>
/// Individual information can be read from the <see cref="Sensors"/>.
/// </para>
/// </summary>
public abstract class Hardware : IHardware
{
protected readonly HashSet<ISensor> _active = new();
@@ -17,6 +23,12 @@ namespace LibreHardwareMonitor.Hardware
protected readonly ISettings _settings;
private string _customName;
/// <summary>
/// Creates a new <see cref="Hardware"/> instance based on the data provided.
/// </summary>
/// <param name="name">Component name.</param>
/// <param name="identifier">Identifier that will be assigned to the device. Based on <see cref="Identifier"/></param>
/// <param name="settings">Additional settings passed by the <see cref="IComputer"/>.</param>
protected Hardware(string name, Identifier identifier, ISettings settings)
{
_settings = settings;
@@ -25,12 +37,18 @@ namespace LibreHardwareMonitor.Hardware
_customName = settings.GetValue(new Identifier(Identifier, "name").ToString(), name);
}
/// <summary>
/// Event triggered when <see cref="Hardware"/> is closing.
/// </summary>
public event HardwareEventHandler Closing;
/// <inheritdoc />
public abstract HardwareType HardwareType { get; }
/// <inheritdoc />
public Identifier Identifier { get; }
/// <inheritdoc />
public string Name
{
get { return _customName; }
@@ -42,30 +60,37 @@ namespace LibreHardwareMonitor.Hardware
}
}
/// <inheritdoc />
public virtual IHardware Parent
{
get { return null; }
}
/// <inheritdoc />
public virtual IDictionary<string, string> Properties => new SortedDictionary<string, string>();
/// <inheritdoc />
public virtual ISensor[] Sensors
{
get { return _active.ToArray(); }
}
/// <inheritdoc />
public IHardware[] SubHardware
{
get { return new IHardware[0]; }
}
/// <inheritdoc />
public virtual string GetReport()
{
return null;
}
/// <inheritdoc />
public abstract void Update();
/// <inheritdoc />
public void Accept(IVisitor visitor)
{
if (visitor == null)
@@ -75,24 +100,28 @@ namespace LibreHardwareMonitor.Hardware
visitor.VisitHardware(this);
}
/// <inheritdoc />
public virtual void Traverse(IVisitor visitor)
{
foreach (ISensor sensor in _active)
sensor.Accept(visitor);
}
/// <inheritdoc />
protected virtual void ActivateSensor(ISensor sensor)
{
if (_active.Add(sensor))
SensorAdded?.Invoke(sensor);
}
/// <inheritdoc />
protected virtual void DeactivateSensor(ISensor sensor)
{
if (_active.Remove(sensor))
SensorRemoved?.Invoke(sensor);
}
/// <inheritdoc />
public virtual void Close()
{
Closing?.Invoke(this);
@@ -0,0 +1,26 @@
// 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 <mmoeller@openhardwaremonitor.org> and Contributors.
// All Rights Reserved.
namespace LibreHardwareMonitor.Hardware
{
/// <summary>
/// Collection of identifiers representing the purpose of the hardware.
/// </summary>
public enum HardwareType
{
Motherboard,
SuperIO,
Cpu,
Memory,
GpuNvidia,
GpuAmd,
Storage,
Network,
Cooler,
EmbeddedController,
Psu
}
}
+62 -3
View File
@@ -8,6 +8,10 @@ using System.Collections.Generic;
namespace LibreHardwareMonitor.Hardware
{
/// <summary>
/// Handler that will trigger the actions assigned to it when the event occurs.
/// </summary>
/// <param name="hardware">Component returned to the assigned action(s).</param>
public delegate void HardwareEventHandler(IHardware hardware);
/// <summary>
@@ -15,28 +19,83 @@ namespace LibreHardwareMonitor.Hardware
/// </summary>
public interface IComputer : IElement
{
/// <summary>
/// Gets or sets a value indicating whether collecting information about <see cref="HardwareType.Cpu"/> devices should be enabled and updated.
/// </summary>
/// <returns><see langword="true"/> if a given category of devices is already enabled.</returns>
bool IsCpuEnabled { get; }
/// <summary>
/// Gets or sets a value indicating whether collecting information about:
/// <list>
/// <item><see cref="LibreHardwareMonitor.Hardware.Controller.TBalancer.TBalancerGroup"/></item>
/// <item><see cref="LibreHardwareMonitor.Hardware.Controller.Heatmaster.HeatmasterGroup"/></item>
/// <item><see cref="LibreHardwareMonitor.Hardware.Controller.AquaComputer.AquaComputerGroup"/></item>
/// <item><see cref="LibreHardwareMonitor.Hardware.Controller.AeroCool.AeroCoolGroup"/></item>
/// <item><see cref="LibreHardwareMonitor.Hardware.Controller.Nzxt.NzxtGroup"/></item>
/// </list>
/// devices should be enabled and updated.
/// </summary>
/// <returns><see langword="true"/> if a given category of devices is already enabled.</returns>
bool IsControllerEnabled { get; }
/// <summary>
/// Gets or sets a value indicating whether collecting information about <see cref="HardwareType.GpuAmd"/> or <see cref="HardwareType.GpuNvidia"/> devices should be enabled and updated.
/// </summary>
/// <returns><see langword="true"/> if a given category of devices is already enabled.</returns>
bool IsGpuEnabled { get; }
IList<IHardware> Hardware { get; }
/// <summary>
/// Gets or sets a value indicating whether collecting information about <see cref="HardwareType.Storage"/> devices should be enabled and updated.
/// </summary>
/// <returns><see langword="true"/> if a given category of devices is already enabled.</returns>
bool IsStorageEnabled { get; }
/// <summary>
/// Gets or sets a value indicating whether collecting information about <see cref="HardwareType.Motherboard"/> devices should be enabled and updated.
/// </summary>
/// <returns><see langword="true"/> if a given category of devices is already enabled.</returns>
bool IsMotherboardEnabled { get; }
/// <summary>
/// Gets or sets a value indicating whether collecting information about <see cref="HardwareType.Network"/> devices should be enabled and updated.
/// </summary>
/// <returns><see langword="true"/> if a given category of devices is already enabled.</returns>
bool IsNetworkEnabled { get; }
/// <summary>
/// Gets or sets a value indicating whether collecting information about <see cref="HardwareType.Memory"/> devices should be enabled and updated.
/// </summary>
/// <returns><see langword="true"/> if a given category of devices is already enabled.</returns>
bool IsMemoryEnabled { get; }
/// <summary>
/// Gets or sets a value indicating whether collecting information about <see cref="HardwareType.Psu"/> devices should be enabled and updated.
/// </summary>
/// <returns><see langword="true"/> if a given category of devices is already enabled.</returns>
bool IsPsuEnabled { get; }
string GetReport();
/// <summary>
/// Gets a list of all known <see cref="IHardware"/>.
/// <para>Can be updated by <see cref="IVisitor"/>.</para>
/// </summary>
/// <returns>List of all enabled devices.</returns>
IList<IHardware> Hardware { get; }
/// <summary>
/// Triggered when a new <see cref="IHardware"/> is registered.
/// </summary>
event HardwareEventHandler HardwareAdded;
/// <summary>
/// Triggered when a <see cref="IHardware"/> is removed.
/// </summary>
event HardwareEventHandler HardwareRemoved;
/// <summary>
/// Generates full LibreHardwareMonitor report for devices that have been enabled.
/// </summary>
/// <returns>A formatted text string with library, OS and hardware information.</returns>
string GetReport();
}
}
+13 -23
View File
@@ -8,28 +8,18 @@ using System.Collections.Generic;
namespace LibreHardwareMonitor.Hardware
{
/// <summary>
/// Handler that will trigger the actions assigned to it when the event occurs.
/// </summary>
/// <param name="sensor">Component returned to the assigned action(s).</param>
public delegate void SensorEventHandler(ISensor sensor);
/// <summary>
/// Reflects what category the device is.
/// </summary>
public enum HardwareType
{
Motherboard,
SuperIO,
Cpu,
Memory,
GpuNvidia,
GpuAmd,
Storage,
Network,
Cooler,
EmbeddedController,
Psu
}
/// <summary>
/// An abstract object that stores information about a device. All sensors are available as an array of <see cref="Sensors"/>.
/// Abstract object that stores information about a device. All sensors are available as an array of <see cref="Sensors"/>.
/// <para>
/// Can contain <see cref="SubHardware"/>.
/// Type specified in <see cref="HardwareType"/>.
/// </para>
/// </summary>
public interface IHardware : IElement
{
@@ -39,7 +29,7 @@ namespace LibreHardwareMonitor.Hardware
HardwareType HardwareType { get; }
/// <summary>
/// Gets unique hardware identifier obtained from the computer.
/// Gets a unique hardware ID that represents its location.
/// </summary>
Identifier Identifier { get; }
@@ -54,12 +44,12 @@ namespace LibreHardwareMonitor.Hardware
IHardware Parent { get; }
/// <summary>
/// Gets an array of all sensors such as temperature, clocks, load etc.
/// Gets an array of all sensors such as <see cref="SensorType.Temperature"/>, <see cref="SensorType.Clock"/>, <see cref="SensorType.Load"/> etc.
/// </summary>
ISensor[] Sensors { get; }
/// <summary>
/// Gets child devices, e.g. SuperIO of the motherboard.
/// Gets child devices, e.g. <see cref="LibreHardwareMonitor.Hardware.Motherboard.Lpc.LpcIO"/> of the <see cref="LibreHardwareMonitor.Hardware.Motherboard.Motherboard"/>.
/// </summary>
IHardware[] SubHardware { get; }
@@ -86,7 +76,7 @@ namespace LibreHardwareMonitor.Hardware
event SensorEventHandler SensorRemoved;
/// <summary>
/// Rarely changed hardware properties that can't be represented as sensors.
/// Gets rarely changed hardware properties that can't be represented as sensors.
/// </summary>
IDictionary<string, string> Properties { get; }
}
@@ -6,20 +6,44 @@
namespace LibreHardwareMonitor.Hardware
{
/// <summary>
/// Abstract object that represents additional parameters included in <see cref="ISensor"/>.
/// </summary>
public interface IParameter : IElement
{
/// <summary>
/// Gets a parameter default value defined by library.
/// </summary>
float DefaultValue { get; }
/// <summary>
/// Gets a parameter description defined by library.
/// </summary>
string Description { get; }
/// <summary>
/// Gets a unique parameter ID that represents its location.
/// </summary>
Identifier Identifier { get; }
/// <summary>
/// Gets or sets information whether the given <see cref="IParameter"/> is the default for <see cref="ISensor"/>.
/// </summary>
bool IsDefault { get; set; }
/// <summary>
/// Gets a parameter name defined by library.
/// </summary>
string Name { get; }
/// <summary>
/// Gets the sensor that is the data container for the given parameter.
/// </summary>
ISensor Sensor { get; }
/// <summary>
/// Gets or sets the current value.
/// </summary>
float Value { get; set; }
}
}
@@ -5,17 +5,35 @@
namespace LibreHardwareMonitor.Hardware
{
/// <summary>
/// Abstract object that stores information about the limits of <see cref="ISensor"/>.
/// </summary>
public interface ISensorLimits
{
/// <summary>
/// Upper limit of <see cref="ISensor"/> value.
/// </summary>
float? HighLimit { get; }
/// <summary>
/// Lower limit of <see cref="ISensor"/> value.
/// </summary>
float? LowLimit { get; }
}
/// <summary>
/// Abstract object that stores information about the critical limits of <see cref="ISensor"/>.
/// </summary>
public interface ICriticalSensorLimits
{
/// <summary>
/// Critical upper limit of <see cref="ISensor"/> value.
/// </summary>
float? CriticalHighLimit { get; }
/// <summary>
/// Critical lower limit of <see cref="ISensor"/> value.
/// </summary>
float? CriticalLowLimit { get; }
}
}
@@ -6,14 +6,35 @@
namespace LibreHardwareMonitor.Hardware
{
/// <summary>
/// Abstract object that stores settings passed to <see cref="IComputer"/>, <see cref="IHardware"/> and <see cref="ISensor"/>.
/// </summary>
public interface ISettings
{
/// <summary>
/// Returns information whether the given collection of settings contains a value assigned to the given key.
/// </summary>
/// <param name="name">Key to which the setting value is assigned.</param>
bool Contains(string name);
/// <summary>
/// Assigns a setting option to a given key.
/// </summary>
/// <param name="name">Key to which the setting value is assigned.</param>
/// <param name="value">Text setting value.</param>
void SetValue(string name, string value);
/// <summary>
/// Gets a setting option assigned to the given key.
/// </summary>
/// <param name="name">Key to which the setting value is assigned.</param>
/// <param name="value">Default value.</param>
string GetValue(string name, string value);
/// <summary>
/// Removes a setting with the specified key from the settings collection.
/// </summary>
/// <param name="name">Key to which the setting value is assigned.</param>
void Remove(string name);
}
}
@@ -11,12 +11,28 @@ namespace LibreHardwareMonitor.Hardware
/// </summary>
public interface IVisitor
{
/// <summary>
/// Refreshes the values of all <see cref="ISensor"/> in all <see cref="IHardware"/> on selected <see cref="IComputer"/>.
/// </summary>
/// <param name="computer">Instance of the computer to be revisited.</param>
void VisitComputer(IComputer computer);
/// <summary>
/// Refreshes the values of all <see cref="ISensor"/> on selected <see cref="IHardware"/>.
/// </summary>
/// <param name="hardware">Instance of the hardware to be revisited.</param>
void VisitHardware(IHardware hardware);
/// <summary>
/// Refreshes the values on selected <see cref="ISensor"/>.
/// </summary>
/// <param name="sensor">Instance of the sensor to be revisited.</param>
void VisitSensor(ISensor sensor);
/// <summary>
/// Refreshes the values on selected <see cref="IParameter"/>.
/// </summary>
/// <param name="parameter">Instance of the parameter to be revisited.</param>
void VisitParameter(IParameter parameter);
}
}
@@ -10,6 +10,9 @@ using System.Text;
namespace LibreHardwareMonitor.Hardware
{
/// <summary>
/// Represents a unique <see cref="ISensor"/>/<see cref="IHardware"/> identifier in text format with a / separator.
/// </summary>
public class Identifier : IComparable<Identifier>
{
private const char Separator = '/';
@@ -28,6 +31,11 @@ namespace LibreHardwareMonitor.Hardware
_identifier = s.ToString();
}
/// <summary>
/// Creates a new identifier instance based on the base <see cref="Identifier"/> and additional elements.
/// </summary>
/// <param name="identifier">Base identifier being the beginning of the new one.</param>
/// <param name="extensions">Additional parts by which the base <see cref="Identifier"/> will be extended.</param>
public Identifier(Identifier identifier, params string[] extensions)
{
CheckIdentifiers(extensions);
@@ -87,7 +95,7 @@ namespace LibreHardwareMonitor.Hardware
}
public static bool operator ==(Identifier id1, Identifier id2)
{
{
if (ReferenceEquals(id1, null) && ReferenceEquals(id2, null))
return true;
@@ -13,6 +13,9 @@ using OperatingSystem = LibreHardwareMonitor.Software.OperatingSystem;
namespace LibreHardwareMonitor.Hardware.Motherboard
{
/// <summary>
/// Represents the motherboard of a computer with its <see cref="LpcIO"/> and <see cref="EmbeddedController"/> as <see cref="SubHardware"/>.
/// </summary>
public class Motherboard : IHardware
{
private readonly LMSensors _lmSensors;
@@ -21,6 +24,11 @@ namespace LibreHardwareMonitor.Hardware.Motherboard
private readonly ISettings _settings;
private string _customName;
/// <summary>
/// Creates motherboard instance by retrieving information from <see cref="LibreHardwareMonitor.Hardware.SMBios"/> and creates a new <see cref="SubHardware"/> based on data from <see cref="LpcIO"/> and <see cref="EmbeddedController"/>.
/// </summary>
/// <param name="smBios"><see cref="LibreHardwareMonitor.Hardware.SMBios"/> table containing motherboard data.</param>
/// <param name="settings">Additional settings passed by <see cref="IComputer"/>.</param>
public Motherboard(SMBios smBios, ISettings settings)
{
IReadOnlyList<ISuperIO> superIO;
@@ -61,7 +69,7 @@ namespace LibreHardwareMonitor.Hardware.Motherboard
_lpcIO = new LpcIO();
superIO = _lpcIO.SuperIO;
}
EmbeddedController embeddedController = EmbeddedController.Create(model, settings);
SubHardware = new IHardware[superIO.Count + (embeddedController != null ? 1 : 0)];
@@ -72,20 +80,27 @@ namespace LibreHardwareMonitor.Hardware.Motherboard
SubHardware[superIO.Count] = embeddedController;
}
/// <inheritdoc/>
public event SensorEventHandler SensorAdded;
/// <inheritdoc/>
public event SensorEventHandler SensorRemoved;
/// <returns><see cref="HardwareType.Motherboard"/></returns>
public HardwareType HardwareType
{
get { return HardwareType.Motherboard; }
}
/// <inheritdoc/>
public Identifier Identifier
{
get { return new Identifier("motherboard"); }
}
/// <summary>
/// Gets the name obtained from <see cref="LibreHardwareMonitor.Hardware.SMBios"/>.
/// </summary>
public string Name
{
get { return _customName; }
@@ -97,25 +112,31 @@ namespace LibreHardwareMonitor.Hardware.Motherboard
}
}
/// <inheritdoc/>
/// <returns>Always <see langword="null"/></returns>
public virtual IHardware Parent
{
get { return null; }
}
/// <inheritdoc/>
public virtual IDictionary<string, string> Properties => new SortedDictionary<string, string>();
/// <inheritdoc/>
public ISensor[] Sensors
{
get { return new ISensor[0]; }
}
/// <summary>
/// Gets the SMBios information.
/// Gets the <see cref="LibreHardwareMonitor.Hardware.SMBios"/> information.
/// </summary>
public SMBios SMBios { get; }
/// <inheritdoc/>
public IHardware[] SubHardware { get; }
/// <inheritdoc/>
public string GetReport()
{
StringBuilder r = new();
@@ -130,9 +151,13 @@ namespace LibreHardwareMonitor.Hardware.Motherboard
return r.ToString();
}
/// <summary>
/// Motherboard itself cannot be updated. Update <see cref="SubHardware"/> instead.
/// </summary>
public void Update()
{ }
{}
/// <inheritdoc/>
public void Accept(IVisitor visitor)
{
if (visitor == null)
@@ -142,12 +167,16 @@ namespace LibreHardwareMonitor.Hardware.Motherboard
visitor.VisitHardware(this);
}
/// <inheritdoc/>
public void Traverse(IVisitor visitor)
{
foreach (IHardware hardware in SubHardware)
hardware.Accept(visitor);
}
/// <summary>
/// Closes <see cref="SubHardware"/> using <see cref="Hardware.Close"/>.
/// </summary>
public void Close()
{
_lmSensors?.Close();
@@ -6,8 +6,17 @@
namespace LibreHardwareMonitor.Hardware
{
/// <summary>
/// Composite class containing information about the selected <see cref="ISensor"/>.
/// </summary>
public struct ParameterDescription
{
/// <summary>
/// Creates a new instance and assigns values.
/// </summary>
/// <param name="name">Name of the selected component.</param>
/// <param name="description">Description of the selected component.</param>
/// <param name="defaultValue">Default value of the selected component.</param>
public ParameterDescription(string name, string description, float defaultValue)
{
Name = name;
@@ -15,10 +24,19 @@ namespace LibreHardwareMonitor.Hardware
DefaultValue = defaultValue;
}
/// <summary>
/// Gets a name of the parent <see cref="ISensor"/>.
/// </summary>
public string Name { get; }
/// <summary>
/// Gets a description of the parent <see cref="ISensor"/>.
/// </summary>
public string Description { get; }
/// <summary>
/// Gets a default value of the parent <see cref="ISensor"/>.
/// </summary>
public float DefaultValue { get; }
}
}
@@ -8,15 +8,26 @@ using System;
namespace LibreHardwareMonitor.Hardware
{
/// <summary>
/// Observer making calls to selected component <see cref="ISensor"/>'s.
/// </summary>
public class SensorVisitor : IVisitor
{
private readonly SensorEventHandler _handler;
/// <summary>
/// Creates a new observer instance.
/// </summary>
/// <param name="handler">Instance of the <see cref="SensorEventHandler"/> that triggers events during visiting the <see cref="ISensor"/>.</param>
public SensorVisitor(SensorEventHandler handler)
{
_handler = handler ?? throw new ArgumentNullException(nameof(handler));
}
/// <summary>
/// Goes through all the components of the specified <see cref="IComputer"/> with its <see cref="IElement.Traverse(IVisitor)"/>.
/// </summary>
/// <param name="computer">Computer class instance that is derived from the <see cref="IComputer"/> interface.</param>
public void VisitComputer(IComputer computer)
{
if (computer == null)
@@ -26,6 +37,10 @@ namespace LibreHardwareMonitor.Hardware
computer.Traverse(this);
}
/// <summary>
/// Goes through all the components of the specified <see cref="IHardware"/> with its <see cref="IElement.Traverse(IVisitor)"/>.
/// </summary>
/// <param name="hardware">Hardware class instance that is derived from the <see cref="IHardware"/> interface.</param>
public void VisitHardware(IHardware hardware)
{
if (hardware == null)
@@ -35,11 +50,22 @@ namespace LibreHardwareMonitor.Hardware
hardware.Traverse(this);
}
/// <summary>
/// Goes through all the components of the specified <see cref="ISensor"/> using <see cref="SensorEventHandler"/>.
/// </summary>
/// <param name="sensor">Sensor class instance that is derived from the <see cref="ISensor"/> interface.</param>
public void VisitSensor(ISensor sensor)
{
_handler(sensor);
}
/// <summary>
/// Goes through all the components of the specified <see cref="IParameter"/>.
/// <para>
/// <see cref="NotImplementedException"/>
/// </para>
/// </summary>
/// <param name="parameter">Parameter class instance that is derived from the <see cref="IParameter"/> interface.</param>
public void VisitParameter(IParameter parameter)
{ }
}
+3
View File
@@ -8,6 +8,9 @@
namespace LibreHardwareMonitor.Interop
{
/// <summary>
/// Driver with access at kernel level.
/// </summary>
internal static class Ring0
{
public const uint INVALID_PCI_ADDRESS = 0xFFFFFFFF;
+9
View File
@@ -10,10 +10,16 @@ using System.Runtime.InteropServices;
namespace LibreHardwareMonitor.Interop
{
/// <summary>
/// Contains Win32 definitions for Windows NT.
/// </summary>
internal static class WinNt
{
internal const int STATUS_SUCCESS = 0;
/// <summary>
/// Describes a local identifier for an adapter.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal struct LUID
{
@@ -21,6 +27,9 @@ namespace LibreHardwareMonitor.Interop
public readonly int HighPart;
}
/// <summary>
/// Represents a 64-bit signed integer value.
/// </summary>
[StructLayout(LayoutKind.Explicit, Size = 8)]
internal struct LARGE_INTEGER
{
@@ -24,6 +24,9 @@
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<OutputPath>..\bin\Release\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\inpout32.dll" />
<EmbeddedResource Include="Resources\inpoutx64.dll" />
@@ -8,8 +8,14 @@ using System;
namespace LibreHardwareMonitor.Software
{
/// <summary>
/// Contains basic information about the operating system.
/// </summary>
public static class OperatingSystem
{
/// <summary>
/// Statically checks if the current system <see cref="Is64Bit"/> and <see cref="IsUnix"/>.
/// </summary>
static OperatingSystem()
{
// The operating system doesn't change during execution so let's query it just one time.
@@ -20,8 +26,14 @@ namespace LibreHardwareMonitor.Software
Is64Bit = true;
}
/// <summary>
/// Gets information about whether the current system is 64 bit.
/// </summary>
public static bool Is64Bit { get; }
/// <summary>
/// Gets information about whether the current system is Unix based.
/// </summary>
public static bool IsUnix { get; }
}
}