QtDataSync  4.2.0
A simple offline-first synchronisation framework, to synchronize data of Qt applications between devices
Public Types | Signals | Public Member Functions | List of all members
QtDataSync::DataStore Class Reference

Main store to generically access all stored data synchronously. More...

#include <datastore.h>

+ Inheritance diagram for QtDataSync::DataStore:

Public Types

enum  SearchMode {
  RegexpMode, WildcardMode, ContainsMode, StartsWithMode,
  EndsWithMode
}
 Possible pattern modes for the search mechanism. More...
 

Signals

void dataChanged (int metaTypeId, const QString &key, bool deleted, QPrivateSignal)
 Is emitted whenever a dataset has been changed. More...
 
Q_DECL_DEPRECATED void dataCleared (int metaTypeId, QPrivateSignal)
 Is emitted when a datatypes has been cleared. More...
 
void dataResetted (QPrivateSignal)
 Is emitted when the store is resetted due to an account reset. More...
 

Public Member Functions

 DataStore (QObject *parent=nullptr)
 Default constructor, uses the default setup. More...
 
 DataStore (const QString &setupName, QObject *parent=nullptr)
 Constructor with an explicit setup. More...
 
QString setupName () const
 Returns the name of the setup this class operates on. More...
 
qint64 count (int metaTypeId) const
 Counts the number of datasets for the given type. More...
 
QStringList keys (int metaTypeId) const
 Returns all saved keys for the given type. More...
 
QVariantList loadAll (int metaTypeId) const
 Loads all existing datasets for the given type. More...
 
bool contains (int metaTypeId, const QString &key) const
 Checks if a dataset exists in the store for the given key. More...
 
bool contains (int metaTypeId, const QVariant &key) const
 Checks if a dataset exists in the store for the given key. More...
 
QVariant load (int metaTypeId, const QString &key) const
 Loads the dataset with the given key for the given type. More...
 
QVariant load (int metaTypeId, const QVariant &key) const
 Loads the dataset with the given key for the given type. More...
 
void save (int metaTypeId, QVariant value)
 Saves the given dataset in the store. More...
 
bool remove (int metaTypeId, const QString &key)
 Removes the dataset with the given key for the given type. More...
 
bool remove (int metaTypeId, const QVariant &key)
 Removes the dataset with the given key for the given type. More...
 
void update (int metaTypeId, QObject *object) const
 Loads the dataset with the given key for the given type into the existing object by updating it's properties. More...
 
QVariantList search (int metaTypeId, const QString &query, SearchMode mode=RegexpMode) const
 Searches the store for datasets of the given type where the key matches the query. More...
 
void iterate (int metaTypeId, const std::function< bool(QVariant)> &iterator) const
 Iterates over all existing datasets of the given types. More...
 
void iterate (int metaTypeId, const std::function< bool(QVariant)> &iterator, bool skipBroken) const
 Iterates over all existing datasets of the given types. More...
 
void clear (int metaTypeId)
 Removes all datasets of the given type from the store. More...
 
template<typename T >
quint64 count () const
 Counts the number of datasets for the given type. More...
 
template<typename T >
QStringList keys () const
 Returns all saved keys for the given type. More...
 
template<typename T , typename K >
QList< K > keys () const
 Returns all saved keys for the given type. More...
 
template<typename T >
QList< T > loadAll () const
 Loads all existing datasets for the given type. More...
 
template<typename T >
bool contains (const QString &key) const
 Checks if a dataset exists in the store for the given key. More...
 
template<typename T , typename K >
bool contains (const K &key) const
 Checks if a dataset exists in the store for the given key. More...
 
template<typename T >
load (const QString &key) const
 Loads the dataset with the given key for the given type. More...
 
template<typename T , typename K >
load (const K &key) const
 Loads the dataset with the given key for the given type. More...
 
template<typename T >
void save (const T &value)
 Saves the given dataset in the store. More...
 
template<typename T >
bool remove (const QString &key)
 Removes the dataset with the given key for the given type. More...
 
template<typename T , typename K >
bool remove (const K &key)
 Removes the dataset with the given key for the given type. More...
 
