Rose
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
rose::Settings Class Reference

A settings database. More...

#include <Settings.h>

Public Member Functions

void initializeDatabase ()
 Initialize the database, creating the required tables if they have not been created.
 
template<typename T , typename S >
std::optional< T > getDatabaseValue (soci::session &sql, S name)
 Get a value from settings the database. More...
 
template<typename T , typename S >
void setDatabaseValue (soci::session &sql, S name, T value)
 Set a value in the settings database. More...
 
template<typename T , typename S >
void setValue (S name, T value)
 Set a value in the settings database. More...
 
template<typename T , typename S >
std::optional< T > getValue (S name)
 Get a value in the settings database. More...
 
template<typename T , typename S >
getValue (S name, T defaultValue)
 Get a value in the settings database, returning the default value if not found. More...
 

Static Public Member Functions

static SettingsgetSettings ()
 

Public Attributes

SettingsUpdateProtocol::signal_type dataChangeTx {}
 The Signal to notify of settings updates.
 

Protected Member Functions

void transmitDataUpdate (const std::string &dataName)
 Send out notification that data has changed. More...
 

Protected Attributes

std::filesystem::path mDbPath
 The file path to the settings database.
 

Static Protected Attributes

static constexpr std::string_view string_table = "settings_string"
 The string table.
 
static constexpr std::string_view int_table = "settings_int"
 The integer table.
 
static constexpr std::string_view real_table = "settings_real"
 The real table.
 
static constexpr std::string_view int_pair_table = "settings_int_pair"
 The integer pair table.
 
static constexpr std::string_view real_pair_table = "settings_real_pair"
 The real pair table.
 
static constexpr std::string_view color_table = "settings_color"
 The color table.
 

Detailed Description

A settings database.

Member Function Documentation

◆ getDatabaseValue()

template<typename T , typename S >
std::optional<T> rose::Settings::getDatabaseValue ( soci::session &  sql,
name 
)
inline

Get a value from settings the database.

Select the table to search based on the type of value sought.

Template Parameters
TThe type of the value to retrieve.
SThe type of the name of the value.
Parameters
sqlThe database session to use.
nameThe name of the value
Returns
A std::optional<T> containing the value if found, empty if not found.

◆ getValue() [1/2]

template<typename T , typename S >
std::optional<T> rose::Settings::getValue ( name)
inline

Get a value in the settings database.

Template Parameters
TThe type of the value.
SThe type of the name of the value.
Parameters
nameThe name of the value.
Returns
A std::optional<T> with the value if found, empty if not found.

◆ getValue() [2/2]

template<typename T , typename S >
T rose::Settings::getValue ( name,
defaultValue 
)
inline

Get a value in the settings database, returning the default value if not found.

Template Parameters
TThe type of the value.
SThe type of the name of the value.
Parameters
nameThe name of the value.
defaultValueThe default value to return if the value is not in the database.
Returns
The found value, or the default value.

◆ setDatabaseValue()

template<typename T , typename S >
void rose::Settings::setDatabaseValue ( soci::session &  sql,
name,
value 
)
inline

Set a value in the settings database.

Select the table to store the value based on the type of value.

Template Parameters
TThe type of the value to retrieve.
SThe type of the name of the value.
Parameters
sqlThe database session to use.
nameThe name of the value
valueThe value to store.

◆ setValue()

template<typename T , typename S >
void rose::Settings::setValue ( name,
value 
)
inline

Set a value in the settings database.

Template Parameters
TThe type of the value.
SThe type of the name of the value.
Parameters
nameThe name of the value.
valueThe value.

◆ transmitDataUpdate()

void rose::Settings::transmitDataUpdate ( const std::string &  dataName)
protected

Send out notification that data has changed.

Parameters
dataNameThe name of the data item that has changed.

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