herald  2.0.0
sensor_source.h
1 // Copyright 2021 Herald Project Contributors
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #ifndef HERALD_ANALYSIS_SENSOR_SOURCE_H
6 #define HERALD_ANALYSIS_SENSOR_SOURCE_H
7 
8 #include "sampling.h"
9 #include "../datatype/rssi.h"
10 
11 namespace herald {
12 namespace analysis {
13 
14 using namespace sampling;
15 
17 template <typename RunnerT>
19 
20  // Must delete for GCC 8/9. See https://stackoverflow.com/questions/63812165/stdvariant-requires-default-constructor-in-gcc-8-and-9-and-not-require-in-gcc
21  SensorDelegateRSSISource() = delete;
22  SensorDelegateRSSISource(RunnerT& runner) : runner(runner) {};
23  ~SensorDelegateRSSISource() = default;
24 
25  void sensor(SensorType sensor, const Proximity& didMeasure, const TargetIdentifier& fromTarget, const PayloadData& withPayload) {
26  if (sensor != SensorType::BLE) return; // guard for BLE RSSI proximity only data
27  runner.template newSample<RSSI>(withPayload.hashCode(),Sample<RSSI>(Date(),RSSI(didMeasure.value)));
28  }
29 
30 private:
31  RunnerT& runner; // reference to app wide Analysis Runner instance
32 };
33 
34 }
35 }
36 
37 #endif
std::size_t hashCode() const noexcept
Returns the hash code of this instance.
Definition: data.h:462
Definition: date.h:18
Definition: payload_data.h:13
Definition: rssi.h:14
Definition: target_identifier.h:17
SensorType
Sensor type as qualifier for target identifier.
Definition: sensor_type.h:14
Acts as a non-global memory arena for arbitrary classes.
Definition: aggregates.h:15
Connects the RSSI readings from a SensorDelegate to a source for AnalysisRunner data.
Definition: sensor_source.h:18
The Sample taken from an object with ID of type SampledID.
Definition: sampling.h:28
Definition: proximity.h:17