template<typename T >
void update (T object) const
 Loads the dataset with the given key for the given type into the existing object by updating it's properties. More...
 
template<typename T >
QList< T > search (const QString &query, SearchMode mode=RegexpMode) const
 Searches the store for datasets of the given type where the key matches the query. More...
 
template<typename T >
void iterate (const std::function< bool(T)> &iterator, bool skipBroken=false) const
 Iterates over all existing datasets of the given types. More...
 
template<typename T >
void clear ()
 Removes all datasets of the given type from the store. More...
 
- Public Member Functions inherited from QObject
virtual const QMetaObjectmetaObject () const const
 
virtual void * qt_metacast (const char *)
 
virtual int qt_metacall (QMetaObject::Call, int, void **)
 
 QObject (QObject *parent)
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
bool signalsBlocked () const const
 
bool blockSignals (bool block)
 
QThreadthread () const const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
const QObjectList & children () const const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
void dumpObjectTree () const const
 
void dumpObjectInfo () const const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const const
 
QList< QByteArraydynamicPropertyNames () const const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
bool inherits (const char *className) const const
 
void deleteLater ()
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
- Protected Member Functions inherited from QObject
QObjectsender () const const
 
int senderSignalIndex () const const
 
int receivers (const char *signal) const const
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

Main store to generically access all stored data synchronously.

The class is used as base for all other stores. It provides a generic API to access the store that is simple to use, as well as a the same API for use with metatype ids and qvariant to access the store non generically. All access is atomic and synchronous. A single store can only be used from within one thread, but you can create a store on any thread. It also provides change signals to notify you in case a dataset has been changed.

Warning
If you are using the stores with QObject classes, please be aware that the store never** takes ownership of those objects, neither for saving nor for loading. You as the caller of those methods are responsible for deleting the objects after the operations have been completed. This of course only applies to pointer classes, as gadgets are used as value types.
See also
DataTypeStore, CachingDataTypeStore, DataStoreModel, EventCursor

Definition at line 21 of file datastore.h.

Member Enumeration Documentation

◆ SearchMode

Possible pattern modes for the search mechanism.

Enumerator
RegexpMode 

Interpret the search string as a regular expression. See QRegularExpression.

WildcardMode 

Interpret the search string as a wildcard string (with * and ?)

ContainsMode 

The data key must contain the search string.

StartsWithMode 

The data key must start with the search string.

EndsWithMode 

The data key must end with the search string.

Definition at line 28 of file datastore.h.

Constructor & Destructor Documentation

◆ DataStore() [1/2]

QtDataSync::DataStore::DataStore ( QObject parent = nullptr)
explicit

Default constructor, uses the default setup.

Parameters
parentThe parent object
Exceptions
SetupDoesNotExistExceptionThrown if the default setup was not created yet

◆ DataStore() [2/2]

QtDataSync::DataStore::DataStore ( const QString setupName,
QObject parent = nullptr 
)
explicit

Constructor with an explicit setup.

Parameters
setupNameThe name of the setup to connect to
parentThe parent object
Exceptions
SetupDoesNotExistExceptionThrown if the given setup was not created yet

Member Function Documentation

◆ clear() [1/2]

QtDataSync::DataStore::clear ( int  metaTypeId)

Removes all datasets of the given type from the store.

Parameters
metaTypeIdThe QMetaType type id of the type
Exceptions
LocalStoreExceptionIn case of an internal error
See also
DataStore::dataCleared, DataStore::remove

◆ clear() [2/2]

template<typename T >
QtDataSync::DataStore::clear ( )

Removes all datasets of the given type from the store.

Template Parameters
TThe type to be cleard
Exceptions
LocalStoreExceptionIn case of an internal error
See also
DataStore::dataCleared, DataStore::remove

Definition at line 352 of file datastore.h.

◆ contains() [1/4]

QtDataSync::DataStore::contains ( int  metaTypeId,
const QString key 
) const

Checks if a dataset exists in the store for the given key.

Parameters
metaTypeIdThe QMetaType type id of the type
keyThe key of the dataset to be checked for existance
Returns
true if the dataset exists, false if not
Exceptions
LocalStoreExceptionIn case of an internal error
See also
DataStore::keys, DataStore::load

