AbstractSensorService.hpp Example File
bpstoqml/src/AbstractSensorService.hpp
#ifndef ABSTRACTSENSORSERVICE_H_
#define ABSTRACTSENSORSERVICE_H_
#include "BlackBerryPlatformService.hpp"
#include <bps/sensor.h>
namespace bb {
namespace cascades {
namespace bps {
class AbstractSensorService: public BlackBerryPlatformService {
Q_OBJECT
Q_ENUMS(SensorAccuracy)
public:
enum SensorAccuracy {
AccuracyUnreliable = 0,
AccuracyLow = 1,
AccuracyMedium = 2,
AccuracyHigh = 3
};
AbstractSensorService(sensor_type_t sensorType, QObject *parent = 0);
virtual ~AbstractSensorService();
Q_INVOKABLE bool isSupported();
Q_INVOKABLE void setCalibrationEnabled(bool calibrationEnabled);
Q_INVOKABLE void setEnableSkipDuplicates(bool enableSkipDuplicates);
Q_INVOKABLE void setEventRate(unsigned int rate);
Q_INVOKABLE void setBackgroundEnabled(bool backgroundEnabled);
virtual void requestEvents();
virtual int eventDomain();
protected:
SensorAccuracy getAccuracy(bps_event_t *event);
unsigned long long getTimestamp(bps_event_t *event);
private:
sensor_type_t m_sensorType;
bool m_calibrationEnabled;
bool m_calibrationEnabledSet;
bool m_enableSkipDuplicates;
bool m_enableSkipDuplicatesSet;
unsigned int m_rate;
bool m_rateSet;
bool m_backgroundEnabled;
bool m_backgroundEnabledSet;
};
}
}
}
Q_DECLARE_METATYPE( bb::cascades::bps::AbstractSensorService::SensorAccuracy );
QML_DECLARE_TYPE(bb::cascades::bps::AbstractSensorService)
#endif /* ABSTRACTSENSORSERVICE_H_ */