Inital commit. Meisten features sind implementiert und müssen getestet werden

This commit is contained in:
2020-07-15 10:49:03 +02:00
commit e1dcd55757
12 changed files with 632 additions and 0 deletions

28
src/Cache.cpp Normal file
View File

@@ -0,0 +1,28 @@
#include "Cache.h"
#include <algorithm>
std::vector<TopicState> Cache::topic_states(std::vector<std::string>& topics) {
std::vector<TopicState> states;
for (const auto& topic : topics) {
auto hit = std::find_if(cache.begin(), cache.end(), [&](TopicState& cache_state) {
return cache_state.topic == topic;
});
if (hit != cache.end()) {
states.push_back(*hit);
}
}
return states;
}
TopicState Cache::set_topic_value(const std::string& topic, const std::string& value) {
for (auto& state : cache) {
if (state.topic == topic) {
state.value = value;
return state;
}
}
return cache.emplace_back(topic, value);
}