Torc  0.1
torcdevice.h
Go to the documentation of this file.
1 #ifndef TORCDEVICE_H
2 #define TORCDEVICE_H
3 
4 // Qt
5 #include <QHash>
6 #include <QMutex>
7 #include <QString>
8 #include <QObject>
9 
10 // Torc
11 #include "torcreferencecounted.h"
12 #include "torcdevicehandler.h"
13 
14 #define NETWORK_DEVICE_STRING QStringLiteral("network")
15 #define CONSTANT_DEVICE_STRING QStringLiteral("constant")
16 #define DEVICE_LINE_ITEM QStringLiteral("|<FONT POINT-SIZE=\"10\">%1</FONT>")
17 #define DEVICE_CONSTANT QStringLiteral("Constant")
18 
19 class TorcDevice : public QObject, public TorcReferenceCounter
20 {
21  friend class TorcCentral;
22 
23  Q_OBJECT
24  Q_PROPERTY(bool valid READ GetValid() NOTIFY ValidChanged(Valid))
25  Q_PROPERTY(double value READ GetValue() NOTIFY ValueChanged(Value))
26  Q_PROPERTY(QString modelId READ GetModelId() CONSTANT)
27  Q_PROPERTY(QString uniqueId READ GetUniqueId() CONSTANT)
28  Q_PROPERTY(QString userName READ GetUserName() CONSTANT)
29  Q_PROPERTY(QString userDescription READ GetUserDescription() CONSTANT)
30 
31  public:
32  TorcDevice(bool Valid, double Value, double Default,
33  const QString &ModelId, const QVariantMap &Details);
34 
35  virtual void Start (void);
36  virtual void Stop (void);
37  virtual QStringList GetDescription (void);
38 
39  public slots:
40  virtual void SetValue (double Value);
41  virtual void SetValid (bool Valid);
42 
43  bool GetValid (void);
44  double GetValue (void);
45  double GetDefaultValue (void);
46  QString GetModelId (void);
47  QString GetUniqueId (void);
48  QString GetUserName (void);
49  QString GetUserDescription (void);
50 
51  signals:
52  void ValidChanged (bool Valid);
53  void ValueChanged (double Value);
54 
55  protected:
56  virtual ~TorcDevice();
57 
58  protected:
59  bool valid;
60  double value;
61  double defaultValue;
62  QString modelId;
63  QString uniqueId;
64  QString userName;
65  QString userDescription;
66  QMutex lock;
67 
68  static QHash<QString,TorcDevice*> *gDeviceList;
69  static QMutex *gDeviceListLock;
70 
71  bool wasInvalid;
72 };
73 
74 #endif // TORCDEVICE_H
void ValueChanged(double Value)
QString GetUserName(void)
Definition: torcdevice.cpp:168
double GetDefaultValue(void)
Definition: torcdevice.cpp:149
QString uniqueId
Definition: torcdevice.h:63
virtual void SetValid(bool Valid)
Definition: torcdevice.cpp:101
A reference counting implementation.
bool GetValid(void)
Definition: torcdevice.cpp:135
QString GetUserDescription(void)
Definition: torcdevice.cpp:175
QString userDescription
Definition: torcdevice.h:65
static QMutex * gDeviceListLock
Definition: torcdevice.h:69
static QHash< QString, TorcDevice * > * gDeviceList
Definition: torcdevice.h:68
double defaultValue
Definition: torcdevice.h:61
virtual void SetValue(double Value)
Definition: torcdevice.cpp:115
QMutex lock
Definition: torcdevice.h:66
double value
Definition: torcdevice.h:60
QString modelId
Definition: torcdevice.h:62
QString GetModelId(void)
Definition: torcdevice.cpp:156
QString userName
Definition: torcdevice.h:64
void ValidChanged(bool Valid)
double GetValue(void)
Definition: torcdevice.cpp:142
bool wasInvalid
Definition: torcdevice.h:71
bool valid
Definition: torcdevice.h:24
QString GetUniqueId(void)
Definition: torcdevice.cpp:162