◆ contains() [2/4]

QtDataSync::DataStore::contains ( int  metaTypeId,
const QVariant key 
) const
inline

Checks if a dataset exists in the store for the given key.

Parameters
metaTypeIdThe QMetaType type id of the type
keyThe key of the dataset to be checked for existance
Returns
true if the dataset exists, false if not
Exceptions
LocalStoreExceptionIn case of an internal error
See also
DataStore::keys, DataStore::load
Note
The given QVariant must be convertible to a QString

Definition at line 56 of file datastore.h.

◆ contains() [3/4]

template<typename T >
QtDataSync::DataStore::contains ( const QString key) const

Checks if a dataset exists in the store for the given key.

Template Parameters
TThe type of the dataset to check for
Parameters
keyThe key of the dataset to be checked for existance
Returns
true if the dataset exists, false if not
Exceptions
LocalStoreExceptionIn case of an internal error
See also
DataStore::keys, DataStore::load

Definition at line 277 of file datastore.h.

◆ contains() [4/4]

template<typename T , typename K >
QtDataSync::DataStore::contains ( const K &  key) const

Checks if a dataset exists in the store for the given key.

Template Parameters
KThe type of the key to be returned as list
TThe type of the dataset to check for
Parameters
keyThe key of the dataset to be checked for existance
Returns
true if the dataset exists, false if not
Exceptions
LocalStoreExceptionIn case of an internal error
See also
DataStore::keys, DataStore::load
Note
The given type K must be convertible to a QString

Definition at line 284 of file datastore.h.

◆ count() [1/2]

QtDataSync::DataStore::count ( int  metaTypeId) const

Counts the number of datasets for the given type.

Parameters
metaTypeIdThe QMetaType type id of the type
Returns
The number of datasets of the given type stored
Exceptions
LocalStoreExceptionIn case of an internal error
See also
DataStore::keys

◆ count() [2/2]

template<typename T >
QtDataSync::DataStore::count ( ) const

Counts the number of datasets for the given type.

Template Parameters
TThe type to be counted
Returns
The number of datasets of the given type stored
Exceptions
LocalStoreExceptionIn case of an internal error
See also
DataStore::keys

Definition at line 243 of file datastore.h.

◆ dataChanged

QtDataSync::DataStore::dataChanged ( int  metaTypeId,
const QString key,
bool  deleted,
QPrivateSignal   
)
signal

Is emitted whenever a dataset has been changed.

Parameters
metaTypeIdThe QMetaType type id of the dataset that was changed
keyThe key of the dataset that was changed
deletedtrue if the dataset was deleted, false if it was created or changed

Is emitted for any local or remote data change. For local changes, it is emitted from within the method that performs the changed. For passive setups or remote changes, it is emitted as queued signal instead.

See also
DataStore::save, DataStore::remove

◆ dataCleared

QtDataSync::DataStore::dataCleared ( int  metaTypeId,
QPrivateSignal   
)
signal

Is emitted when a datatypes has been cleared.

Parameters
metaTypeIdThe QMetaType type id of the type that was cleard

This signal is only emitted when a type was completly removed locally. If data was removed by a remote, dataChanged() will instead be called for every single remove dataset. Locally, only this signal will be emitted.

See also
DataStore::clear, DataStore::dataChanged

◆ dataResetted

QtDataSync::DataStore::dataResetted ( QPrivateSignal  )
signal

Is emitted when the store is resetted due to an account reset.

This one is only emitted on account resets where the whole store (i.e. all types in it) have been deleted. It indicates a total reset of the store.

See also
DataStore::clear, AccountManager::resetAccount, AccountManager::importAccount, AccountManager::importAccountTrusted

◆ iterate() [1/3]

QtDataSync::DataStore::iterate ( int  metaTypeId,
const std::function< bool(QVariant)> &  iterator 
) const

Iterates over all existing datasets of the given types.

Parameters
metaTypeIdThe QMetaType type id of the type
iteratorAn iterator function that is called for every dataset of the given type
Exceptions
LocalStoreExceptionIn case of an internal error

