SensESP 3.0.0-beta.6
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
sensesp::ConfigItemBase Class Referenceabstract

#include <sensesp/ui/config_item.h>

Inheritance diagram for sensesp::ConfigItemBase:
[legend]

Public Member Functions

const String & get_title () const
 
ConfigItemBaseset_title (const String &title)
 
const String & get_description () const
 
ConfigItemBaseset_description (const String &description)
 Set the description of the ConfigItemT.
 
virtual const String get_config_schema () const
 
int get_sort_order () const
 
ConfigItemBaseset_sort_order (int sort_order)
 
bool requires_restart () const
 Return true if the ConfigItemT requires restart after saving for the changes to take effect.
 
ConfigItemBaseset_requires_restart (bool requires_restart)
 Set the requires_restart flag.
 
virtual bool load ()=0
 
virtual bool refresh ()=0
 
virtual bool save ()=0
 
virtual bool to_json (JsonObject &config) const =0
 
virtual bool from_json (const JsonObject &config) const =0
 
virtual const String & get_config_path () const =0
 

Static Public Member Functions

static std::shared_ptr< ConfigItemBaseget_config_item (const String key)
 Get a single ConfigItemT by key.
 
static std::unique_ptr< std::vector< std::shared_ptr< ConfigItemBase > > > get_config_items ()
 Get all config items as a vector.
 

Protected Member Functions

virtual const String get_default_config_schema () const =0
 

Protected Attributes

String config_path_ = ""
 The path of the ConfigItemT. This is used to identify the ConfigItemT.
 
String config_schema_ = ""
 
String title_ = ""
 Title of the ConfigItemT to be displayed on the web UI.
 
String description_ = ""
 Description of the ConfigItemT to be displayed on the web UI.
 
int sort_order_ = 1000
 The sort order of ConfigItemT. Lower numbers have precedence.
 
bool requires_restart_ = false
 

Static Protected Attributes

static std::map< String, std::shared_ptr< ConfigItemBase > > config_items_
 

Friends

template<typename T >
std::shared_ptr< ConfigItemT< T > > ConfigItem (std::shared_ptr< T > config_object)
 Register a ConfigItemT with the ConfigItemBase.
 

Detailed Description

Definition at line 70 of file config_item.h.

Member Function Documentation

◆ from_json()

virtual bool sensesp::ConfigItemBase::from_json ( const JsonObject & config) const
pure virtual

Implemented in sensesp::ConfigItemT< T >.

◆ get_config_item()

static std::shared_ptr< ConfigItemBase > sensesp::ConfigItemBase::get_config_item ( const String key)
inlinestatic

Get a single ConfigItemT by key.

Return nullptr if not found.

Definition at line 135 of file config_item.h.

Here is the caller graph for this function:

◆ get_config_items()

static std::unique_ptr< std::vector< std::shared_ptr< ConfigItemBase > > > sensesp::ConfigItemBase::get_config_items ( )
inlinestatic

Get all config items as a vector.

Definition at line 148 of file config_item.h.

Here is the caller graph for this function:

◆ get_config_path()

virtual const String & sensesp::ConfigItemBase::get_config_path ( ) const
pure virtual

Implemented in sensesp::ConfigItemT< T >.

◆ get_config_schema()

virtual const String sensesp::ConfigItemBase::get_config_schema ( ) const
inlinevirtual

Returns a configuration schema that specifies the key/value pairs that can be expected when calling get_configuration(), or are expected by set_configuration(). The schema will be in JSON Schema format

See also
https://json-schema.org

Definition at line 100 of file config_item.h.

Here is the call graph for this function:

◆ get_default_config_schema()

virtual const String sensesp::ConfigItemBase::get_default_config_schema ( ) const
protectedpure virtual

Implemented in sensesp::ConfigItemT< T >.

Here is the caller graph for this function:

◆ get_description()

const String & sensesp::ConfigItemBase::get_description ( ) const
inline

Returns a configuration description that is visible in the web UI. You can use HTML tags to make description more readable.

