SPH
Classes | Public Member Functions | List of all members
VirtualSettings Class Reference

Holds a map of virtual entries, associated with a unique name. More...

#include <VirtualSettings.h>

Classes

class  Category
 
class  IEntryProc
 Interface allowing to enumerate all entries in the settings. More...
 

Public Member Functions

void set (const std::string &key, const IVirtualEntry::Value &value)
 Modifies an existing entry in the settings. More...
 
template<typename TEnum , typename = std::enable_if_t<std::is_enum<TEnum>::value>>
void set (const TEnum id, const IVirtualEntry::Value &value)
 Overload allowing to use an ID associated with a Settings entry. More...
 
IVirtualEntry::Value get (const std::string &key) const
 Returns a value of an entry. More...
 
CategoryaddCategory (const std::string &name)
 Creates a new category of entries. More...
 
void enumerate (const IEntryProc &proc)
 Enumerates all entries stored in the settings. More...
 

Detailed Description

Holds a map of virtual entries, associated with a unique name.

The key-value pairs are not stored in the settings directly, they are stored in settings categories; the VirtualSettings object then holds a map of categories. This provides clustering of related entries, which helps to separate the entries in UI.

Definition at line 229 of file VirtualSettings.h.

Member Function Documentation

◆ addCategory()

VirtualSettings::Category & VirtualSettings::addCategory ( const std::string &  name)

Creates a new category of entries.

Returned object can be used to add entries into settings.

Parameters
nameName of the created category.

Definition at line 100 of file VirtualSettings.cpp.

◆ enumerate()

void VirtualSettings::enumerate ( const IEntryProc proc)

Enumerates all entries stored in the settings.

Definition at line 104 of file VirtualSettings.cpp.

◆ get()

IVirtualEntry::Value VirtualSettings::get ( const std::string &  key) const

Returns a value of an entry.

Parameters
keyIdentifier of the entry
Exceptions
InvalidSetupif no entry with given key exists.

Definition at line 90 of file VirtualSettings.cpp.

◆ set() [1/2]

void VirtualSettings::set ( const std::string &  key,
const IVirtualEntry::Value value 
)

Modifies an existing entry in the settings.

This function cannot be used to add a new entry. Use Category to create entries.

Parameters
keyIdentifier of the entry
valueNew value of the entry
Exceptions
InvalidSetupif no entry with given key exists.

Definition at line 79 of file VirtualSettings.cpp.

◆ set() [2/2]

template<typename TEnum , typename >
void VirtualSettings::set ( const TEnum  id,
const IVirtualEntry::Value value 
)

Overload allowing to use an ID associated with a Settings entry.

This is useful if the virtual entry is connected to an entry in a Settings object. This way, an enum value can be used instead of string, ensuring the value is valid (string may contain typos) and can be easily renamed if necessary.

Note that there is no check that the virtual entry is really connected to a "real" entry with given ID, virtual entry is (intentionally) a black box here.

Parameters
idID of the connected entry
valueNew value of the entry
Exceptions
InvalidSetupif the ID is invalid or no entry with given ID exists.

Definition at line 267 of file VirtualSettings.inl.h.


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