6 #ifndef SWIFT_MISC_SETTINGSCACHE_H
7 #define SWIFT_MISC_SETTINGSCACHE_H
11 #include <QStringList>
31 static const QString &persistentStore();
41 void enableLocalSave();
47 static QString filenameForKey(
const QString &key);
50 static const QString &relativeFilePath();
53 QStringList enumerateStore()
const;
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");
148 static const QString name;
154 static bool isValid(
const T &value, QString &reason)
165 static const T def {};
Provides access to one of the values stored in a CValueCache.
bool isInitialized() const
Can be false if key contains OwnerName% and owner's objectName was empty.
CStatusMessage set(const Trait::type &value, qint64 timestamp=0)
Write a new value. Must be called from the thread in which the owner lives.
const QString & getKey() const
Get the key string of this value.
void setNotifySlot(F slot)
Set a callback to be called when the value is changed by another source.
Trait::type get() const
Get a copy of the current value.
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.
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.
Base class for traits to be used as template argument to swift::misc::CSetting.
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 T & defaultValue()
Return the value to use in case the supplied value does not satisfy the validator....
static const QString & humanReadable()
Optional human readable name.
TSettingTrait & operator=(const TSettingTrait &)=delete
Deleted copy assignment operator.
T type
Data type of the value.
static const char * key()
Key string of the value. Reimplemented in derived class.
#define SWIFT_MISC_EXPORT
Export a class or function from the library.