Definition at line 83 of file config_item.h.

◆ get_sort_order()

int sensesp::ConfigItemBase::get_sort_order ( ) const
inline

Definition at line 107 of file config_item.h.

◆ get_title()

const String & sensesp::ConfigItemBase::get_title ( ) const
inline

Definition at line 73 of file config_item.h.

◆ load()

virtual bool sensesp::ConfigItemBase::load ( )
pure virtual

Implemented in sensesp::ConfigItemT< T >.

◆ refresh()

virtual bool sensesp::ConfigItemBase::refresh ( )
pure virtual

Implemented in sensesp::ConfigItemT< T >.

◆ requires_restart()

bool sensesp::ConfigItemBase::requires_restart ( ) const
inline

Return true if the ConfigItemT requires restart after saving for the changes to take effect.

Definition at line 118 of file config_item.h.

Here is the caller graph for this function:

◆ save()

virtual bool sensesp::ConfigItemBase::save ( )
pure virtual

Implemented in sensesp::ConfigItemT< T >.

◆ set_description()

ConfigItemBase * sensesp::ConfigItemBase::set_description ( const String & description)
inline

Set the description of the ConfigItemT.

Definition at line 88 of file config_item.h.

Here is the caller graph for this function:

◆ set_requires_restart()

ConfigItemBase * sensesp::ConfigItemBase::set_requires_restart ( bool requires_restart)
inline

Set the requires_restart flag.

Parameters
requires_restart

Definition at line 125 of file config_item.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_sort_order()

ConfigItemBase * sensesp::ConfigItemBase::set_sort_order ( int sort_order)
inline

Definition at line 109 of file config_item.h.

Here is the caller graph for this function:

◆ set_title()

ConfigItemBase * sensesp::ConfigItemBase::set_title ( const String & title)
inline

Definition at line 74 of file config_item.h.

Here is the caller graph for this function:

◆ to_json()

virtual bool sensesp::ConfigItemBase::to_json ( JsonObject & config) const
pure virtual

Implemented in sensesp::ConfigItemT< T >.

Friends And Related Symbol Documentation

◆ ConfigItem

template<typename T >
std::shared_ptr< ConfigItemT< T > > ConfigItem ( std::shared_ptr< T > config_object)
friend

Register a ConfigItemT with the ConfigItemBase.

Note, this function only exists to avoid having to provide the template argument when creating a ConfigItemT. It should be possible to remove it once C++17 is supported.

Template Parameters
T
Parameters
config_object
title
description
sort_order
Returns
T*

Definition at line 289 of file config_item.h.

Member Data Documentation

◆ config_items_

std::map< String, std::shared_ptr< ConfigItemBase > > sensesp::ConfigItemBase::config_items_
staticprotected

Definition at line 172 of file config_item.h.

◆ config_path_

String sensesp::ConfigItemBase::config_path_ = ""
protected

The path of the ConfigItemT. This is used to identify the ConfigItemT.

Definition at line 175 of file config_item.h.

◆ config_schema_

String sensesp::ConfigItemBase::config_schema_ = ""
protected

The configuration schema of the ConfigItemT in serialized JSON Schema format.

Definition at line 178 of file config_item.h.

◆ description_

String sensesp::ConfigItemBase::description_ = ""
protected

Description of the ConfigItemT to be displayed on the web UI.

Definition at line 182 of file config_item.h.

◆ requires_restart_

bool sensesp::ConfigItemBase::requires_restart_ = false
protected

Flag to indicate whether the ConfigItemT setting requires a restart to take effect after saving the configuration.

Definition at line 187 of file config_item.h.

◆ sort_order_

int sensesp::ConfigItemBase::sort_order_ = 1000
protected

The sort order of ConfigItemT. Lower numbers have precedence.

Definition at line 184 of file config_item.h.

◆ title_

String sensesp::ConfigItemBase::title_ = ""
protected

Title of the ConfigItemT to be displayed on the web UI.

Definition at line 180 of file config_item.h.


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