sensor.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (C) 2015 Malte Veerman <malte.veerman@gmail.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU Lesser General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. *
  18. */
  19. #ifndef SENSOR_H
  20. #define SENSOR_H
  21. #include <QtCore/QObject>
  22. namespace Fancontrol
  23. {
  24. class Hwmon;
  25. class Sensor : public QObject
  26. {
  27. Q_OBJECT
  28. Q_PROPERTY(uint index READ index CONSTANT)
  29. Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
  30. Q_PROPERTY(QString path READ path CONSTANT)
  31. Q_PROPERTY(Hwmon * parent READ parent CONSTANT)
  32. public:
  33. explicit Sensor(Hwmon *parent = Q_NULLPTR, uint index = 0, const QString &path = QString());
  34. virtual QString name() const = 0;
  35. virtual void setName(const QString &name) = 0;
  36. virtual void toDefault() = 0;
  37. virtual bool isValid() const = 0;
  38. virtual void update() = 0;
  39. QString path() const { return m_path; }
  40. Hwmon * parent() const { return m_parent; }
  41. uint index() const { return m_index; }
  42. bool operator==(const Sensor &other) { return m_path == other.path(); }
  43. bool operator!=(const Sensor &other) { return m_path != other.path(); }
  44. signals:
  45. void nameChanged();
  46. void error(QString, bool = false);
  47. protected:
  48. Hwmon *const m_parent;
  49. const uint m_index;
  50. const QString m_path;
  51. };
  52. }
  53. #endif // SENSOR_H