Krita Source Code Documentation
Loading...
Searching...
No Matches
KisValueCache< Initializer > Struct Template Reference

#include <KisValueCache.h>

+ Inheritance diagram for KisValueCache< Initializer >:

Public Types

using value_type = decltype(std::declval<Initializer>().initialize())
 

Public Member Functions

void clear ()
 
bool isValid () const
 
template<typename ... Args>
 KisValueCache (Args... args)
 
 operator const value_type & () const
 
const value_typevalue ()
 

Private Attributes

std::optional< value_typem_value
 

Detailed Description

template<typename Initializer>
struct KisValueCache< Initializer >

A simple class for cache-like structures. It should be parametrized with a policy-class that has value_type initialize() method, which would be used for initializing the cache.

Definition at line 18 of file KisValueCache.h.

Member Typedef Documentation

◆ value_type

template<typename Initializer >
using KisValueCache< Initializer >::value_type = decltype(std::declval<Initializer>().initialize())

Definition at line 20 of file KisValueCache.h.

Constructor & Destructor Documentation

◆ KisValueCache()

template<typename Initializer >
template<typename ... Args>
KisValueCache< Initializer >::KisValueCache ( Args... args)
inline

Definition at line 23 of file KisValueCache.h.

24 : Initializer(args...)
25 {
26 }

Member Function Documentation

◆ clear()

template<typename Initializer >
void KisValueCache< Initializer >::clear ( )
inline

Definition at line 44 of file KisValueCache.h.

44 {
45 m_value = std::nullopt;
46 }
std::optional< value_type > m_value

References KisValueCache< Initializer >::m_value.

◆ isValid()

template<typename Initializer >
bool KisValueCache< Initializer >::isValid ( ) const
inline

Definition at line 40 of file KisValueCache.h.

40 {
41 return bool(m_value);
42 }

References KisValueCache< Initializer >::m_value.

◆ operator const value_type &()

template<typename Initializer >
KisValueCache< Initializer >::operator const value_type & ( ) const
inline

Definition at line 36 of file KisValueCache.h.

36 {
37 return value();
38 }
const value_type & value()

References KisValueCache< Initializer >::value().

◆ value()

template<typename Initializer >
const value_type & KisValueCache< Initializer >::value ( )
inline

Definition at line 28 of file KisValueCache.h.

28 {
29 if (!m_value) {
30 m_value = Initializer::initialize();
31 }
32
33 return *m_value;
34 }

References KisValueCache< Initializer >::m_value.

Member Data Documentation

◆ m_value

template<typename Initializer >
std::optional<value_type> KisValueCache< Initializer >::m_value
private

Definition at line 49 of file KisValueCache.h.


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