SensESP 3.4.1-alpha
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

virtual ~ConfigItemBase ()=default
 
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.
 
static void clear_registry ()
 Empty the config item registry.
 

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 >)
 Register a ConfigItemT with the ConfigItemBase.
 

Detailed Description

Definition at line 70 of file config_item.h.

Constructor & Destructor Documentation

◆ ~ConfigItemBase()

virtual sensesp::ConfigItemBase::~ConfigItemBase ( )
virtualdefault

Member Function Documentation

◆ clear_registry()

void sensesp::ConfigItemBase::clear_registry ( )
static

Empty the config item registry.

Releases the registry's shared_ptr references. Intended for clean app restart and test isolation; not for normal runtime use.

Unlike the raw-pointer registries (SKEmitter, Transform, StatusPageItem), this registry owns its entries via shared_ptr, so there is no unregister-on-destruction: clearing the map releases the objects. A self-erasing destructor here would be re-entrant and is deliberately absent.

Definition at line 7 of file config_item.cpp.

Here is the caller graph for this function:

◆ 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 137 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 150 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 102 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 85 of file config_item.h.

◆ get_sort_order()

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

Definition at line 109 of file config_item.h.

◆ get_title()

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

Definition at line 75 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 120 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 90 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 127 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 111 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 76 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 305 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 188 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 191 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 194 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 198 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 203 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 200 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 196 of file config_item.h.


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