Semantics of the iterator:

  • Parameter 1: The loaded dataset
  • Returns: true to continue the iteration, false to prematurely abort it
See also
DataStore::search, DataStore::keys, DataStore::loadAll

◆ iterate() [2/3]

QtDataSync::DataStore::iterate ( int  metaTypeId,
const std::function< bool(QVariant)> &  iterator,
bool  skipBroken 
) const

Iterates over all existing datasets of the given types.

Parameters
skipBrokenSkip datasets that fail to load instead of thrown the exception
metaTypeIdThe QMetaType type id of the type
iteratorAn iterator function that is called for every dataset of the given type
Exceptions
LocalStoreExceptionIn case of an internal error

Semantics of the iterator:

  • Parameter 1: The loaded dataset
  • Returns: true to continue the iteration, false to prematurely abort it
See also
DataStore::search, DataStore::keys, DataStore::loadAll

◆ iterate() [3/3]

template<typename T >
QtDataSync::DataStore::iterate ( const std::function< bool(T)> &  iterator,
bool  skipBroken = false 
) const

Iterates over all existing datasets of the given types.

Template Parameters
TThe type to be iterated over
Parameters
iteratorAn iterator function that is called for every dataset of the given type
skipBrokenSkip datasets that fail to load instead of thrown the exception
Exceptions
LocalStoreExceptionIn case of an internal error

Semantics of the iterator:

  • Parameter 1: The loaded dataset
  • Returns: true to continue the iteration, false to prematurely abort it
See also
DataStore::search, DataStore::keys, DataStore::loadAll

Definition at line 343 of file datastore.h.

◆ keys() [1/3]

QtDataSync::DataStore::keys ( int  metaTypeId) const

Returns all saved keys for the given type.

Parameters
metaTypeIdThe QMetaType type id of the type
Returns
A list of all keys stored for the given type
Exceptions
LocalStoreExceptionIn case of an internal error
See also
DataStore::count, DataStore::loadAll, DataStore::search, DataStore::load

◆ keys() [2/3]

template<typename T >
QtDataSync::DataStore::keys ( ) const

Returns all saved keys for the given type.

Template Parameters
TThe type to load keys for
Returns
A list of all keys stored for the given type
Exceptions
LocalStoreExceptionIn case of an internal error
See also
DataStore::count, DataStore::loadAll, DataStore::search, DataStore::load

Definition at line 250 of file datastore.h.

◆ keys() [3/3]

template<typename T , typename K >
QList< K > QtDataSync::DataStore::keys ( ) const

Returns all saved keys for the given type.

Template Parameters
KThe type of the key to be returned as list
TThe type to load keys for
Returns
A list of all keys stored for the given type
Exceptions
LocalStoreExceptionIn case of an internal error
See also
DataStore::count, DataStore::loadAll, DataStore::search, DataStore::load
Note
The given type K must be convertible from a QString

Definition at line 257 of file datastore.h.

◆ load() [1/4]

QtDataSync::DataStore::load ( int  metaTypeId,
const QString key 
) const

Loads the dataset with the given key for the given type.

Parameters
metaTypeIdThe QMetaType type id of the type
keyThe key of the dataset to be loaded
Returns
The dataset that was found for the given type and key
Exceptions
NoDataExceptionIn case no dataset for the given type and key was found
LocalStoreExceptionIn case of an internal error
See also
DataStore::loadAll, DataStore::keys, DataStore::iterate

◆ load() [2/4]

QtDataSync::DataStore::load ( int  metaTypeId,
const QVariant key 
) const
inline

Loads the dataset with the given key for the given type.

Parameters
metaTypeIdThe QMetaType type id of the type
keyThe key of the dataset to be loaded
Returns
The dataset that was found for the given type and key
Exceptions
NoDataExceptionIn case no dataset for the given type and key was found
LocalStoreExceptionIn case of an internal error
See also
DataStore::loadAll, DataStore::keys, DataStore::iterate
Note
The given QVariant must be convertible to a QString

Definition at line 62 of file datastore.h.

◆ load() [3/4]

template<typename T >
QtDataSync::DataStore::load ( const QString key) const

Loads the dataset with the given key for the given type.

