Remoto - VFS
|
A subclass of VFS_datastore_cache_entry, used for mongo database access. More...
#include <VFS_mongo.h>
Public Member Functions | |
VFS_mongo_cache_entry (VFS_mongo *mongo, QString path, bool debug, int flushInterval, int expireInterval, bool create=false, bool container=false, QJsonObject createData=QJsonObject()) | |
virtual | ~VFS_mongo_cache_entry () |
VFS_mongo_cache_entry destructor. More... | |
virtual bool | isContainer () |
Return the container-ness of this entry. More... | |
virtual bool | valid (QString &reason) |
If the file or directory does not exist or is not readable, _valid is set to false. More... | |
Public Member Functions inherited from VFS_datastore_cache_entry | |
VFS_datastore_cache_entry (bool debug, int flushInterval, int expireInterval, bool raw=false) | |
Construct the cache entry. More... | |
virtual | ~VFS_datastore_cache_entry () |
Destroy the cache entry. More... | |
virtual QJsonDocument | getData () |
Return the data from an entry. More... | |
virtual QByteArray | getRawData () |
Return the data from an entry. More... | |
virtual void | setData (QByteArray data) |
Write raw data to the entry. More... | |
virtual void | setData (QJsonObject json) |
Write data to the entry. More... | |
quint64 | size () |
Protected Member Functions | |
virtual void | flush () |
Actually write the document to the database. More... | |
Protected Member Functions inherited from VFS_datastore_cache_entry | |
virtual void | touch () |
Reset the expiration timer. More... | |
Protected Attributes | |
bool | _container |
The entry is a container. More... | |
VFS_mongo * | _mongo |
The VFS_mongo instance that owns this item's cache. More... | |
QString | _path |
The path associated with this cache entry. More... | |
Protected Attributes inherited from VFS_datastore_cache_entry | |
QJsonDocument | _data |
The actual cache data. More... | |
bool | _debug |
Debug flag, for verbose output. More... | |
bool | _dirty |
Changes have occurred but they are not commited to storage yet. More... | |
int | _expireID |
Timer ID for expire events. More... | |
int | _expireInterval |
Expire interval, in milliseconds. More... | |
QBasicTimer | _expireTimer |
The expiration timer. More... | |
int | _flushID |
Timer ID for flush events. More... | |
int | _flushInterval |
Flush interval, in milliseconds. More... | |
bool | _raw |
A convenience flag used in subclasses. Not used by this class. More... | |
QByteArray | _rawData |
Raw binary data. Used if _raw=true. More... | |
QString | _reason |
The reason this may be invalid. Set by a subclass. More... | |
quint64 | _size |
The size of the data. Always initialized to zero. Must be set in a subclass. More... | |
bool | _valid |
Defaults to false. A subclass will determine if _valid is true, like for instance if an underlying file doesn't exist. More... | |
Friends | |
class | VFS_mongo |
Additional Inherited Members | |
Public Slots inherited from VFS_datastore_cache_entry | |
virtual void | timerEvent (QTimerEvent *e) |
Either a flush or expire has happened. More... | |
Signals inherited from VFS_datastore_cache_entry | |
void | expired (VFS_datastore_cache_entry *) |
Signal emitted when a cache entry has expired and is no longer in use. More... | |
void | touched () |
Signal emitted when a cache entry has made a change and should climb the cache queue. More... | |
Public Attributes inherited from VFS_datastore_cache_entry | |
QString | _key |
The cache entry key. More... | |
A subclass of VFS_datastore_cache_entry, used for mongo database access.
Definition at line 19 of file VFS_mongo.h.
|
explicit |
mongo | The VFS_mongo instance owning the cache of this object |
path | The path to database information, which may be a collection or a query or a single entry, or empty. |
debug | Verbose debug mode |
flushInterval | Interval to flush to database, in milliseconds. |
expireInterval | Interval to expire cache entries, in milliseconds. |
create | If an entry with the path doesn't exist, create it. |
container | If the entry is meant to be a container |
createData | If creating, use this data to initialize it. |
The mongocxx driver makes use of exceptions, which makes failures in this funtion a bit tricky to read.
This method will catch exceptions and set _vaild and _dirty as needed.
Definition at line 47 of file VFS_mongo.cpp.
|
virtual |
VFS_mongo_cache_entry destructor.
Will call flush() if _dirty and _valid are true.
Definition at line 143 of file VFS_mongo.cpp.
|
protectedvirtual |
Actually write the document to the database.
If the entry is not _dirty, this immediately returns. If data cannot be written to disk, the entry is left _dirty and a _reason is recorded, and a VFS::CRITICAL() message is sent, on suspicion that the disk is full, the database is offline, or some other bad thing has happened.
On write success, _dirty is set to false, and the _size of the entry is updated.
Implements VFS_datastore_cache_entry.
Definition at line 191 of file VFS_mongo.cpp.
|
virtual |
Return the container-ness of this entry.
_container
Definition at line 172 of file VFS_mongo.cpp.
|
virtual |
If the file or directory does not exist or is not readable, _valid is set to false.
reason | If invalid, the reason will be written to this string. |
Reimplemented from VFS_datastore_cache_entry.
Definition at line 159 of file VFS_mongo.cpp.
|
friend |
Definition at line 23 of file VFS_mongo.h.
|
protected |
The entry is a container.
Definition at line 35 of file VFS_mongo.h.
|
protected |
The VFS_mongo instance that owns this item's cache.
Definition at line 33 of file VFS_mongo.h.
|
protected |
The path associated with this cache entry.
Definition at line 34 of file VFS_mongo.h.