6#ifndef SWIFT_MISC_SETTINGSCACHE_H
7#define SWIFT_MISC_SETTINGSCACHE_H
58 static const QString &lockFileName();
66 template <
typename Trait>
75 Trait::defaultValue(), owner)
79 this->onOwnerNameChanged([
this, owner] { private_ns::reconstruct(
this, owner); });
87 template <
typename T,
typename F>
97 auto getDefault()
const {
return Trait::defaultValue(); }
110 template <
typename Trait>
124 qint64 timestamp = 0) =
delete;
132 template <
typename T>
141 qFatal(
"Not implemented");
165 static const T def {};
Provides access to one of the values stored in a CValueCache.
bool isInitialized() const
const QString & getKey() const
CStatusMessage set(const Trait::type &value, qint64 timestamp=0)
CCached(CValueCache *cache, const QString &key, const QString &name, U *owner)
void setNotifySlot(F slot)
Non-owning reference to a CPropertyIndex with a subset of its features.
Class template for accessing a specific value in the CSettingsCache.
auto getDefault() const
Gets the default value.
CStatusMessage setDefault()
Reset the setting to its default value.
CSetting(T *owner)
Constructor.
CSetting(T *owner, F slot)
Constructor.
bool isDefault() const
Is default value?
QString getFilename() const
Return the file that is used for persistence for this value.
Class template for accessing a specific value in the CSettingsCache.
CStatusMessage setDefault()=delete
Deleted mutators.
CStatusMessage save()=delete
Deleted mutators.
CStatusMessage setAndSaveProperty(CPropertyIndexRef index, const CVariant &value, qint64 timestamp=0)=delete
Deleted mutators.
CStatusMessage setProperty(CPropertyIndexRef index, const CVariant &value, qint64 timestamp=0)=delete
Deleted mutators.
CStatusMessage setAndSave(const typename Trait::type &value, qint64 timestamp=0)=delete
Deleted mutators.
CStatusMessage set(const typename Trait::type &value, qint64 timestamp=0)=delete
Deleted mutators.
Singleton derived class of CValueCache, for settings.
static QString filenameForKey(const QString &key)
Return the filename where the value with the given key may be stored.
static const QString & persistentStore()
The directory where settings are stored.
CStatusMessage loadFromStore()
Load settings from disk.
void enableLocalSave()
Connects signal CValueCache::valuesSaveRequested to a private slot that saves the values....
static const QString & relativeFilePath()
Relative file path in application data directory.
static CSettingsCache * instance()
Return the singleton instance.
CStatusMessage saveToStore(const QString &keyPrefix={})
Save settings to disk.
QStringList enumerateStore() const
Return all files where settings may be stored.
Streamable status message, e.g.
Manages a map of { QString, CVariant } pairs, which can be distributed among multiple processes.
Value class used for signalling changed values in the cache.
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
Free functions in swift::misc.
TSettingTrait(const TSettingTrait &)=delete
Deleted copy constructor.
static bool isValid(const T &value, QString &reason)
Validator function. Return true if the argument is valid, false otherwise. Default implementation jus...
TSettingTrait()=delete
Deleted default constructor.
static const char * key()
Key string of the value. Reimplemented in derived class.
static const QString & humanReadable()
Optional human readable name.
static const T & defaultValue()
Return the value to use in case the supplied value does not satisfy the validator....
T type
Data type of the value.
TSettingTrait & operator=(const TSettingTrait &)=delete
Deleted copy assignment operator.
#define SWIFT_MISC_EXPORT
Export a class or function from the library.