Template Parameters
TThe type to load the dataset for
Parameters
keyThe key of the dataset to be loaded
Returns
The dataset that was found for the given type and key
Exceptions
NoDataExceptionIn case no dataset for the given type and key was found
LocalStoreExceptionIn case of an internal error
See also
DataStore::loadAll, DataStore::keys, DataStore::iterate

Definition at line 291 of file datastore.h.

◆ load() [4/4]

template<typename T , typename K >
QtDataSync::DataStore::load ( const K &  key) const

Loads the dataset with the given key for the given type.

Template Parameters
KThe type of the key to be returned as list
TThe type to load the dataset for
Parameters
keyThe key of the dataset to be loaded
Returns
The dataset that was found for the given type and key
Exceptions
NoDataExceptionIn case no dataset for the given type and key was found
LocalStoreExceptionIn case of an internal error
See also
DataStore::loadAll, DataStore::keys, DataStore::iterate
Note
The given type K must be convertible to a QString

Definition at line 298 of file datastore.h.

◆ loadAll() [1/2]

QtDataSync::DataStore::loadAll ( int  metaTypeId) const

Loads all existing datasets for the given type.

Parameters
metaTypeIdThe QMetaType type id of the type
Returns
A list of all datasets stored for the given type
Exceptions
LocalStoreExceptionIn case of an internal error
Attention
Depending on how many data is stored for a given type, this method can take long to return and cosume very much memory. For most situations however, this is not the case
See also
DataStore::iterate, DataStore::search, DataStore::load, DataStore::keys

◆ loadAll() [2/2]

template<typename T >
QtDataSync::DataStore::loadAll ( ) const

Loads all existing datasets for the given type.

Template Parameters
TThe type to load the datasets for
Returns
A list of all datasets stored for the given type
Exceptions
LocalStoreExceptionIn case of an internal error
Attention
Depending on how many data is stored for a given type, this method can take long to return and cosume very much memory. For most situations however, this is not the case
See also
DataStore::iterate, DataStore::search, DataStore::load, DataStore::keys

Definition at line 267 of file datastore.h.

◆ remove() [1/4]

QtDataSync::DataStore::remove ( int  metaTypeId,
const QString key 
)

Removes the dataset with the given key for the given type.

Parameters
metaTypeIdThe QMetaType type id of the type
keyThe key of the dataset to be removed
Returns
true in case the dataset was removed, false if it did not exist
Exceptions
LocalStoreExceptionIn case of an internal error
See also
DataStore::save, DataStore::clear, DataStore::load, DataStore::dataChanged

◆ remove() [2/4]

QtDataSync::DataStore::remove ( int  metaTypeId,
const QVariant key 
)
inline

Removes the dataset with the given key for the given type.

Parameters
metaTypeIdThe QMetaType type id of the type
keyThe key of the dataset to be removed
Returns
true in case the dataset was removed, false if it did not exist
Exceptions
LocalStoreExceptionIn case of an internal error
See also
DataStore::save, DataStore::clear, DataStore::load, DataStore::dataChanged
Note
The given QVariant must be convertible to a QString

Definition at line 70 of file datastore.h.

◆ remove() [3/4]

template<typename T >
QtDataSync::DataStore::remove ( const QString key)

Removes the dataset with the given key for the given type.

Template Parameters
TThe type to remove the dataset from
Parameters
keyThe key of the dataset to be removed
Returns
true in case the dataset was removed, false if it did not exist
Exceptions
LocalStoreExceptionIn case of an internal error
See also
DataStore::save, DataStore::clear, DataStore::load, DataStore::dataChanged

Definition at line 312 of file datastore.h.

◆ remove() [4/4]

template<typename T , typename K >
QtDataSync::DataStore::remove ( const K &  key)

Removes the dataset with the given key for the given type.

Template Parameters
KThe type of the key of the dataset to be removed
TThe type to remove the dataset from
Parameters
keyThe key of the dataset to be removed
Returns
true in case the dataset was removed, false if it did not exist
Exceptions
LocalStoreExceptionIn case of an internal error
See also
DataStore::save, DataStore::clear, DataStore::load, DataStore::dataChanged
Note
The given type K must be convertible to a QString

