MQTTSuite
Loading...
Searching...
No Matches
Storage.h
Go to the documentation of this file.
1/*
2 * MQTTSuite - A lightweight MQTT Integration System
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2022, 2023, 2024, 2025
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation, either version 3 of the License, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20/*
21 * MIT License
22 *
23 * Permission is hereby granted, free of charge, to any person obtaining a copy
24 * of this software and associated documentation files (the "Software"), to deal
25 * in the Software without restriction, including without limitation the rights
26 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
27 * copies of the Software, and to permit persons to whom the Software is
28 * furnished to do so, subject to the following conditions:
29 *
30 * The above copyright notice and this permission notice shall be included in
31 * all copies or substantial portions of the Software.
32 *
33 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
39 * THE SOFTWARE.
40 */
41
42#ifndef MQTT_LIB_PLUGINS_STORAGE_PLUGIN_STORAGE_H
43#define MQTT_LIB_PLUGINS_STORAGE_PLUGIN_STORAGE_H
44
45#ifdef __GNUC__
46#pragma GCC diagnostic push
47#ifdef __has_warning
48#if __has_warning("-Wcovered-switch-default")
49#pragma GCC diagnostic ignored "-Wcovered-switch-default"
50#endif
51#if __has_warning("-Wnrvo")
52#pragma GCC diagnostic ignored "-Wnrvo"
53#endif
54#endif
55#endif
56#include "lib/inja.hpp"
57#ifdef __GNUC_
58#pragma GCC diagnostic pop
59#endif
60
61#ifndef DOXYGEN_SHOULD_SKIP_THIS
62
63#include <map>
64#include <string>
65
66#endif // DOXYGEN_SHOULD_SKIP_THIS
67
68namespace mqtt::lib::plugins::storage_plugin {
69
70 class Storage {
71 public:
72 private:
73 Storage() = default;
74
75 public:
76 Storage(const Storage&) = delete;
77
78 Storage& operator=(const Storage&) = delete;
79
80 static Storage& instance();
81
82 static void store(const inja::Arguments& args);
83
84 static const std::string& recall(const inja::Arguments& args);
85 static int recall_as_int(const inja::Arguments& args);
86 static double recall_as_float(const inja::Arguments& args);
87
88 static bool is_empty(const inja::Arguments& args);
89
90 static bool exists(const inja::Arguments& args);
91
92 ~Storage() = default;
93
94 private:
95 std::map<std::string, std::string> storage;
96 };
97
98} // namespace mqtt::lib::plugins::storage_plugin
99
100#endif // MQTT_LIB_PLUGINS_STORAGE_PLUGIN_STORAGE_H
std::vector< mqtt::lib::Function > functions
Definition Double.cpp:80
std::vector< mqtt::lib::VoidFunction > voidFunctions
static void store(const inja::Arguments &args)
Definition Storage.cpp:63
static double recall_as_float(const inja::Arguments &args)
Definition Storage.cpp:85
static const std::string & recall(const inja::Arguments &args)
Definition Storage.cpp:67
static bool exists(const inja::Arguments &args)
Definition Storage.cpp:109
static bool is_empty(const inja::Arguments &args)
Definition Storage.cpp:99
Storage & operator=(const Storage &)=delete
static int recall_as_int(const inja::Arguments &args)
Definition Storage.cpp:71
std::map< std::string, std::string > storage
Definition Storage.h:95
std::vector< const nlohmann::json * > Arguments