swift
Public Member Functions | List of all members
swift::misc::CData< Trait > Class Template Reference

Class template for accessing a specific value in the CDataCache. More...

Inheritance diagram for swift::misc::CData< Trait >:
[legend]

Public Member Functions

template<typename T >
 CData (T *owner)
 Constructor. More...
 
template<typename T , typename F >
 CData (T *owner, F slot)
 Constructor. More...
 
CStatusMessage set (const typename Trait::type &value, qint64 timestamp=0)
 Write a new value. Must be called from the thread in which the owner lives. More...
 
CStatusMessage setProperty (CPropertyIndexRef index, const CVariant &value, qint64 timestamp=0)
 Write a property of the value. Must be called from the thread in which the owner lives. More...
 
CStatusMessage setDefault ()
 Reset the data to its default value.
 
QString getFilename () const
 Return the file that is used for persistence for this value.
 
bool isStale () const
 True if the current timestamp is older than the TTL (time to live).
 
void renewTimestamp (qint64 timestamp)
 Don't change the value, but write a new timestamp, to extend the life of the value.
 
QDateTime getAvailableTimestamp () const
 Get the timestamp of the value, or of the deferred value that is available to be loaded.
 
void admit ()
 If the value is load-deferred, trigger the deferred load (async).
 
void synchronize ()
 If the value is currently being loaded, wait for it to finish loading, and call the notification slot, if any. More...
 
CStatusMessage save ()=delete
 Data cache doesn't support save (because currently set value is saved already).
 
CStatusMessage setAndSave (const typename Trait::type &value, qint64 timestamp=0)=delete
 Data cache doesn't support setAndSave (because set() already causes save anyway).
 
CStatusMessage setAndSaveProperty (CPropertyIndexRef index, const CVariant &value, qint64 timestamp=0)=delete
 Data cache doesn't support setAndSave (because set() already causes save anyway).
 
- Public Member Functions inherited from swift::misc::CCached< Trait::type >
 CCached (CValueCache *cache, const QString &key, const QString &name, U *owner)
 Constructor. More...
 
 CCached (CValueCache *cache, const QString &key, const QString &name, F validator, const Trait::type &defaultValue, U *owner)
 Constructor. More...
 
 CCached (const CCached &)=delete
 Deleted copy constructor.
 
void setNotifySlot (F slot)
 Set a callback to be called when the value is changed by another source.
 
const Trait::type & getThreadLocal () const
 Read the current value.
 
Trait::type get () const
 Get a copy of the current value. More...
 
CStatusMessage set (const Trait::type &value, qint64 timestamp=0)
 Write a new value. Must be called from the thread in which the owner lives.
 
CStatusMessage setAndSave (const Trait::type &value, qint64 timestamp=0)
 Write and save in the same step. Must be called from the thread in which the owner lives.
 
CStatusMessage save ()
 Save using the currently set value. Must be called from the thread in which the owner lives.
 
CStatusMessage setProperty (CPropertyIndexRef index, const CVariant &value, qint64 timestamp=0)
 Write a property of the value. Must be called from the thread in which the owner lives.
 
CStatusMessage setAndSaveProperty (CPropertyIndexRef index, const CVariant &value, qint64 timestamp=0)
 Write a property and save in the same step. Must be called from the thread in which the owner lives.
 
bool isOwnerThread () const
 Is current thread the owner thread, so CCached::set is safe.
 
const QString & getKey () const
 Get the key string of this value.
 
QDateTime getTimestamp () const
 Return the time when this value was updated. More...
 
qint64 getTimestampMsSinceEpoch () const
 Return the time when this value was updated. More...
 
qint64 lastUpdatedAge () const
 How old is that cache (ms)?
 
bool isSaved () const
 Return true if this value was already saved.
 
bool isSaving () const
 Return true if this value is currently saving.
 
bool isInitialized () const
 Can be false if key contains OwnerName% and owner's objectName was empty.
 
CCachedoperator= (const CCached &)=delete
 Deleted copy assignment operator.
 

Detailed Description

template<typename Trait>
class swift::misc::CData< Trait >

Class template for accessing a specific value in the CDataCache.

Template Parameters
TraitA subclass of swift::misc::TDataTrait that identifies the value's key and other metadata.

Definition at line 314 of file datacache.h.

Constructor & Destructor Documentation

◆ CData() [1/2]

template<typename Trait >
template<typename T >
swift::misc::CData< Trait >::CData ( T *  owner)
inline

Constructor.

Parameters
ownerWill be the parent of the internal QObject used to access the value.

Definition at line 320 of file datacache.h.

◆ CData() [2/2]

template<typename Trait >
template<typename T , typename F >
swift::misc::CData< Trait >::CData ( T *  owner,
slot 
)
inline

Constructor.

Parameters
ownerWill be the parent of the internal QObject used to access the value.
slotSlot to call when the value is modified by another object. Must be a void, non-const member function of the owner.

Definition at line 344 of file datacache.h.

Member Function Documentation

◆ set()

template<typename Trait >
CStatusMessage swift::misc::CData< Trait >::set ( const typename Trait::type &  value,
qint64  timestamp = 0 
)
inline

Write a new value. Must be called from the thread in which the owner lives.

Definition at line 350 of file datacache.h.

◆ setProperty()

template<typename Trait >
CStatusMessage swift::misc::CData< Trait >::setProperty ( CPropertyIndexRef  index,
const CVariant value,
qint64  timestamp = 0 
)
inline

Write a property of the value. Must be called from the thread in which the owner lives.

Definition at line 357 of file datacache.h.

◆ synchronize()

template<typename Trait >
void swift::misc::CData< Trait >::synchronize ( )
inline

If the value is currently being loaded, wait for it to finish loading, and call the notification slot, if any.

Todo:
KB 2018-01 is this OK or should it go to CValuePage::setValuesFromCache?

Definition at line 400 of file datacache.h.


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