1 #ifndef VFS_DATASTORE_H
2 #define VFS_DATASTORE_H
6 #include <QJsonDocument>
20 virtual void setData(QJsonObject json);
21 virtual QJsonDocument
getData();
23 virtual void setData(QByteArray data);
29 virtual bool valid(QString &reason);
96 static QJsonObject
applyJsonDiff(QJsonObject obj, QJsonObject
diff, QString trace=
"", QString user=
"server");
97 static QString
applyDeltaDiff(QString data, QJsonObject delta, QString trace=
"", QString user=
"server");
A pure virtual class which must be subclassed for data storage.
quint64 _size
The size of the data. Always initialized to zero. Must be set in a subclass.
virtual bool valid(QString &reason)
virtual void setData(QJsonObject json)
Write data to the entry.
virtual ~VFS_datastore_cache_entry()
Destroy the cache entry.
void touched()
Signal emitted when a cache entry has made a change and should climb the cache queue.
virtual QByteArray getRawData()
Return the data from an entry.
QString _reason
The reason this may be invalid. Set by a subclass.
bool _debug
Debug flag, for verbose output.
void expired(VFS_datastore_cache_entry *)
Signal emitted when a cache entry has expired and is no longer in use.
int _expireInterval
Expire interval, in milliseconds.
QByteArray _rawData
Raw binary data. Used if _raw=true.
virtual QJsonDocument getData()
Return the data from an entry.
bool _valid
Defaults to false. A subclass will determine if _valid is true, like for instance if an underlying fi...
bool _dirty
Changes have occurred but they are not commited to storage yet.
QBasicTimer _expireTimer
The expiration timer.
QString _key
The cache entry key.
virtual void touch()
Reset the expiration timer.
QJsonDocument _data
The actual cache data.
int _flushID
Timer ID for flush events.
virtual void timerEvent(QTimerEvent *e)
Either a flush or expire has happened.
bool _raw
A convenience flag used in subclasses. Not used by this class.
int _expireID
Timer ID for expire events.
int _flushInterval
Flush interval, in milliseconds.
virtual void flush()=0
A pure virtual function that must be overridden in subclasses. This is the function that actually com...
VFS_datastore_cache_entry(bool debug, int flushInterval, int expireInterval, bool raw=false)
Construct the cache entry.
A subclass of QCache and QObject.
void expired(VFS_datastore_cache_entry *)
A cache entry has exipred.
bool insert(const QString &key, VFS_datastore_cache_entry *object)
Insert a new entry.
virtual ~VFS_datastore_cache()
static const quint64 DEFAULT_DATACACHE_SIZE
The default size to create a cache. Defaults to 100mb.
VFS_datastore_cache(quint64 size)
void touched()
A cache entry has been touched.
A base class for creating storage nodes in VFS.
VFS_datastore_cache _cache
The data cache.
virtual bool isContainer()
All datastore subclasses are containers.
static QString applyDeltaDiff(QString data, QJsonObject delta, QString trace="", QString user="server")
Apply a delta diff to a json object.
VFS_datastore(quint64 size, bool debug=false)
static QJsonObject applyJsonDiff(QJsonObject obj, QJsonObject diff, QString trace="", QString user="server")
Apply a json diff to a json object.
virtual QString reportDetails()
Report the current cache usage.
virtual VFS_node * find(VFS_request *r)
VFS_node is the base class from which all other VFS_node classes derive.
void diff(VFS_node *origin, VFS_request *t)
Emit a diff, which will trigger notifySubscribers() for a mounted node.
The base class for all requests between nodes.