sensorfw
datatypes/orientation.h
Go to the documentation of this file.
00001 
00027 #ifndef ORIENTATION_H
00028 #define ORIENTATION_H
00029 
00030 #include <QDBusArgument>
00031 #include <datatypes/orientationdata.h>
00032 
00036 class Orientation : public QObject
00037 {
00038     Q_OBJECT
00039 
00040     Q_PROPERTY(int x READ x)
00041     Q_PROPERTY(int y READ y)
00042     Q_PROPERTY(int z READ z)
00043     Q_PROPERTY(DisplayOrientation orientation READ orientation)
00044 
00045 public:
00051     enum DisplayOrientation
00052     {
00053         OrientationUndefined = 0,
00054         OrientationDisplayUp,
00055         OrientationDisplayDown,
00056         OrientationDisplayLeftUp,
00057         OrientationDisplayRightUp,
00058         OrientationDisplayUpwards,
00059         OrientationDisplayDownwards
00060     };
00061 
00065     Orientation() {}
00066 
00072     Orientation(const OrientationData& orientationData);
00073 
00079     Orientation(const Orientation& orientation);
00080 
00086     const OrientationData& orientationData() const { return data_; }
00087 
00093     int x() const { return data_.x_; }
00094 
00100     int y() const { return data_.y_; }
00101 
00107     int z() const { return data_.z_; }
00108 
00116     DisplayOrientation orientation() const { return OrientationUndefined; }
00117 
00118 private:
00119     OrientationData data_; 
00121     friend const QDBusArgument &operator>>(const QDBusArgument &argument, Orientation& orientation);
00122 };
00123 
00124 Q_DECLARE_METATYPE( Orientation )
00125 
00126 
00133 inline QDBusArgument &operator<<(QDBusArgument &argument, const Orientation &orientation)
00134 {
00135     argument.beginStructure();
00136     argument << orientation.orientationData().timestamp_ << orientation.orientationData().x_ << orientation.orientationData().y_ << orientation.orientationData().z_;
00137     argument.endStructure();
00138     return argument;
00139 }
00140 
00148 inline const QDBusArgument &operator>>(const QDBusArgument &argument, Orientation &orientation)
00149 {
00150     argument.beginStructure();
00151     argument >> orientation.data_.timestamp_ >> orientation.data_.x_ >> orientation.data_.y_ >> orientation.data_.z_;
00152     argument.endStructure();
00153     return argument;
00154 }
00155 
00156 #endif // ORIENTATION_H