Doxygen with github
Loading...
Searching...
No Matches
ksf::comps::ksConfigProvider Class Referenceabstract

A component that provides a set of parameters to the ksWifiConfigurator and is also responsible for handling its storage. More...

#include <ksConfigProvider.h>

+ Inheritance diagram for ksf::comps::ksConfigProvider:

Public Member Functions

virtual const size_t getInstanceType () const
 Retrieves type ID of the object.
 
virtual bool isA (const size_t id) const
 Checks whether object is of given type.
 
std::list< ksConfigParameter > & getParameters ()
 Provides const reference to the list of managed parameters.
 
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.
 
- Public Member Functions inherited from ksf::ksComponent
virtual bool init (ksApplication *app)
 Initializes component.
 
virtual bool loop (ksApplication *app)
 Handles component loop logic, called from application loop.
 
virtual bool postInit (ksApplication *app)
 Method called after component initialization, used to setup references to other components.
 
- Public Member Functions inherited from ksf::ksRtti
template<typename TType >
TType * as ()
 Tries to cast object to the type provided as a template parameter.
 
template<typename TType >
const TType * as () const
 Tries to cast object to the type provided as a template parameter (const version).
 

Static Public Member Functions

static const size_t getClassType ()
 
- Static Public Member Functions inherited from ksf::ksComponent
static const size_t getClassType ()
 

Protected Member Functions

void addNewParam (std::string id, std::string label, std::string defaultValue, int maxLength=50, EConfigParamType::Type type={})
 Defines new configutation parameter.
 
void addNewParamWithConfigDefault (ksConfig &config, std::string id, std::string label={}, int maxLength=50, EConfigParamType::Type type={})
 Defines new configuation parameter (with default value).
 

Protected Attributes

std::list< ksConfigParameterparams
 
- Protected Attributes inherited from ksf::ksComponent
ksComponentState::TYPE componentState { ksComponentState::NotInitialized }
 

Detailed Description

A component that provides a set of parameters to the ksWifiConfigurator and is also responsible for handling its storage.

In the configurator application, it should be instantiated like a typical component, and ksWifiConfigurator must be added to the component stack. In this case, it will manage the correct flow of data reading and saving.

In contrast, in a normal application, it can be created for a short period of time, usually inside the application's init method, to read the data and return the required value. Refer to the EnergySensor init method for an example. Note that the component will be destroyed upon reaching the function return. Also, note that the setupRotations method can return false in case of a problem with the value retrieval (for example, no config present yet), thus causing the application to break and triggering the app rotator to move to the next defined application, usually AP-based configurator.

Member Function Documentation

◆ addNewParam()

void ksf::comps::ksConfigProvider::addNewParam ( std::string id,
std::string label,
std::string defaultValue,
int maxLength = 50,
EConfigParamType::Type type = {} )
protected

Defines new configutation parameter.

Parameters
idUnique identificator that will be also used as property label by Device Portal.
labelParameter label.
defaultValueDefault parameter value.
maxLengthMaximum length of the value.
typeType of parameter, which tells the Device Portal which field type should be used.

Referenced by addNewParamWithConfigDefault().

◆ addNewParamWithConfigDefault()

void ksf::comps::ksConfigProvider::addNewParamWithConfigDefault ( ksConfig & config,
std::string id,
std::string label = {},
int maxLength = 50,
EConfigParamType::Type type = {} )
protected

Defines new configuation parameter (with default value).

Parameters
configksConfig reference.
idUnique identificator that will be also used as property label by Device Portal.
labelParameter label.
maxLengthMaximum length of the value.
typeType of parameter, which tells the Device Portal which field type should be used.

References addNewParam(), and ksf::ksConfig::getParam().

Referenced by ksf::comps::ksMqttConfigProvider::readParams().

◆ getInstanceType()

virtual const size_t ksf::comps::ksConfigProvider::getInstanceType ( ) const
inlinevirtual

Retrieves type ID of the object.

Returns
Object type ID.

Reimplemented from ksf::ksComponent.

Reimplemented in ksf::comps::ksMqttConfigProvider.

◆ isA()

virtual bool ksf::comps::ksConfigProvider::isA ( const size_t id) const
inlinevirtual

Checks whether object is of given type.

Parameters
idType ID to check against.
Returns
True if object is of given type, otherwise false.

Reimplemented from ksf::ksComponent.

Reimplemented in ksf::comps::ksMqttConfigProvider.

◆ readParams()

virtual void ksf::comps::ksConfigProvider::readParams ( )
pure virtual

Populates the parameter list by processing the configuration file.

Implemented in ksf::comps::ksMqttConfigProvider.

◆ saveParams()

virtual void ksf::comps::ksConfigProvider::saveParams ( )
pure virtual

Outputs the parameter list to the configuration file.

Implemented in ksf::comps::ksMqttConfigProvider.


The documentation for this class was generated from the following files: