Doxygen with github
Loading...
Searching...
No Matches
ksConfigProvider.h
1/*
2 * Copyright (c) 2020-2025, Krzysztof Strehlau
3 *
4 * This file is a part of the ksIotFrameworkLib IoT 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#include "../ksComponent.h"
16
17namespace ksf::misc
18{
19 class ksConfig;
20}
21
22namespace ksf::comps
23{
24 namespace EConfigParamType
25 {
29 enum Type
30 {
31 Text,
32 Password,
33 Number,
34 Checkbox
35 };
36 };
37
42 {
43 std::string id;
44 std::string label;
45 std::string value;
46 EConfigParamType::Type type{};
47 int maxLength{};
48 };
49
63 {
64 KSF_RTTI_DECLARATIONS(ksConfigProvider, ksComponent)
65
66 protected:
67 std::list<ksConfigParameter> params;
68
78 void addNewParam(std::string id, std::string label, std::string defaultValue, int maxLength = 50, EConfigParamType::Type type = {});
79
89 void addNewParamWithConfigDefault(misc::ksConfig& config, std::string id, std::string label = {}, int maxLength = 50, EConfigParamType::Type type = {});
90
91 public:
95 std::list<ksConfigParameter>& getParameters();
96
100 virtual void readParams() = 0;
101
105 virtual void saveParams() = 0;
106 };
107}
A component responsible for providing a set of parameters to ksWifiConfigurator and managing its stor...
Definition ksConfigProvider.h:63
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:67
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:42
std::string label
Value label.
Definition ksConfigProvider.h:44
EConfigParamType::Type type
Parameter type.
Definition ksConfigProvider.h:46
int maxLength
Maximum length of the parameter value.
Definition ksConfigProvider.h:47
std::string value
Default parameter value.
Definition ksConfigProvider.h:45
std::string id
Unique parameter identifier.
Definition ksConfigProvider.h:43