Skip to content
Snippets Groups Projects
Commit 8a8199b6 authored by fxk8y's avatar fxk8y :spider:
Browse files

going functional

parent d2b5f3c4
No related branches found
No related tags found
2 merge requests!8Updating bme280-qthing,!5Measured: A measuring daemon
......@@ -8,10 +8,9 @@ typedef struct {
std::string name;
std::string type;
std::string unit;
qthing::measured::Producer producer;
} sensor_t;
qthing::measured::sensor_t sensor;
} sensor_data_t;
typedef qthing::measured::Consumer backend_t;
// TODO: declare backend/sensor vectors!
......@@ -30,12 +29,12 @@ static void start_measured() {
}
}
void registerSensor(std::string name, std::string type, std::string unit, qthing::measured::Producer p) {
void registerSensor(std::string name, std::string type, std::string unit, qthing::measured::sensor_t sensor) {
// do stuff!
start_measured();
}
void registerBackend(qthing::measured::Consumer c) {
void registerBackend(qthing::measured::backend_t backend) {
// do stuff!
start_measured();
}
#pragma once
#include <string>
#include <functional>
namespace qthing {
namespace measured {
class Producer {
public:
float getValue();
};
typedef std::function<float()> sensor_t;
typedef std::function<void(std::string name, std::string type, std::string unit, float value)> backend_t; // name, type, unit, value
class Consumer {
public:
void processValue(std::string name, std::string type, std::string unit, float value);
};
void registerBackend(Consumer c);
void registerSensor(std::string name, std::string type, std::string unit, Producer p);
void registerBackend(sensor_t sensor);
void registerSensor(std::string name, std::string type, std::string unit, backend_t);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment