MQTTSuite
Loading...
Searching...
No Matches
ConfigSections.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, 2026
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
12#ifndef MQTTSTORE_LIB_CONFIGSECTIONS_H
13#define MQTTSTORE_LIB_CONFIGSECTIONS_H
14
15#include <net/config/ConfigSection.h>
16
17#ifndef DOXYGEN_SHOULD_SKIP_THIS
18
19#include <cstdint>
20#include <list>
21#include <string_view>
22
23#endif
24
25namespace mqtt::mqttstore::lib {
26
27 class ConfigSession : public utils::SubCommand {
28 public:
29 constexpr static std::string_view NAME{"session"};
30 constexpr static std::string_view DESCRIPTION{"MQTT session behavior"};
31
32 ConfigSession(utils::SubCommand* parent);
33 ~ConfigSession() override;
34
35 [[nodiscard]] std::string getClientId() const;
36 [[nodiscard]] std::uint8_t getQoS() const;
37 [[nodiscard]] bool getRetainSession() const;
38 [[nodiscard]] std::uint16_t getKeepAlive() const;
39 [[nodiscard]] std::string getWillTopic() const;
40 [[nodiscard]] std::string getWillMessage() const;
41 [[nodiscard]] std::uint8_t getWillQoS() const;
42 [[nodiscard]] bool getWillRetain() const;
43 [[nodiscard]] std::string getUsername() const;
44 [[nodiscard]] std::string getPassword() const;
45 [[nodiscard]] std::string getSessionStore() const;
46
47 private:
48 CLI::Option* clientIdOpt;
49 CLI::Option* qoSOpt;
50 CLI::Option* retainSessionOpt;
51 CLI::Option* keepAliveOpt;
52 CLI::Option* willTopicOpt;
53 CLI::Option* willMessageOpt;
54 CLI::Option* willQoSOpt;
55 CLI::Option* willRetainOpt;
56 CLI::Option* usernameOpt;
57 CLI::Option* passwordOpt;
58 CLI::Option* sessionStoreOpt;
59 };
60
61 class ConfigSubscribe : public utils::SubCommand {
62 public:
63 constexpr static std::string_view NAME{"sub"};
64 constexpr static std::string_view DESCRIPTION{"MQTT subscriptions to persist"};
65
66 ConfigSubscribe(utils::SubCommand* parent);
67 ~ConfigSubscribe() override;
68
69 [[nodiscard]] std::list<std::string> getTopic() const;
70
71 private:
72 CLI::Option* topicOpt;
73 };
74
75 class ConfigDatabase : public utils::SubCommand {
76 public:
77 constexpr static std::string_view NAME{"db"};
78 constexpr static std::string_view DESCRIPTION{"MariaDB/MySQL connection"};
79
80 ConfigDatabase(utils::SubCommand* parent);
81 ~ConfigDatabase() override;
82
83 [[nodiscard]] std::string getHost() const;
84 [[nodiscard]] std::string getUsername() const;
85 [[nodiscard]] std::string getPassword() const;
86 [[nodiscard]] std::string getDatabase() const;
87 [[nodiscard]] std::uint16_t getPort() const;
88 [[nodiscard]] std::string getSocket() const;
89 [[nodiscard]] std::uint32_t getFlags() const;
90
91 private:
92 CLI::Option* hostOpt;
93 CLI::Option* usernameOpt;
94 CLI::Option* passwordOpt;
95 CLI::Option* databaseOpt;
96 CLI::Option* portOpt;
97 CLI::Option* socketOpt;
98 CLI::Option* flagsOpt;
99 };
100
101 class ConfigStorage : public utils::SubCommand {
102 public:
103 constexpr static std::string_view NAME{"storage"};
104 constexpr static std::string_view DESCRIPTION{"Generic MQTT persistence behavior"};
105
106 ConfigStorage(utils::SubCommand* parent);
107 ~ConfigStorage() override;
108
109 [[nodiscard]] std::string getRawTable() const;
110 [[nodiscard]] bool getAutoCreateRawTable() const;
111 [[nodiscard]] std::string getProjectionFile() const;
112
113 private:
114 CLI::Option* rawTableOpt;
116 CLI::Option* projectionFileOpt;
117 };
118
119} // namespace mqtt::mqttstore::lib
120
121#endif // MQTTSTORE_LIB_CONFIGSECTIONS_H
core::socket::stream::SocketContext * create(core::socket::stream::SocketConnection *socketConnection) final
static constexpr std::string_view DESCRIPTION
static constexpr std::string_view NAME
ConfigDatabase(utils::SubCommand *parent)
static constexpr std::string_view DESCRIPTION
ConfigSession(utils::SubCommand *parent)
static constexpr std::string_view NAME
ConfigStorage(utils::SubCommand *parent)
static constexpr std::string_view NAME
static constexpr std::string_view DESCRIPTION
static constexpr std::string_view DESCRIPTION
static constexpr std::string_view NAME
ConfigSubscribe(utils::SubCommand *parent)
std::list< std::string > getTopic() const
static StoragePlan fromFile(const std::string &fileName)
StorageOptions getStorageOptions(const mqtt::mqttstore::lib::ConfigStorage *configStorage)