qBittorrent
CachedSettingValue< T > Class Template Reference

#include <settingvalue.h>

Public Member Functions

 CachedSettingValue (const char *keyName, const T &defaultValue={})
 
template<typename ProxyFunc >
 CachedSettingValue (const char *keyName, const T &defaultValue, ProxyFunc &&proxyFunc)
 
get () const
 
 operator T () const
 
CachedSettingValue< T > & operator= (const T &value)
 

Private Attributes

SettingValue< T > m_setting
 
m_cache
 

Detailed Description

template<typename T>
class CachedSettingValue< T >

Definition at line 67 of file settingvalue.h.

Constructor & Destructor Documentation

◆ CachedSettingValue() [1/2]

template<typename T >
CachedSettingValue< T >::CachedSettingValue ( const char *  keyName,
const T &  defaultValue = {} 
)
inlineexplicit

Definition at line 70 of file settingvalue.h.

70  {})
71  : m_setting {keyName}
72  , m_cache {m_setting.get(defaultValue)}
73  {
74  }
SettingValue< T > m_setting
Definition: settingvalue.h:106

◆ CachedSettingValue() [2/2]

template<typename T >
template<typename ProxyFunc >
CachedSettingValue< T >::CachedSettingValue ( const char *  keyName,
const T &  defaultValue,
ProxyFunc &&  proxyFunc 
)
inlineexplicit

Definition at line 79 of file settingvalue.h.

80  : m_setting {keyName}
81  , m_cache {proxyFunc(m_setting.get(defaultValue))}
82  {
83  }

Member Function Documentation

◆ get()

◆ operator T()

template<typename T >
CachedSettingValue< T >::operator T ( ) const
inline

Definition at line 90 of file settingvalue.h.

91  {
92  return get();
93  }

◆ operator=()

template<typename T >
CachedSettingValue<T>& CachedSettingValue< T >::operator= ( const T &  value)
inline

Definition at line 95 of file settingvalue.h.

96  {
97  if (m_cache == value)
98  return *this;
99 
100  m_setting = value;
101  m_cache = value;
102  return *this;
103  }
T value(const QString &key, const T &defaultValue={})
Definition: preferences.cpp:64

References CachedSettingValue< T >::m_cache, CachedSettingValue< T >::m_setting, and anonymous_namespace{preferences.cpp}::value().

Here is the call graph for this function:

Member Data Documentation

◆ m_cache

template<typename T >
T CachedSettingValue< T >::m_cache
private

◆ m_setting

template<typename T >
SettingValue<T> CachedSettingValue< T >::m_setting
private

Definition at line 106 of file settingvalue.h.

Referenced by CachedSettingValue< T >::operator=().


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