LibrePCB Developers Documentation
WorkspaceSettingsItem_GenericValue< T > Class Template Referencefinal

Generic implementation of librepcb::WorkspaceSettingsItem for simple, value-type settings. More...

#include <workspacesettingsitem_genericvalue.h>

+ Inheritance diagram for WorkspaceSettingsItem_GenericValue< T >:
+ Collaboration diagram for WorkspaceSettingsItem_GenericValue< T >:

Public Member Functions

 WorkspaceSettingsItem_GenericValue ()=delete
 
 WorkspaceSettingsItem_GenericValue (const WorkspaceSettingsItem_GenericValue &other)=delete
 
 WorkspaceSettingsItem_GenericValue (const QString &key, const T &defaultValue, QObject *parent=nullptr) noexcept
 
 ~WorkspaceSettingsItem_GenericValue () noexcept
 
const T & get () const noexcept
 Get the current value. More...
 
void set (const T &value) noexcept
 Set the value. More...
 
const T & getDefault () const noexcept
 Get the default value. More...
 
WorkspaceSettingsItem_GenericValueoperator= (const WorkspaceSettingsItem_GenericValue &rhs)=delete
 
- Public Member Functions inherited from WorkspaceSettingsItem
 WorkspaceSettingsItem ()=delete
 
 WorkspaceSettingsItem (const QString &key, QObject *parent=nullptr) noexcept
 
 WorkspaceSettingsItem (const WorkspaceSettingsItem &other)=delete
 
virtual ~WorkspaceSettingsItem () noexcept
 
const QString & getKey () const noexcept
 Get the setting key used for serialization. More...
 
bool isDefaultValue () const noexcept
 Check whether this setting is at its default value (not modified) More...
 
bool isEdited () const noexcept
 Check whether this setting was edited sinc the last load or save. More...
 
void restoreDefault () noexcept
 Restore default value. More...
 
void load (const SExpression &root)
 Load value from S-Expression file. More...
 
void serialize (SExpression &root) const
 Serialize the value into S-Expression nodes. More...
 
WorkspaceSettingsItemoperator= (const WorkspaceSettingsItem &rhs)=delete
 

Private Member Functions

virtual void restoreDefaultImpl () noexcept override
 Restore default value. More...
 
void loadImpl (const SExpression &root) override
 Load value from S-Expression node. More...
 
void serializeImpl (SExpression &root) const override
 Serialize the value into S-Expression node. More...
 

Private Attributes

mDefaultValue
 Initial, default value. More...
 
mCurrentValue
 Current value. More...
 

Additional Inherited Members

- Signals inherited from WorkspaceSettingsItem
void edited ()
 Signal to notify about changes of the settings value. More...
 
- Protected Member Functions inherited from WorkspaceSettingsItem
void valueModified () noexcept
 
virtual void restoreDefaultImpl () noexcept=0
 Restore default value. More...
 
virtual void loadImpl (const SExpression &root)=0
 Load value from S-Expression node. More...
 
virtual void serializeImpl (SExpression &root) const =0
 Serialize the value into S-Expression node. More...
 

Detailed Description

template<typename T>
class librepcb::WorkspaceSettingsItem_GenericValue< T >

Generic implementation of librepcb::WorkspaceSettingsItem for simple, value-type settings.

Constructor & Destructor Documentation

◆ WorkspaceSettingsItem_GenericValue() [1/3]

◆ WorkspaceSettingsItem_GenericValue() [2/3]

◆ WorkspaceSettingsItem_GenericValue() [3/3]

WorkspaceSettingsItem_GenericValue ( const QString &  key,
const T &  defaultValue,
QObject *  parent = nullptr 
)
inlineexplicitnoexcept

◆ ~WorkspaceSettingsItem_GenericValue()

Member Function Documentation

◆ get()

const T & get ( ) const
inlinenoexcept

Get the current value.

Returns
Current value
+ Here is the caller graph for this function:

◆ set()

void set ( const T &  value)
inlinenoexcept

Set the value.

Parameters
valueThe new value
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefault()

const T & getDefault ( ) const
inlinenoexcept

Get the default value.

Returns
Default value

◆ operator=()

◆ restoreDefaultImpl()

virtual void restoreDefaultImpl ( )
inlineoverrideprivatevirtualnoexcept

Restore default value.

Note
Implementation must emit the edited() signal if the value has changed.

Implements WorkspaceSettingsItem.

+ Here is the call graph for this function:

◆ loadImpl()

void loadImpl ( const SExpression root)
inlineoverrideprivatevirtual

Load value from S-Expression node.

Parameters
rootS-Expression node of the settings element.
Note
Implementation must emit the edited() signal if the value has changed.
Implementation must be atomic, i.e. either the value must be loaded completely from file, or left at the old value (in case of errors).

Implements WorkspaceSettingsItem.

+ Here is the call graph for this function:

◆ serializeImpl()

void serializeImpl ( SExpression root) const
inlineoverrideprivatevirtual

Serialize the value into S-Expression node.

Parameters
rootS-Expression node to be updated.

Implements WorkspaceSettingsItem.

+ Here is the call graph for this function:

Member Data Documentation

◆ mDefaultValue

T mDefaultValue
private

Initial, default value.

◆ mCurrentValue

T mCurrentValue
private

Current value.


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