Doxygen with github
Loading...
Searching...
No Matches
ksConfigProvider.h
1/*
2 * Copyright (c) 2021-2023, 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 <utility>
13#include <list>
14#include "../ksComponent.h"
15
16namespace ksf
17{
18 class ksConfig;
19}
20
21namespace ksf::comps
22{
23 namespace EConfigParamType
24 {
28 enum Type
29 {
30 Text,
31 Password,
32 Number
33 };
34 };
35
40 {
41 std::string id;
42 std::string label;
43 std::string defaultValue;
44 std::string value;
45 EConfigParamType::Type type{};
46 int maxLength{};
47 };
48
62 {
63 KSF_RTTI_DECLARATIONS(ksConfigProvider, ksComponent)
64
65 protected:
66 std::list<ksConfigParameter> params;
67
77 void addNewParam(std::string id, std::string label, std::string defaultValue, int maxLength = 50, EConfigParamType::Type type = {});
78
88 void addNewParamWithConfigDefault(ksConfig& config, std::string id, std::string label = {}, int maxLength = 50, EConfigParamType::Type type = {});
89
90 public:
94 std::list<ksConfigParameter>& getParameters();
95
99 virtual void readParams() = 0;
100
104 virtual void saveParams() = 0;
105 };
106}
A component that provides a set of parameters to the ksWifiConfigurator and is also responsible for h...
Definition ksConfigProvider.h:62
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:39
void addNewParamWithConfigDefault(ksConfig &config, std::string id, std::string label={}, int maxLength=50, EConfigParamType::Type type={})
Defines new configuation parameter (with default value).
Definition ksConfigProvider.cpp:33
void addNewParam(std::string id, std::string label, std::string defaultValue, int maxLength=50, EConfigParamType::Type type={})
Defines new configutation parameter.
Definition ksConfigProvider.cpp:15
Base component class.
Definition ksComponent.h:51
Implements low-level configuration file handling.
Definition ksConfig.h:31
A structure that defines configuration parameter.
Definition ksConfigProvider.h:40