Warning, file /plasma/libksysguard/systemstats/SensorsFeatureSensor.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  * SPDX-FileCopyrightText: 2021 David Redondo <kde@david-redondo.de>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005  */
0006 
0007 #ifndef SENSORSFEATURESENSOR_H
0008 #define SENSORSFEATURESENSOR_H
0009 
0010 #include "SensorProperty.h"
0011 #include "systemstats_export.h"
0012 
0013 #ifdef Q_OS_LINUX
0014 
0015 struct sensors_chip_name;
0016 struct sensors_feature;
0017 struct sensors_subfeature;
0018 
0019 namespace KSysGuard
0020 {
0021 /**
0022  * Convenience subclass of SensorProperty that wraps a sensor from a libsensors
0023  * @since 5.23
0024  */
0025 class SYSTEMSTATS_EXPORT SensorsFeatureSensor : public SensorProperty
0026 {
0027     Q_OBJECT
0028 public:
0029     /**
0030      * Update the sensor by reading the current value.
0031      */
0032     void update() override;
0033     ~SensorsFeatureSensor() override = default;
0034 
0035 private:
0036     SensorsFeatureSensor(const QString &id, const sensors_chip_name *const chipName, const sensors_subfeature *const valueFeature, SensorObject *parent);
0037     const sensors_chip_name *m_chipName;
0038     const sensors_subfeature *m_valueFeature;
0039     friend SensorsFeatureSensor *makeSensorsFeatureSensor(const QString &id, const sensors_chip_name *const, const sensors_feature *const, SensorObject *);
0040 };
0041 
0042 /**
0043  * Creates a SensorsFeatureSensor wrapping the sensor represented by @p chipName and @p feature with
0044  * the given @p id and @p parent as parent.
0045  * This function will set the unit of the returned SensorProperty and determines the minimum and maximum if
0046  * available. If the label of @p feature is of the form 'temp%d', 'in%d' or 'fan%d' the name will be
0047  * 'Temperature %d', 'Voltage %d' or 'Fan %d' respectively, otherwise the label will be used as name.
0048  * @returns A pointer to a new SensorsFeatureSensor or @c nullptr if @p parent already contains a sensor
0049  * with @p id, the sensor does not support reading the current value or @c feature->type is greater or
0050  * equal @c SENSORS_FEATURE_MAX_MAIN.
0051  * @since 5.23
0052  */
0053 SYSTEMSTATS_EXPORT SensorsFeatureSensor *
0054 makeSensorsFeatureSensor(const QString &id, const sensors_chip_name *const chipName, const sensors_feature *const feature, SensorObject *parent);
0055 }
0056 #endif
0057 #endif