Refactoring, housekeeping, documentation

Add a class diagram. Still needs some details.
Refactor to better respect SOLID principles.
Housekeeping, move and rename classes/files.
This commit is contained in:
2022-09-27 00:09:30 +02:00
parent 4f6a1dfc4f
commit 289c55b78c
28 changed files with 402 additions and 339 deletions

View File

@@ -0,0 +1,14 @@
#ifndef GPUSENSORSFACADE_H_
#define GPUSENSORSFACADE_H_
#include <memory>
#include <vector>
#include <sensor/Sensor.h>
class GPUSensorsFacade {
public:
std::vector<std::shared_ptr<Sensor>> TemperatureSensors();
};
#endif // GPUSENSORSFACADE_H_

View File

@@ -5,10 +5,10 @@
#include <sensor/Sensor.h>
class HwmonSensor : public Sensor {
class LMSensor : public Sensor {
public:
HwmonSensor(const sensors_chip_name *chipName, const sensors_feature *feature,
const sensors_subfeature *subfeature);
LMSensor(const sensors_chip_name *chipName, const sensors_feature *feature,
const sensors_subfeature *subfeature);
int value() override;
const std::string toString() const override;

View File

@@ -0,0 +1,27 @@
#ifndef LMSENSORSFACADE_H_
#define LMSENSORSFACADE_H_
#include <memory>
#include <vector>
#include <sensors/sensors.h>
#include <sensor/Sensor.h>
class LMSensorsFacade {
public:
LMSensorsFacade();
~LMSensorsFacade();
std::vector<std::shared_ptr<Sensor>> TemperatureSensors();
std::vector<std::shared_ptr<Sensor>> RPMSensors();
private:
template <sensors_subfeature_type T>
std::vector<std::shared_ptr<Sensor>> Sensors();
private:
FILE *mConfigFile;
};
#endif // LMSENSORSFACADE_H_

View File

@@ -0,0 +1,20 @@
#ifndef SENSORMANAGER_H_
#define SENSORMANAGER_H_
#include <memory>
#include <sensor/GPUSensorsFacade.h>
#include <sensor/LMSensorsFacade.h>
class SensorManager {
public:
SensorManager();
std::vector<std::shared_ptr<Sensor>> TemperatureSensors();
std::vector<std::shared_ptr<Sensor>> RPMSensors();
private:
std::unique_ptr<LMSensorsFacade> mLMSensorsFacade;
std::unique_ptr<GPUSensorsFacade> mGPUSensorsFacade;
};
#endif // SENSORMANAGER_H_

View File

@@ -1,26 +0,0 @@
#ifndef SENSORSWRAPPER_H_
#define SENSORSWRAPPER_H_
#include <memory>
#include <vector>
#include <sensors/sensors.h>
#include <fan/PwmControl.h>
#include <sensor/Sensor.h>
class SensorsWrapper {
public:
SensorsWrapper();
~SensorsWrapper();
std::vector<std::shared_ptr<Sensor>>
Sensors(sensors_subfeature_type sensorType);
std::vector<std::shared_ptr<PwmControl>> PwmControls();
private:
FILE *mConfigFile;
};
#endif // SENSORSWRAPPER_H_