sensor.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (C) 2015 Malte Veerman <maldela@halloarsch.de>
  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. #include <QtCore/QString>
  23. namespace Fancontrol
  24. {
  25. class Hwmon;
  26. class Sensor : public QObject
  27. {
  28. Q_OBJECT
  29. Q_PROPERTY(uint index READ index CONSTANT)
  30. Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
  31. Q_PROPERTY(QString path READ path CONSTANT)
  32. Q_PROPERTY(Hwmon * parent READ parent CONSTANT)
  33. public:
  34. explicit Sensor(Hwmon *parent, uint index, const QString &path = QString());
  35. virtual QString name() const = 0;
  36. virtual void setName(const QString &name) = 0;
  37. virtual void reset() = 0;
  38. QString path() const { return m_path; }
  39. Hwmon * parent() const { return m_parent; }
  40. uint index() const { return m_index; }
  41. public slots:
  42. virtual void update() = 0;
  43. signals:
  44. void nameChanged();
  45. void errorChanged(QString);
  46. protected:
  47. Hwmon *const m_parent;
  48. const uint m_index;
  49. const QString m_path;
  50. };
  51. }
  52. #endif // SENSOR_H