Added db logger functions. Chnaged to newest mqtt++ version.
This commit is contained in:
@@ -1,22 +1,19 @@
|
||||
#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);
|
||||
#include "mqtt++.h"
|
||||
#include <iostream>
|
||||
|
||||
std::optional<std::string> Cache::cached_topic_value(const std::string& topic) {
|
||||
for (const auto& state : m_cache) {
|
||||
if (state.topic == topic) {
|
||||
return state.value;
|
||||
}
|
||||
}
|
||||
|
||||
return states;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
TopicState Cache::set_topic_value(const std::string& topic, const std::string& value) {
|
||||
for (auto& state : cache) {
|
||||
for (auto& state : m_cache) {
|
||||
if (state.topic == topic) {
|
||||
state.value = value;
|
||||
|
||||
@@ -24,5 +21,5 @@ TopicState Cache::set_topic_value(const std::string& topic, const std::string& v
|
||||
}
|
||||
}
|
||||
|
||||
return cache.emplace_back(topic, value);
|
||||
return m_cache.emplace_back(topic, value);
|
||||
}
|
||||
Reference in New Issue
Block a user