NetBurner 3.5.0
PDF Version
 
config_obj Class Reference

Base class used to create configuration objects. More...

#include <config_obj.h>

Inherits config_leaf.

Inherited by AcmeObject, CertData, ControlSet, EmailNotify, I4Record, I6Record, InterfaceBlock, LLDPEntity, MonitorRecord, NV_OneI2CPortSetting, NV_OnePortSetting, NV_SettingsStruct, OneConfigRecord, PIDSet, SysRecord, TempRange, TempRange, TempRange, ThermoGroup, Thermostat1, cfg_class_slot, cfg_class_slots, config_chooser, config_preserver_obj, config_uart, detached_root_obj, empty_config_obj, and root_obj.

Public Member Functions

 config_obj (config_obj &owner, const char *name, const char *desc)
 Object constructor with the parent/owner leaf parameter.
 
 config_obj (const char *name, const char *desc)
 Object constructor.
 
virtual void GetTextValue (NBString &s)
 Get the object value as a text string to the specified NBString object.
 
virtual void GetTypeValue (NBString &s)
 Assigns the object type value to the specified NBString object.
 

Detailed Description

Base class used to create configuration objects.

Base that can be used to create your own custom configuration objects in a JSON compatible format. The object can hold any number of JSON compatible types: integer, boolean, null, string, object or array.

A config_obj can hold multiple values in a JSON object. A config_value holds only a single JSON value.

See also
config_value

The example below demonstrates how to create a thermostat object with a temperature range derived from a config_obj:

Note
Please check the Configuration Class example in the \nburn\examples folder for the latest code updates.
The use of config objects should be done at a global scope. They can contain any number of members,
which should be given a default value and a name used as an identifier. The name value for each
member variable should be unique, otherwise it can lead to issues inside the config tree.
class TempRange : public config_obj
{
public:
// Class variables
config_int m_maxTemp{100, "MaxTemp"};
config_int m_setTemp{30, "SetTemp"};
config_int m_minTemp{10, "MinTemp"};
ConfigEndMarker; // No new data members below this line
// Class constructors
TempRange(const char *name, const char *desc = nullptr) : config_obj(name, desc){};
TempRange(config_obj &owner, const char *name, const char *desc = nullptr) : config_obj(owner, name, desc){};
};
class Thermostat : public TempRange
{
public:
config_int m_tempRec1{101, "TempRecord_1"};
config_int m_tempRec2{102, "TempRecord_2"};
config_bool m_active{true, "Active"};
config_string m_location{"Warehouse 1", "Thermostat Location"};
config_chooser m_tempScale{"Temperature Scale", "Fahrenheit", "Fahrenheit,Celsius,Kelvin"};
ConfigEndMarker; // No new data members below this line
Thermostat(const char *name, const char *desc = nullptr) : TempRange(name, desc){};
Thermostat(config_obj &owner, const char *name, const char *desc = nullptr) : TempRange(owner, name, desc){};
};
static Thermostat thermo(appdata, "Thermostat", "The primary thermostat");
Boolean Configuration Variable.
Definition config_obj.h:932
Chooser Configuration Variable - Select From a List of Items.
Definition config_obj.h:1915
Signed 32-bit Integer Configuration Variable.
Definition config_obj.h:649
Base class used to create configuration objects.
Definition config_obj.h:277
String Configuration Variable.
Definition config_obj.h:1055
Note
All modifications to configuration objects are marked as pending. A call to SaveConfigToStorage is required to save changes to flash memory.

Constructor & Destructor Documentation

◆ config_obj() [1/2]

config_obj::config_obj ( config_obj & owner,
const char * name,
const char * desc )
inline

Object constructor with the parent/owner leaf parameter.

For example,

myObject(config_obj &owner, const char *name, const char *desc = nullptr) : config_obj(owner, name, desc){};
Parameters
ownerReference to owner/parent leaf
nameField name
descDescription used for info/tool tip

◆ config_obj() [2/2]

config_obj::config_obj ( const char * name,
const char * desc )
inline

Object constructor.

This constructor should be called as part of the derived class constructor. For example,

myObject(const char *name, const char *desc = nullptr) : config_obj(name, desc){}
Parameters
nameField name
descDescription used for info/tool tip

Member Function Documentation

◆ GetTextValue()

virtual void config_obj::GetTextValue ( NBString & s)
virtual

Get the object value as a text string to the specified NBString object.

This is a virtual function that can be overridden in any derived class.

Parameters
sReference to a NBString object to store the result

◆ GetTypeValue()

virtual void config_obj::GetTypeValue ( NBString & s)
inlinevirtual

Assigns the object type value to the specified NBString object.

The type value "object" is written to the NBString object.

Parameters
sNBString object to hold the type value string

Reimplemented in config_chooser.


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