Workspace 6.21.5
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SettingsMap< Enum > Class Template Referenceabstract

This abstract class stores settings information and current value. It wraps around QMap that maps some type of settings Enum to a QVariant. More...

#include <Workspace/Application/settingsmap.h>

Inheritance diagram for SettingsMap< Enum >:
[legend]

Classes

struct  Setting
 

Public Member Functions

virtual QString getParentTag () const =0
 
QString getSerializableName (Enum setting) const
 
QList< Enum > getSettingTypes () const
 
template<typename T >
bool getValue (Enum setting, T &value) const
 
void loadAll (DataExecution::SerializedItem &parentItem)
 
void saveAll (DataExecution::SerializedItem &rootItem)
 
template<typename T >
bool setValue (Enum setting, const T &value)
 
Enum toEnum (const QString &name, bool &ok)
 

Protected Member Functions

 SettingsMap ()=default
 
virtual void load (const DataExecution::SerializedItem &item)
 
virtual void save (Enum setting, DataExecution::SerializedItem &item)
 
bool validateMap ()
 

Protected Attributes

QMap< Enum, Settingmap_
 

Detailed Description

template<typename Enum>
class CSIRO::Application::SettingsMap< Enum >

getParentTag must be implemented to return the tag name of the parent item of the setting category. Settings items are serialised as children to the parent item.

Constructor & Destructor Documentation

◆ SettingsMap()

SettingsMap ( )
protecteddefault

Member Function Documentation

◆ getParentTag()

virtual QString getParentTag ( ) const
pure virtual
Returns
Parent tag name of the SerializedItem that the settings items will be parented to.

Implemented in UserInterfaceMap.

◆ getSerializableName()

QString getSerializableName ( Enum  setting) const
inline
Parameters
settingThe specified setting
Returns
The serializable name of the specified setting

◆ getSettingTypes()

QList< Enum > getSettingTypes ( ) const
inline
Returns
All settings types.

◆ getValue()

bool getValue ( Enum  setting,
T &  value 
) const
inline
Parameters
settingThe specified setting
valueThe value of the setting is written to this variable.
Returns
false when the value was not retrieved successfully and consequently value will be unchanged.

◆ load()

virtual void load ( const DataExecution::SerializedItem item)
inlineprotectedvirtual

Loads the value from the attribute of item

◆ loadAll()

void loadAll ( DataExecution::SerializedItem parentItem)
inline
Parameters
parentItemThe parent SerializedItem whose children are expected to be settings to load

Removes all children of parentItem, loading each settings value from each child.

◆ save()

virtual void save ( Enum  setting,
DataExecution::SerializedItem item 
)
inlineprotectedvirtual

Saves the setting value as an attribute of item

◆ saveAll()

void saveAll ( DataExecution::SerializedItem rootItem)
inline
Parameters
rootItemThe root settings item.

Adds a new parent SerializedItem to rootItem if required. All settings will be saved as children of that parent item.

◆ setValue()

bool setValue ( Enum  setting,
const T &  value 
)
inline
Parameters
settingThe specified setting
valueThe value that will be set for the specified setting

◆ toEnum()

Enum toEnum ( const QString &  name,
bool &  ok 
)
inline
Parameters
nameThe serilizable name of a specified enum
okReturns false when the name is unrecognised
Returns
The enum value as converted from the serializable name

◆ validateMap()

bool validateMap ( )
inlineprotected

Call this function after initialising the map to validate

  1. initial values are of the correct type
  2. make sure there are no duplicate serializable names.

Member Data Documentation

◆ map_

QMap<Enum, Setting> map_
protected