sensorfw
orientation.h
Go to the documentation of this file.
1
26
27#ifndef ORIENTATION_H
28#define ORIENTATION_H
29
30#include <QDBusArgument>
32
36class Orientation : public QObject
37{
38 Q_OBJECT
39
40 Q_PROPERTY(int x READ x)
41 Q_PROPERTY(int y READ y)
42 Q_PROPERTY(int z READ z)
44
45public:
61
66
73
80
86 const OrientationData& orientationData() const { return data_; }
87
93 float x() const { return data_.x_; }
94
100 float y() const { return data_.y_; }
101
107 float z() const { return data_.z_; }
108
117
118private:
119 OrientationData data_;
120
121 friend const QDBusArgument &operator>>(const QDBusArgument &argument, Orientation& orientation);
122};
123
125
126
133inline QDBusArgument &operator<<(QDBusArgument &argument, const Orientation &orientation)
134{
135 // No floats on D-Bus: Implicit float to double conversion
136 argument.beginStructure();
137 argument << orientation.orientationData().timestamp_ << orientation.orientationData().x_ << orientation.orientationData().y_ << orientation.orientationData().z_;
138 argument.endStructure();
139 return argument;
140}
141
149inline const QDBusArgument &operator>>(const QDBusArgument &argument, Orientation &orientation)
150{
151 // No floats on D-Bus: Explicit double to float conversion
152 argument.beginStructure();
153 double x, y, z;
154 argument >> orientation.data_.timestamp_ >> x >> y >> z;
155 orientation.data_.x_ = float(x);
156 orientation.data_.y_ = float(y);
157 orientation.data_.z_ = float(z);
158 argument.endStructure();
159 return argument;
160}
161
162#endif // ORIENTATION_H
QObject facade for OrientationData.
Definition orientation.h:37
const OrientationData & orientationData() const
Accessor for contained OrientationData.
Definition orientation.h:86
Orientation(const OrientationData &orientationData)
Constructor.
float x() const
Accessor for X coordinate.
Definition orientation.h:93
DisplayOrientation
Display orientation.
Definition orientation.h:52
@ OrientationUndefined
Definition orientation.h:53
@ OrientationDisplayDown
Definition orientation.h:55
@ OrientationDisplayLeftUp
Definition orientation.h:56
@ OrientationDisplayDownwards
Definition orientation.h:59
@ OrientationDisplayRightUp
Definition orientation.h:57
@ OrientationDisplayUpwards
Definition orientation.h:58
@ OrientationDisplayUp
Definition orientation.h:54
friend const QDBusArgument & operator>>(const QDBusArgument &argument, Orientation &orientation)
Unmarshall Orientation data from the D-Bus argument.
float z() const
Accessor for Z coordinate.
Orientation(const Orientation &orientation)
Copy constructor.
float y() const
Accessor for Y coordinate.
DisplayOrientation orientation
Definition orientation.h:43
DisplayOrientation orientation() const
Accessor for display orientation.
Orientation()
Default constructor.
Definition orientation.h:65
Q_DECLARE_METATYPE(TMatrix)
const QDBusArgument & operator>>(const QDBusArgument &argument, Orientation &orientation)
Unmarshall Orientation data from the D-Bus argument.
Datatypes for different filters.
TimedXyzData OrientationData
Device orientation measurement data.