sensorfw: datatypes/xyz.h Source File

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>
33#include <datatypes/orientationdata.h>
34
38 class 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
108 Q_DECLARE_METATYPE( XYZ )
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
133 inline 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
TimedData::timestamp_
quint64 timestamp_
monotonic time (microsec)
Definition genericdata.h:46
TimedXyzData
Class for vector type measurement data (timestamp, x, y, z).
Definition genericdata.h:53
TimedXyzData::z_
float z_
Z value.
Definition genericdata.h:72
TimedXyzData::y_
float y_
Y value.
Definition genericdata.h:71
TimedXyzData::x_
float x_
X value.
Definition genericdata.h:70
XYZ
QObject facade for XYZData.
Definition xyz.h:39
XYZ::y
int y
Definition xyz.h:43
XYZ::y
float y() const
Returns the value for Y.
Definition xyz.h:83
XYZ::x
float x() const
Returns the value for X.
Definition xyz.h:77
XYZ::XYZData
const TimedXyzData & XYZData() const
Returns the contained XYZData.
Definition xyz.h:71
XYZ::XYZ
XYZ(const XYZ &xyz)
Copy constructor.
XYZ::x
int x
Definition xyz.h:42
XYZ::XYZ
XYZ(const TimedXyzData &xyzData)
Copy constructor.
XYZ::z
int z
Definition xyz.h:44
XYZ::operator=
XYZ & operator=(const XYZ &origin)
Assignment operator.
Definition xyz.h:96
XYZ::operator>>
friend const QDBusArgument & operator>>(const QDBusArgument &argument, XYZ &xyz)
Unmarshall XYZ data from the D-Bus argument.
Definition xyz.h:133
XYZ::z
float z() const
Returns the value for Z.
Definition xyz.h:89
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(TMatrix)
orientationdata.h
Datatypes for different filters.
operator>>
const QDBusArgument & operator>>(const QDBusArgument &argument, XYZ &xyz)
Unmarshall XYZ data from the D-Bus argument.
Definition xyz.h:133