sensorfw
xyz.h
Go to the documentation of this file.
1
27#ifndef XYZ_H
28#define XYZ_H
29
30#include <math.h>
31
32#include <QDBusArgument>
34
38class XYZ : public QObject
39{
40 Q_OBJECT
41
42 Q_PROPERTY(int x READ x)
43 Q_PROPERTY(int y READ y)
44 Q_PROPERTY(int z READ z)
45
46public:
47
51 XYZ() {}
52
58 XYZ(const TimedXyzData& xyzData);
59
65 XYZ(const XYZ& xyz);
66
71 const TimedXyzData& XYZData() const { return data_; }
72
77 float x() const { return data_.x_; }
78
83 float y() const { return data_.y_; }
84
89 float z() const { return data_.z_; }
90
96 XYZ& operator=(const XYZ& origin)
97 {
98 data_ = origin.XYZData();
99 return *this;
100 }
101
102private:
103 TimedXyzData data_;
105 friend const QDBusArgument &operator>>(const QDBusArgument &argument, XYZ& xyz);
106};
107
109
110
117inline QDBusArgument &operator<<(QDBusArgument &argument, const XYZ &xyz)
118{
119 // No floats on D-Bus: Implicit float to double conversion
120 argument.beginStructure();
121 argument << xyz.XYZData().timestamp_ << xyz.XYZData().x_ << xyz.XYZData().y_ << xyz.XYZData().z_;
122 argument.endStructure();
123 return argument;
124}
125
133inline const QDBusArgument &operator>>(const QDBusArgument &argument, XYZ &xyz)
134{
135 // No floats on D-Bus: Explicit double to float conversion
136 argument.beginStructure();
137 double x, y, z;
138 argument >> xyz.data_.timestamp_ >> x >> y >> z;
139 xyz.data_.x_ = float(x);
140 xyz.data_.y_ = float(y);
141 xyz.data_.z_ = float(z);
142 argument.endStructure();
143 return argument;
144}
145
146#endif // XYZ_H
quint64 timestamp_
monotonic time (microsec)
Definition: genericdata.h:46
Class for vector type measurement data (timestamp, x, y, z).
Definition: genericdata.h:53
float z_
Z value.
Definition: genericdata.h:72
float y_
Y value.
Definition: genericdata.h:71
float x_
X value.
Definition: genericdata.h:70
QObject facade for XYZData.
Definition: xyz.h:39
int y
Definition: xyz.h:43
float y() const
Returns the value for Y.
Definition: xyz.h:83
float x() const
Returns the value for X.
Definition: xyz.h:77
const TimedXyzData & XYZData() const
Returns the contained XYZData.
Definition: xyz.h:71
XYZ(const XYZ &xyz)
Copy constructor.
int x
Definition: xyz.h:42
XYZ(const TimedXyzData &xyzData)
Copy constructor.
int z
Definition: xyz.h:44
XYZ & operator=(const XYZ &origin)
Assignment operator.
Definition: xyz.h:96
friend const QDBusArgument & operator>>(const QDBusArgument &argument, XYZ &xyz)
Unmarshall XYZ data from the D-Bus argument.
Definition: xyz.h:133
XYZ()
Default constructor.
Definition: xyz.h:51
float z() const
Returns the value for Z.
Definition: xyz.h:89
Q_DECLARE_METATYPE(TMatrix)
Datatypes for different filters.
const QDBusArgument & operator>>(const QDBusArgument &argument, XYZ &xyz)
Unmarshall XYZ data from the D-Bus argument.
Definition: xyz.h:133