Definition at line 319 of file datastore.h.

◆ save() [1/2]

QtDataSync::DataStore::save ( int  metaTypeId,
QVariant  value 
)

Saves the given dataset in the store.

Parameters
metaTypeIdThe QMetaType type id of the type
valueThe dataset to be stored
Exceptions
InvalidDataExceptionIn case the given type cannot be stored
LocalStoreExceptionIn case of an internal error
See also
DataStore::remove, DataStore::load, DataStore::dataChanged

◆ save() [2/2]

template<typename T >
QtDataSync::DataStore::save ( const T &  value)

Saves the given dataset in the store.

Template Parameters
TThe type to load the dataset for
Parameters
valueThe dataset to be stored
Exceptions
InvalidDataExceptionIn case the given type cannot be stored
LocalStoreExceptionIn case of an internal error
See also
DataStore::remove, DataStore::load, DataStore::dataChanged

Definition at line 305 of file datastore.h.

◆ search() [1/2]

QtDataSync::DataStore::search ( int  metaTypeId,
const QString query,
SearchMode  mode = RegexpMode 
) const

Searches the store for datasets of the given type where the key matches the query.

Parameters
metaTypeIdThe QMetaType type id of the type
queryA search query to be used to find fitting datasets. Format depends on mode
modeSpecifies how to interpret the search query See DataStore::SearchMode documentation
Returns
A list with all datasets that keys matched the search query for the given type
Exceptions
LocalStoreExceptionIn case of an internal error
See also
DataStore::SearchMode, DataStore::load, DataStore::keys, DataStore::loadAll

◆ search() [2/2]

template<typename T >
QtDataSync::DataStore::search ( const QString query,
SearchMode  mode = RegexpMode 
) const

Searches the store for datasets of the given type where the key matches the query.

Template Parameters
TThe type to be searched for datasets
Parameters
queryA search query to be used to find fitting datasets. Format depends on mode
modeSpecifies how to interpret the search query See DataStore::SearchMode documentation
Returns
A list with all datasets that keys matched the search query for the given type
Exceptions
LocalStoreExceptionIn case of an internal error
See also
DataStore::SearchMode, DataStore::load, DataStore::keys, DataStore::loadAll

Definition at line 333 of file datastore.h.

◆ setupName()

QtDataSync::DataStore::setupName ( ) const

Returns the name of the setup this class operates on.

Returns
The name of the setup
See also
QtDataSync::Setup

◆ update() [1/2]

QtDataSync::DataStore::update ( int  metaTypeId,
QObject object 
) const

Loads the dataset with the given key for the given type into the existing object by updating it's properties.

Parameters
metaTypeIdThe QMetaType type id of the type. Must be the id of a type that extends QObject and is a pointer
objectA pointer to the object to load the data into
Exceptions
NoDataExceptionIn case no dataset for the given type and key was found
InvalidDataExceptionIn case the given type cannot be stored
LocalStoreExceptionIn case of an internal error

This method extracts the key from the passed object and uses load() to load the data. Then it simply updates all the objects properties to the values that have been loaded. This way you can load changes for an object from the store without having to exchange the pointer. In addition, all change signals for updated properties will be emitted.

See also
DataStore::load, DataStore::save, DataStore::dataChanged

◆ update() [2/2]

template<typename T >
QtDataSync::DataStore::update ( object) const

Loads the dataset with the given key for the given type into the existing object by updating it's properties.

Template Parameters
TThe type to load the dataset for. Must extend QObject and be a pointer
Parameters
objectA pointer to the object to load the data into
Exceptions
NoDataExceptionIn case no dataset for the given type and key was found
InvalidDataExceptionIn case the given type cannot be stored
LocalStoreExceptionIn case of an internal error

This method extracts the key from the passed object and uses load() to load the data. Then it simply updates all the objects properties to the values that have been loaded. This way you can load changes for an object from the store without having to exchange the pointer. In addition, all change signals for updated properties will be emitted.

See also
DataStore::load, DataStore::save, DataStore::dataChanged

Definition at line 326 of file datastore.h.


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