swift
Loading...
Searching...
No Matches
swift::misc::TDataTrait< T > Struct Template Reference

Base class for traits to be used as template argument to swift::misc::CData. More...

#include <datacache.h>

Public Types

using type = T
 Data type of the value.

Public Member Functions

 TDataTrait ()=delete
 Deleted default constructor.
 TDataTrait (const TDataTrait &)=delete
 Deleted copy constructor.
TDataTrait & operator= (const TDataTrait &)=delete
 Deleted copy assignment operator.

Static Public Member Functions

static const char * key ()
 Key string of the value. Reimplemented in derived class.
static const QString & humanReadable ()
 Optional human readable name.
static bool isValid (const T &value, QString &reason)
 Validator function. Return true if the argument is valid, false otherwise. Default implementation just returns true. Reimplemented in derived class to support validation of the value.
static const T & defaultValue ()
 Return the value to use in case the supplied value does not satisfy the validator. Default implementation returns a default-constructed value.
static int timeToLive ()
 Number of milliseconds after which cached value becomes stale. Default is -1 which means value never becomes stale.
static constexpr bool isPinned ()
 If true, then value will be synchronously loaded when CDataCache is constructed. Good for small, important values; bad for large ones.
static constexpr bool isDeferred ()
 If true, then value will not be loaded until it is explicitly admitted. Good for large values the loading of which might depend on some other condition.
static constexpr bool isSession ()
 If true, then upon starting an application, value will be overwritten with the default if there are no other applications currently using the cache. In effect, the value is retained only while there are applications using the cache.

Detailed Description

template<typename T>
struct swift::misc::TDataTrait< T >

Base class for traits to be used as template argument to swift::misc::CData.

Definition at line 476 of file datacache.h.

Member Typedef Documentation

◆ type

template<typename T>
using swift::misc::TDataTrait< T >::type = T

Data type of the value.

Definition at line 479 of file datacache.h.

Member Function Documentation

◆ defaultValue()

template<typename T>
const T & swift::misc::TDataTrait< T >::defaultValue ( )
inlinestatic

Return the value to use in case the supplied value does not satisfy the validator. Default implementation returns a default-constructed value.

Definition at line 506 of file datacache.h.

◆ humanReadable()

template<typename T>
const QString & swift::misc::TDataTrait< T >::humanReadable ( )
inlinestatic

Optional human readable name.

Definition at line 489 of file datacache.h.

◆ isDeferred()

template<typename T>
constexpr bool swift::misc::TDataTrait< T >::isDeferred ( )
inlinestaticconstexpr

If true, then value will not be loaded until it is explicitly admitted. Good for large values the loading of which might depend on some other condition.

Definition at line 522 of file datacache.h.

◆ isPinned()

template<typename T>
constexpr bool swift::misc::TDataTrait< T >::isPinned ( )
inlinestaticconstexpr

If true, then value will be synchronously loaded when CDataCache is constructed. Good for small, important values; bad for large ones.

Definition at line 518 of file datacache.h.

◆ isSession()

template<typename T>
constexpr bool swift::misc::TDataTrait< T >::isSession ( )
inlinestaticconstexpr

If true, then upon starting an application, value will be overwritten with the default if there are no other applications currently using the cache. In effect, the value is retained only while there are applications using the cache.

Definition at line 527 of file datacache.h.

◆ isValid()

template<typename T>
bool swift::misc::TDataTrait< T >::isValid ( const T & value,
QString & reason )
inlinestatic

Validator function. Return true if the argument is valid, false otherwise. Default implementation just returns true. Reimplemented in derived class to support validation of the value.

Definition at line 497 of file datacache.h.

◆ key()

template<typename T>
const char * swift::misc::TDataTrait< T >::key ( )
inlinestatic

Key string of the value. Reimplemented in derived class.

Definition at line 482 of file datacache.h.

◆ timeToLive()

template<typename T>
int swift::misc::TDataTrait< T >::timeToLive ( )
inlinestatic

Number of milliseconds after which cached value becomes stale. Default is -1 which means value never becomes stale.

Definition at line 514 of file datacache.h.


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