sensorfw: datatypes/proximity.h Source File

sensorfw

proximity.h
Go to the documentation of this file.
1
26#ifndef PROXIMITY_H
27#define PROXIMITY_H
28
29#include <QDBusArgument>
30
31#include <datatypes/unsigned.h>
32#include <datatypes/orientationdata.h>
33
37 class Proximity : public Unsigned
38{
39 Q_OBJECT
40
41 Q_PROPERTY(int reflectance READ reflectance)
42 Q_PROPERTY(int withinProximity READ withinProximity)
43
44public:
45
49 Proximity() {}
50
56 Proximity(const ProximityData& data) :
57 Unsigned(TimedUnsigned(data.timestamp_, data.withinProximity_)),
58 data_(data.timestamp_, data.value_, data.withinProximity_)
59 {}
60
66 Proximity(const Proximity& data) :
67 Unsigned(data.UnsignedData()), data_(data.proximityData().timestamp_, data.proximityData().value_, data.proximityData().withinProximity_)
68 {}
69
74 const ProximityData& proximityData() const { return data_; }
75
81 bool withinProximity() const { return data_.withinProximity_; }
82
88 int reflectance() const { return data_.value_; }
89
95 Proximity& operator=(const Proximity& origin)
96 {
97 data_ = origin.proximityData();
98 return *this;
99 }
100
107 bool operator==(const Proximity& right) const
108 {
109 ProximityData rdata = right.proximityData();
110 return (data_.value_ == rdata.value_ &&
111 data_.withinProximity_ == rdata.withinProximity_ &&
112 data_.timestamp_ == rdata.timestamp_);
113 }
114
115private:
116 ProximityData data_;
118 friend const QDBusArgument &operator>>(const QDBusArgument &argument, Proximity& data);
119};
120
121 Q_DECLARE_METATYPE( Proximity )
122
123
130inline QDBusArgument &operator<<(QDBusArgument &argument, const Proximity &data)
131{
132 argument.beginStructure();
133 argument << data.proximityData().timestamp_ << data.proximityData().value_ << data.proximityData().withinProximity_;
134 argument.endStructure();
135 return argument;
136}
137
145 inline const QDBusArgument &operator>>(const QDBusArgument &argument, Proximity &data)
146{
147 argument.beginStructure();
148 argument >> data.data_.timestamp_ >> data.data_.value_ >> data.data_.withinProximity_;
149 argument.endStructure();
150 return argument;
151}
152
153#endif // PROXIMITY_H
ProximityData
Datatype for proximity measurements.
Definition: orientationdata.h:151
ProximityData::withinProximity_
bool withinProximity_
is an object within proximity or not
Definition: orientationdata.h:168
Proximity
QObject facade for ProximityData.
Definition: proximity.h:38
Proximity::reflectance
int reflectance() const
Accessor for raw reflectance reading.
Definition: proximity.h:88
Proximity::Proximity
Proximity()
Default constructor.
Definition: proximity.h:49
Proximity::operator>>
friend const QDBusArgument & operator>>(const QDBusArgument &argument, Proximity &data)
Unmarshall Proximity data from the D-Bus argument.
Definition: proximity.h:145
Proximity::reflectance
int reflectance
Definition: proximity.h:41
Proximity::Proximity
Proximity(const ProximityData &data)
Constructor.
Definition: proximity.h:56
Proximity::operator=
Proximity & operator=(const Proximity &origin)
Assignment operator.
Definition: proximity.h:95
Proximity::operator==
bool operator==(const Proximity &right) const
Comparison operator.
Definition: proximity.h:107
Proximity::withinProximity
bool withinProximity() const
Accessor for proximity status.
Definition: proximity.h:81
Proximity::proximityData
const ProximityData & proximityData() const
Returns the contained ProximityData.
Definition: proximity.h:74
Proximity::withinProximity
int withinProximity
Definition: proximity.h:42
Proximity::Proximity
Proximity(const Proximity &data)
Copy constructor.
Definition: proximity.h:66
TimedData::timestamp_
quint64 timestamp_
monotonic time (microsec)
Definition: genericdata.h:46
TimedUnsigned
Datatype for unsigned integer value with timestamp.
Definition: timedunsigned.h:34
TimedUnsigned::value_
unsigned value_
Measurement value.
Definition: timedunsigned.h:49
Unsigned
QObject facae for TimedUnsigned.
Definition: unsigned.h:37
Unsigned::UnsignedData
const TimedUnsigned & UnsignedData() const
Returns the contained TimedUnsigned.
Definition: unsigned.h:66
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(TMatrix)
orientationdata.h
Datatypes for different filters.
operator>>
const QDBusArgument & operator>>(const QDBusArgument &argument, Proximity &data)
Unmarshall Proximity data from the D-Bus argument.
Definition: proximity.h:145
unsigned.h
QObject based datatype for TimedUnsigned.