Doxygen with github
Loading...
Searching...
No Matches
ksConfigProvider.h
1/*
2 * Copyright (c) 2021-2025, Krzysztof Strehlau
3 *
4 * This file is a part of the ksIotFramework library.
5 * All licensing information can be found inside LICENSE.md file.
6 *
7 * https://github.com/cziter15/ksIotFrameworkLib/blob/master/LICENSE
8 */
9
10#pragma once
11
12#include <string>
13#include <utility>
14#include <list>
15
16#include "../ksComponent.h"
17
18namespace ksf::misc
19{
20 class ksConfig;
21}
22
23namespace ksf::comps
24{
25 namespace EConfigParamType
26 {
30 enum Type
31 {
32 Text,
33 Password,
34 Number,
35 Checkbox
36 };
37 };
38
43 {
44 std::string id;
45 std::string label;
46 std::string value;
47 EConfigParamType::Type type{};
48 int maxLength{};
49 };
50
64 {
65 KSF_RTTI_DECLARATIONS(ksConfigProvider, ksComponent)
66
67 protected:
68 std::list<ksConfigParameter> params;
69
79 void addNewParam(std::string id, std::string label, std::string defaultValue, int maxLength = 50, EConfigParamType::Type type = {});
80
90 void addNewParamWithConfigDefault(misc::ksConfig& config, std::string id, std::string label = {}, int maxLength = 50, EConfigParamType::Type type = {});
91
92 public:
96 std::list<ksConfigParameter>& getParameters();
97
101 virtual void readParams() = 0;
102
106 virtual void saveParams() = 0;
107 };
108}
A component responsible for providing a set of parameters to ksWifiConfigurator and managing its stor...
Definition ksConfigProvider.h:64
virtual void readParams()=0
Populates the parameter list by processing the configuration file.
virtual void saveParams()=0
Outputs the parameter list to the configuration file.
std::list< ksConfigParameter > & getParameters()
Provides const reference to the list of managed parameters.
Definition ksConfigProvider.cpp:30
void addNewParam(std::string id, std::string label, std::string defaultValue, int maxLength=50, EConfigParamType::Type type={})
Defines new configutation parameter.
Definition ksConfigProvider.cpp:16
void addNewParamWithConfigDefault(misc::ksConfig &config, std::string id, std::string label={}, int maxLength=50, EConfigParamType::Type type={})
Defines new configuation parameter (with default value).
Definition ksConfigProvider.cpp:24
std::list< ksConfigParameter > params
List of configuration parameters.
Definition ksConfigProvider.h:68
Base component class.
Definition ksComponent.h:36
Implements low-level configuration file handling.
Definition ksConfig.h:31
A structure that defines configuration parameter.
Definition ksConfigProvider.h:43
std::string label
Value label.
Definition ksConfigProvider.h:45
EConfigParamType::Type type
Parameter type.
Definition ksConfigProvider.h:47
int maxLength
Maximum length of the parameter value.
Definition ksConfigProvider.h:48
std::string value
Default parameter value.
Definition ksConfigProvider.h:46
std::string id
Unique parameter identifier.
Definition ksConfigProvider.h:44