This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
YASMIN/sensors/Sensor.h
kazu 075d8bb633 a lot!!! of changes
added main menu
added debug display
many debug widgets for plotting live data
worked on android live sensors
added offline-data sensor feeding
some dummy data sensors
worked on the map display
added ui debug for grid-points, particles and weights
added a cool dude to display the estimation
added real filtering based on the Indoor components
c++11 fixes for android compilation
online and offline filtering support
new resampling technique for testing
map loading via dialog
2016-09-16 19:30:04 +02:00

62 lines
1.2 KiB
C++

#ifndef SENSOR_H
#define SENSOR_H
#include <vector>
#include <QObject>
#include <Indoor/data/Timestamp.h>
template <typename T> class Sensor;
/** listen for sensor events */
template <typename T> class SensorListener {
public:
/** incoming sensor data */
virtual void onSensorData(Sensor<T>* sensor, const Timestamp ts, const T& data) = 0;
};
/** base-class for all sensors */
template <typename T> class Sensor {
private:
std::vector<SensorListener<T>*> listeners;
public:
/** start this sensor */
virtual void start() = 0;
/** stop this sensor */
virtual void stop() = 0;
/** add the given listener to the sensor */
void addListener(SensorListener<T>* l) {
listeners.push_back(l);
}
protected:
/** inform all attached listeners */
void informListeners(const T& sensorData) {
const Timestamp now = Timestamp::fromRunningTime();
for (SensorListener<T>* l : listeners) {
l->onSensorData(this, now, sensorData);
}
}
/** inform all attached listeners. call this if you know the timestamp */
void informListeners(const Timestamp ts, const T& sensorData) {
for (SensorListener<T>* l : listeners) {
l->onSensorData(this, ts, sensorData);
}
}
};
#endif // SENSOR_H