swift
Loading...
Searching...
No Matches
swift::core::db::CDatabaseReader Class Referenceabstract

Specialized version of threaded reader for DB data. More...

#include <databasereader.h>

Inheritance diagram for swift::core::db::CDatabaseReader:
[legend]

Classes

struct  HeaderResponse
 Header response part. More...
struct  JsonDatastoreResponse
 Response from our database (depending on JSON DB backend generates). More...

Signals

void swiftDbDataRead (bool success)
 DB have been read.
void dataRead (swift::misc::network::CEntityFlags::Entity entities, swift::misc::network::CEntityFlags::ReadState state, int number, const QUrl &url)
 Combined read signal.
void sharedFileHeaderRead (swift::misc::network::CEntityFlags::Entity entity, const QString &fileName, bool success)
 Header of shared file read.
void databaseReaderMessages (const swift::misc::CStatusMessageList &messages)
 Database reader messages.
void entityDownloadProgress (swift::misc::network::CEntityFlags::Entity entity, int logId, int progress, qint64 current, qint64 max, const QUrl &url)
 Download progress for an entity.
Signals inherited from swift::misc::CWorkerBase
void aboutToStart ()
 Emitted when the task is about to start.
void finished ()
 Emitted when the task is finished.

Public Member Functions

void readInBackgroundThread (swift::misc::network::CEntityFlags::Entity entities, const QDateTime &newerThan)
 Start reading in own thread.
swift::misc::network::CEntityFlags::Entity triggerLoadingDirectlyFromDb (swift::misc::network::CEntityFlags::Entity entities, const QDateTime &newerThan)
 Start loading from DB in own thread.
swift::misc::network::CEntityFlags::Entity triggerLoadingDirectlyFromSharedFiles (swift::misc::network::CEntityFlags::Entity entities, bool checkCacheTsUpfront)
 Start loading from shared files in own thread.
bool hasReceivedOkReply () const
 Has received Ok response from server at least once?
bool hasReceivedOkReply (QString &message) const
 Has received Ok response from server? A message why connect failed can be obtained.
bool hasReceivedFirstReply () const
 Has received 1st reply?
virtual swift::misc::network::CEntityFlags::Entity getSupportedEntities () const =0
 Supported entities by this reader.
QString getSupportedEntitiesAsString () const
 Supported entities as string.
swift::misc::network::CEntityFlags::Entity maskBySupportedEntities (swift::misc::network::CEntityFlags::Entity entities) const
 Mask by supported entities.
bool supportsAnyOfEntities (swift::misc::network::CEntityFlags::Entity entities) const
 Is any of the given entities supported here by this reader.
virtual QDateTime getCacheTimestamp (swift::misc::network::CEntityFlags::Entity entity) const =0
 Get cache timestamp.
bool hasCacheTimestampNewerThan (swift::misc::network::CEntityFlags::Entity entity, const QDateTime &threshold) const
 Has entity a valid and newer timestamp.
virtual int getCacheCount (swift::misc::network::CEntityFlags::Entity entity) const =0
 Cache`s number of entities.
virtual swift::misc::network::CEntityFlags::Entity getEntitiesWithCacheCount () const =0
 Entities already having data in cache.
virtual swift::misc::network::CEntityFlags::Entity getEntitiesWithCacheTimestampNewerThan (const QDateTime &threshold) const =0
 Entities already having data in cache (based on timestamp assumption).
bool hasDbInfoObjects () const
 DB info objects available?
bool hasSharedInfoObjects () const
 Shared info objects available?
bool hasSharedFileHeader (const swift::misc::network::CEntityFlags::Entity entity) const
 Header of shared file read (for single entity)?
bool hasSharedFileHeaders (const swift::misc::network::CEntityFlags::Entity entities) const
 Headers of shared file read (for single entity)?
QDateTime getLatestEntityTimestampFromDbInfoObjects (swift::misc::network::CEntityFlags::Entity entity) const
 Obtain latest object timestamp from DB info objects.
QDateTime getLatestEntityTimestampFromSharedInfoObjects (swift::misc::network::CEntityFlags::Entity entity) const
 Obtain latest object timestamp from shared info objects.
QDateTime getLatestSharedFileHeaderTimestamp (swift::misc::network::CEntityFlags::Entity entity) const
 Header timestamp (last-modified) for shared file.
bool isSharedHeaderNewerThanCacheTimestamp (swift::misc::network::CEntityFlags::Entity entity) const
 Is the file timestamp newer than cache timestamp?
bool isSharedInfoObjectNewerThanCacheTimestamp (swift::misc::network::CEntityFlags::Entity entity) const
 Is the shared info timestamp newer than cache timestamp?
swift::misc::network::CEntityFlags::Entity getEntitesWithNewerHeaderTimestamp (swift::misc::network::CEntityFlags::Entity entities) const
 Those entities where the timestamp of the header is newer than the cache timestamp.
swift::misc::network::CEntityFlags::Entity getEntitesWithNewerSharedInfoObject (swift::misc::network::CEntityFlags::Entity entities) const
 Those entities where the timestamp of a shared info object is newer than the cache timestamp.
const QString & getStatusMessage () const
 Status message (error message).
void setSeverityNoWorkingUrl (swift::misc::CStatusMessage::StatusSeverity s)
 Severity used for log messages in case of no URLs.
swift::misc::CStatusMessageList initFromLocalResourceFiles (bool inBackground)
 Init from local resource file.
swift::misc::CStatusMessageList initFromLocalResourceFiles (swift::misc::network::CEntityFlags::Entity entities, bool inBackground)
 Init from local resource file.
virtual swift::misc::CStatusMessageList readFromJsonFiles (const QString &dir, swift::misc::network::CEntityFlags::Entity whatToRead, bool overrideNewer)=0
 Data read from local data.
virtual bool readFromJsonFilesInBackground (const QString &dir, swift::misc::network::CEntityFlags::Entity whatToRead, bool overrideNewer)=0
 Data read from local data.
Public Member Functions inherited from swift::core::CThreadedReader
 ~CThreadedReader ()=default
 Destructor.
 CThreadedReader (const CThreadedReader &)=delete
 Copy constructor.
CThreadedReader & operator= (const CThreadedReader &)=delete
 Copy assignment.
 CThreadedReader (CThreadedReader &&)=delete
 Move constructor.
CThreadedReader & operator= (CThreadedReader &&)=delete
 Move assignment.
QDateTime getUpdateTimestamp () const
 Thread safe, get update timestamp.
void setUpdateTimestamp (const QDateTime &updateTimestamp=QDateTime::currentDateTimeUtc())
 Thread safe, set update timestamp.
bool isMarkedAsFailed () const
 Is marked as read failed.
void setMarkedAsFailed (bool failed)
 Set marker for read failed.
swift::misc::network::CUrlLogList getReadLog () const
 Get the read log.
void markAsUsedInUnitTest ()
 Used in unit test.
swift::misc::network::CUrlLogList getUrlLogList () const
 Get the URL log list.
QPair< qint64, qint64 > getNetworkReplyBytes () const
 Max./current bytes.
Public Member Functions inherited from swift::misc::CContinuousWorker
 CContinuousWorker (QObject *owner, const QString &name)
 Constructor.
void start (QThread::Priority priority=QThread::InheritPriority)
 Starts a thread and moves the worker into it.
void quit () noexcept final
 Stops the thread the next time around its event loop. The thread and the worker will then be deleted.
void quitAndWait () noexcept final
 Calls quit() and blocks until the thread is finished.
bool isEnabled () const
 Enabled (running)?
const QString & getName ()
 Name of the worker.
const QObject * owner () const
 Owner of the worker.
Public Member Functions inherited from swift::misc::CWorkerBase
 ~CWorkerBase ()
 Destructor.
 CWorkerBase (const CWorkerBase &)=delete
 Copy constructor.
CWorkerBase & operator= (const CWorkerBase &)=delete
 Copy assignment.
 CWorkerBase (CWorkerBase &&)=delete
 Move constructor.
CWorkerBase & operator= (CWorkerBase &&)=delete
 Move assignment.
template<typename T, typename F>
void then (T *context, F functor)
 Connects to a functor or method which will be called when the task is finished.
template<typename F>
void then (F functor)
 Connects to a functor which will be called when the task is finished.
bool isFinished () const
 Returns true if the task has finished.
template<typename F>
void doIfFinished (F functor) const
 Executes some code (in the caller's thread) if the task has finished.
template<typename F>
void doIfNotFinished (F functor) const
 Executes some code (in the caller's thread) if the task has not finished.
template<typename F1, typename F2>
void doIfFinishedElse (F1 ifFunctor, F2 elseFunctor) const
 Executes some code (in the caller's thread) if the task has finished and some different code if it has not finished.
void waitForFinished () noexcept
 Blocks until the task is finished.
void abandon () noexcept
 Notify the task that its result is no longer needed, so it can finish early.
void abandonAndWait () noexcept
 Convenience to call abandon() followed by waitForFinished().
Public Member Functions inherited from QObject
QBindable< QString > bindableObjectName ()
 QObject (QObject *parent)
 QT_NO_CONTEXTLESS_CONNECT QT_NO_CONTEXTLESS_CONNECT
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 Q_CLASSINFO (Name, Value)
 Q_EMIT Q_EMIT
 Q_ENUM (...)
 Q_ENUMS (...)
 Q_ENUM_NS (...)
 Q_FLAG (...)
 Q_FLAGS (...)
 Q_FLAG_NS (...)
 Q_GADGET Q_GADGET
 Q_GADGET_EXPORT (EXPORT_MACRO)
 Q_INTERFACES (...)
 Q_INVOKABLE Q_INVOKABLE
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 Q_NAMESPACE Q_NAMESPACE
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 Q_OBJECT Q_OBJECT
 Q_PROPERTY (...)
 Q_REVISION Q_REVISION
 Q_SET_OBJECT_NAME (Object)
 Q_SIGNAL Q_SIGNAL
 Q_SIGNALS Q_SIGNALS
 Q_SLOT Q_SLOT
 Q_SLOTS Q_SLOTS
T qobject_cast (QObject *object)
T qobject_cast (const QObject *object)
bool blockSignals (bool block)
virtual bool event (QEvent *e)
virtual bool eventFilter (QObject *watched, QEvent *event)
bool moveToThread (QThread *targetThread)
bool setProperty (const char *name, QVariant &&value)
bool setProperty (const char *name, const QVariant &value)
int startTimer (int interval, Qt::TimerType timerType)
int startTimer (std::chrono::nanoseconds interval, Qt::TimerType timerType)
void deleteLater ()
void destroyed (QObject *obj)
void installEventFilter (QObject *filterObj)
void killTimer (Qt::TimerId id)
void killTimer (int id)
void objectNameChanged (const QString &objectName)
void removeEventFilter (QObject *obj)
void setObjectName (QAnyStringView name)
void setObjectName (const QString &name)
void setParent (QObject *parent)
QList< QByteArray > dynamicPropertyNames () const const
QList< T > findChildren (QAnyStringView name, Qt::FindChildOptions options) const const
QList< T > findChildren (Qt::FindChildOptions options) const const
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
QObject * parent () const const
QString objectName () const const
QThread * thread () const const
QVariant property (const char *name) const const
T findChild (QAnyStringView name, Qt::FindChildOptions options) const const
T findChild (Qt::FindChildOptions options) const const
bool disconnect (const QObject *receiver, const char *method) const const
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
bool inherits (const char *className) const const
bool isQmlExposed () const const
bool isQuickItemType () const const
bool isWidgetType () const const
bool isWindowType () const const
bool signalsBlocked () const const
virtual const QMetaObject * metaObject () const const
const QObjectList & children () const const
void dumpObjectInfo () const const
void dumpObjectTree () const const

Static Public Member Functions

static const QStringList & getLogCategories ()
 Log categories.
Static Public Member Functions inherited from swift::core::CThreadedReader
static const QStringList & getLogCategories ()
 Log categories.
Static Public Member Functions inherited from swift::misc::CWorkerBase
static const QStringList & getLogCategories ()
 Log categories.
static const QSet< CWorkerBase * > & allWorkers ()
 All workers currently existing.
Static Public Member Functions inherited from QObject
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)
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction 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, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString tr (const char *sourceText, const char *disambiguation, int n)
bool disconnect (const QMetaObject::Connection &connection)
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)

Protected Member Functions

 CDatabaseReader (QObject *owner, const CDatabaseReaderConfigList &config, const QString &name)
 Constructor.
CDatabaseReader::JsonDatastoreResponse setStatusAndTransformReplyIntoDatastoreResponse (QNetworkReply *nwReply)
 Check if terminated or error, otherwise split into array of objects.
swift::misc::db::CDbInfoList getDbInfoObjects () const
 DB Info list (latest data timestamps from DB web service).
swift::misc::db::CDbInfoList getSharedInfoObjects () const
 Shared info list (latest data timestamps from DB web service).
CDatabaseReaderConfig getConfigForEntity (swift::misc::network::CEntityFlags::Entity entity) const
 Config for given entity.
swift::misc::network::CEntityFlags::Entity emitReadSignalPerSingleCachedEntity (swift::misc::network::CEntityFlags::Entity cachedEntities, bool onlyIfHasData)
 Split into single entity and send dataRead signal.
void emitAndLogDataRead (swift::misc::network::CEntityFlags::Entity entity, int number, const JsonDatastoreResponse &res)
 Emit signal and log when data have been read.
virtual swift::misc::network::CUrl getDbServiceBaseUrl () const =0
 Get the service URL, individual for each reader.
void logNoWorkingUrl (swift::misc::network::CEntityFlags::Entity entity)
 Log if no working URL exists, using m_noWorkingUrlSeverity.
swift::misc::network::CUrl getBaseUrl (swift::misc::db::CDbFlags::DataRetrievalModeFlag mode) const
 Base URL for mode (either a shared or DB URL).
void startReadFromBackendInBackgroundThread (swift::misc::network::CEntityFlags::Entity entities, swift::misc::db::CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan=QDateTime())
 Start reading in own thread (without config/caching).
void receivedSharedFileHeader (QNetworkReply *nwReplyPtr)
 Received a reply of a header for a shared file.
void receivedSharedFileHeaderNonClosing (QNetworkReply *nwReplyPtr)
 Received a reply of a header for a shared file.
JsonDatastoreResponse transformReplyIntoDatastoreResponse (QNetworkReply *nwReply) const
 Check if terminated or error, otherwise split into array of objects.
HeaderResponse transformReplyIntoHeaderResponse (QNetworkReply *nwReply) const
 Check if terminated or error, otherwise set header information.
bool setHeaderInfoPart (HeaderResponse &headerResponse, QNetworkReply *nwReply) const
 Set the header part.
void setReplyStatus (QNetworkReply::NetworkError status, const QString &message="")
 Feedback about connection status.
void setReplyStatus (QNetworkReply *nwReply)
 Feedback about connection status.
bool overrideCacheFromFile (bool overrideNewerOnly, const QFileInfo &fileInfo, swift::misc::network::CEntityFlags::Entity entity, swift::misc::CStatusMessageList &msgs) const
 Override cache from file.
void logParseMessage (const QString &entity, int size, int msElapsed, const JsonDatastoreResponse &response) const
 Parsing info message.
void networkReplyProgress (int logId, qint64 current, qint64 max, const QUrl &url)
 Network request progress.
Protected Member Functions inherited from swift::core::CThreadedReader
 CThreadedReader (QObject *owner, const QString &name)
 Constructor.
qint64 lastModifiedMsSinceEpoch (QNetworkReply *nwReply) const
 When was reply last modified, -1 if N/A.
void threadAssertCheck () const
 Make sure everything runs correctly in own thread.
bool didContentChange (const QString &content, int startPosition=-1)
 Stores new content hash and returns if content changed (based on hash value.
bool doWorkCheck () const
 Still enabled etc.?
QNetworkReply * getFromNetworkAndLog (const swift::misc::network::CUrl &url, const swift::misc::CSlot< void(QNetworkReply *)> &callback)
 Get request from network, and log with m_urlReadLog.
void logNetworkReplyReceived (QNetworkReply *reply)
 Network reply received, mark in m_urlReadLog.
Protected Member Functions inherited from swift::misc::CContinuousWorker
virtual void initialize ()
 Called when the thread is started.
virtual void cleanup ()
 Called when the thread is finished.
virtual void beforeQuit () noexcept
 Called before quit is called.
virtual unsigned long waitTimeoutMs () const
 Wait time for quitAndWait, 0 means not waiting.
Protected Member Functions inherited from swift::misc::CWorkerBase
 CWorkerBase ()
 Constructor.
bool isAbandoned () const
 For the task to check whether it can finish early.
bool hasStarted () const
 True if the worker has started.
void setStarted ()
 Mark the task as started.
void setFinished ()
 Mark the task as finished.
Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
virtual void connectNotify (const QMetaMethod &signal)
virtual void customEvent (QEvent *event)
virtual void disconnectNotify (const QMetaMethod &signal)
virtual void timerEvent (QTimerEvent *event)
QObject * sender () const const
bool isSignalConnected (const QMetaMethod &signal) const const
int receivers (const char *signal) const const
int senderSignalIndex () const const

Static Protected Member Functions

static const swift::misc::network::CUrl & getDbUrl ()
 DB base URL.
static QString fileNameForMode (swift::misc::network::CEntityFlags::Entity entity, swift::misc::db::CDbFlags::DataRetrievalModeFlag mode)
 File name for given mode, either php service or shared file name.
static const QString & parameterLatestTimestamp ()
 Name of latest timestamp.
static QString dateTimeToDbLatestTs (const QDateTime &ts)
 A newer than value understood by swift DB.
static QString queryLatestTimestamp (const QDateTime &ts)
 Latest timestamp query for DB.
Static Protected Member Functions inherited from swift::core::CThreadedReader
static void logInconsistentData (const swift::misc::CStatusMessage &msg, const char *funcInfo=nullptr)
 Use this to log inconsistent data.

Protected Attributes

CDatabaseReaderConfigList m_config
 DB reder configuration.
QString m_statusMessage
 Returned status message from watchdog.
bool m_1stReplyReceived = false
 Successful connection?
QReadWriteLock m_statusLock
 Lock.
QNetworkReply::NetworkError m_1stReplyStatus = QNetworkReply::UnknownServerError
 Successful connection?
QMap< swift::misc::network::CEntityFlags::Entity, HeaderResponse > m_sharedFileResponses
 file responses of the shared files
swift::misc::CStatusMessage::StatusSeverity m_severityNoWorkingUrl
 severity of message if there is no working URL
Protected Attributes inherited from swift::core::CThreadedReader
QReadWriteLock m_lock
 lock which can be used from the derived classes
std::atomic_int m_networkReplyProgress
 Progress percentage 0...100.
std::atomic_llong m_networkReplyCurrent
 current bytes
std::atomic_llong m_networkReplyMax
 max bytes

Private Member Functions

virtual void read (swift::misc::network::CEntityFlags::Entity entities, swift::misc::db::CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan)=0
 Read / re-read data file.

Cache access

Synchronize caches for given entities

virtual void synchronizeCaches (swift::misc::network::CEntityFlags::Entity entities)=0
 Admit caches for given entities.
virtual void admitCaches (swift::misc::network::CEntityFlags::Entity entities)=0
 Admit caches for given entities.
virtual void invalidateCaches (swift::misc::network::CEntityFlags::Entity entities)=0
 Invalidate the caches for given entities.
virtual bool hasChangedUrl (swift::misc::network::CEntityFlags::Entity entity, swift::misc::network::CUrl &oldUrlInfo, swift::misc::network::CUrl &newUrlInfo) const =0
 Changed URL, means the cache values have been read from elsewhere.
virtual void cacheHasChanged (swift::misc::network::CEntityFlags::Entity entities)
 Cache for given entity has changed.
static bool isChangedUrl (const swift::misc::network::CUrl &oldUrl, const swift::misc::network::CUrl &currentUrl)
 Has URL been changed? Means we load from a different server.

Additional Inherited Members

Public Types inherited from QObject
enum  TimerId
Public Attributes inherited from QObject
typedef QObjectList
 Invalid
Properties inherited from QObject
 objectName

Detailed Description

Specialized version of threaded reader for DB data.

Definition at line 37 of file databasereader.h.

Constructor & Destructor Documentation

◆ CDatabaseReader()

swift::core::db::CDatabaseReader::CDatabaseReader ( QObject * owner,
const CDatabaseReaderConfigList & config,
const QString & name )
protected

Constructor.

Definition at line 41 of file databasereader.cpp.

Member Function Documentation

◆ admitCaches()

virtual void swift::core::db::CDatabaseReader::admitCaches ( swift::misc::network::CEntityFlags::Entity entities)
protectedpure virtual

◆ cacheHasChanged()

void swift::core::db::CDatabaseReader::cacheHasChanged ( swift::misc::network::CEntityFlags::Entity entities)
protectedvirtual

Cache for given entity has changed.

Definition at line 834 of file databasereader.cpp.

◆ databaseReaderMessages

void swift::core::db::CDatabaseReader::databaseReaderMessages ( const swift::misc::CStatusMessageList & messages)
signal

Database reader messages.

Remarks
used with splash screen

◆ dataRead

void swift::core::db::CDatabaseReader::dataRead ( swift::misc::network::CEntityFlags::Entity entities,
swift::misc::network::CEntityFlags::ReadState state,
int number,
const QUrl & url )
signal

Combined read signal.

Remarks
normally in success case state for a single case, skipped cases can be reported for 1..n enities

◆ dateTimeToDbLatestTs()

QString swift::core::db::CDatabaseReader::dateTimeToDbLatestTs ( const QDateTime & ts)
staticprotected

A newer than value understood by swift DB.

See also
CDatabaseReader::parameterLatestTimestamp

Definition at line 798 of file databasereader.cpp.

◆ emitAndLogDataRead()

void swift::core::db::CDatabaseReader::emitAndLogDataRead ( swift::misc::network::CEntityFlags::Entity entity,
int number,
const JsonDatastoreResponse & res )
protected

Emit signal and log when data have been read.

Definition at line 565 of file databasereader.cpp.

◆ emitReadSignalPerSingleCachedEntity()

CEntityFlags::Entity swift::core::db::CDatabaseReader::emitReadSignalPerSingleCachedEntity ( swift::misc::network::CEntityFlags::Entity cachedEntities,
bool onlyIfHasData )
protected

Split into single entity and send dataRead signal.

Definition at line 542 of file databasereader.cpp.

◆ fileNameForMode()

QString swift::core::db::CDatabaseReader::fileNameForMode ( swift::misc::network::CEntityFlags::Entity entity,
swift::misc::db::CDbFlags::DataRetrievalModeFlag mode )
staticprotected

File name for given mode, either php service or shared file name.

Definition at line 786 of file databasereader.cpp.

◆ getBaseUrl()

CUrl swift::core::db::CDatabaseReader::getBaseUrl ( swift::misc::db::CDbFlags::DataRetrievalModeFlag mode) const
protected

Base URL for mode (either a shared or DB URL).

Definition at line 584 of file databasereader.cpp.

◆ getCacheCount()

virtual int swift::core::db::CDatabaseReader::getCacheCount ( swift::misc::network::CEntityFlags::Entity entity) const
pure virtual

Cache`s number of entities.

Remarks
this only works if the cache is admitted, DB caches are read deferred

Implemented in swift::core::db::CAirportDataReader, swift::core::db::CIcaoDataReader, swift::core::db::CInfoDataReader, and swift::core::db::CModelDataReader.

◆ getCacheTimestamp()

virtual QDateTime swift::core::db::CDatabaseReader::getCacheTimestamp ( swift::misc::network::CEntityFlags::Entity entity) const
pure virtual

◆ getConfigForEntity()

CDatabaseReaderConfig swift::core::db::CDatabaseReader::getConfigForEntity ( swift::misc::network::CEntityFlags::Entity entity) const
protected

Config for given entity.

Definition at line 537 of file databasereader.cpp.

◆ getDbInfoObjects()

CDbInfoList swift::core::db::CDatabaseReader::getDbInfoObjects ( ) const
protected

DB Info list (latest data timestamps from DB web service).

See also
swift::core::db::CInfoDataReader

Definition at line 370 of file databasereader.cpp.

◆ getDbServiceBaseUrl()

virtual swift::misc::network::CUrl swift::core::db::CDatabaseReader::getDbServiceBaseUrl ( ) const
protectedpure virtual

◆ getDbUrl()

const CUrl & swift::core::db::CDatabaseReader::getDbUrl ( )
staticprotected

DB base URL.

Definition at line 828 of file databasereader.cpp.

◆ getEntitesWithNewerHeaderTimestamp()

CEntityFlags::Entity swift::core::db::CDatabaseReader::getEntitesWithNewerHeaderTimestamp ( swift::misc::network::CEntityFlags::Entity entities) const

Those entities where the timestamp of the header is newer than the cache timestamp.

Definition at line 505 of file databasereader.cpp.

◆ getEntitesWithNewerSharedInfoObject()

CEntityFlags::Entity swift::core::db::CDatabaseReader::getEntitesWithNewerSharedInfoObject ( swift::misc::network::CEntityFlags::Entity entities) const

Those entities where the timestamp of a shared info object is newer than the cache timestamp.

Definition at line 521 of file databasereader.cpp.

◆ getEntitiesWithCacheCount()

virtual swift::misc::network::CEntityFlags::Entity swift::core::db::CDatabaseReader::getEntitiesWithCacheCount ( ) const
pure virtual

Entities already having data in cache.

Remarks
this only works if the cache is admitted, DB caches are read deferred

Implemented in swift::core::db::CAirportDataReader, swift::core::db::CIcaoDataReader, swift::core::db::CInfoDataReader, and swift::core::db::CModelDataReader.

◆ getEntitiesWithCacheTimestampNewerThan()

virtual swift::misc::network::CEntityFlags::Entity swift::core::db::CDatabaseReader::getEntitiesWithCacheTimestampNewerThan ( const QDateTime & threshold) const
pure virtual

Entities already having data in cache (based on timestamp assumption).

Remarks
unlike getEntitiesWithCacheCount() this even works when the cache is not yet admitted

Implemented in swift::core::db::CAirportDataReader, swift::core::db::CIcaoDataReader, swift::core::db::CInfoDataReader, and swift::core::db::CModelDataReader.

◆ getLatestEntityTimestampFromDbInfoObjects()

QDateTime swift::core::db::CDatabaseReader::getLatestEntityTimestampFromDbInfoObjects ( swift::misc::network::CEntityFlags::Entity entity) const

Obtain latest object timestamp from DB info objects.

See also
swift::core::db::CInfoDataReader

Definition at line 423 of file databasereader.cpp.

◆ getLatestEntityTimestampFromSharedInfoObjects()

QDateTime swift::core::db::CDatabaseReader::getLatestEntityTimestampFromSharedInfoObjects ( swift::misc::network::CEntityFlags::Entity entity) const

Obtain latest object timestamp from shared info objects.

See also
swift::core::db::CInfoDataReader

Definition at line 443 of file databasereader.cpp.

◆ getLatestSharedFileHeaderTimestamp()

QDateTime swift::core::db::CDatabaseReader::getLatestSharedFileHeaderTimestamp ( swift::misc::network::CEntityFlags::Entity entity) const

Header timestamp (last-modified) for shared file.

Deprecated
use getLatestEntityTimestampFromSharedInfoObjects

Definition at line 461 of file databasereader.cpp.

◆ getLogCategories()

const QStringList & swift::core::db::CDatabaseReader::getLogCategories ( )
static

Log categories.

Definition at line 807 of file databasereader.cpp.

◆ getSharedInfoObjects()

CDbInfoList swift::core::db::CDatabaseReader::getSharedInfoObjects ( ) const
protected

Shared info list (latest data timestamps from DB web service).

See also
swift::core::db::CInfoDataReader

Definition at line 384 of file databasereader.cpp.

◆ getStatusMessage()

const QString & swift::core::db::CDatabaseReader::getStatusMessage ( ) const

Status message (error message).

Definition at line 687 of file databasereader.cpp.

◆ getSupportedEntities()

virtual swift::misc::network::CEntityFlags::Entity swift::core::db::CDatabaseReader::getSupportedEntities ( ) const
pure virtual

◆ getSupportedEntitiesAsString()

QString swift::core::db::CDatabaseReader::getSupportedEntitiesAsString ( ) const

Supported entities as string.

Definition at line 662 of file databasereader.cpp.

◆ hasCacheTimestampNewerThan()

bool swift::core::db::CDatabaseReader::hasCacheTimestampNewerThan ( swift::misc::network::CEntityFlags::Entity entity,
const QDateTime & threshold ) const

Has entity a valid and newer timestamp.

Definition at line 677 of file databasereader.cpp.

◆ hasChangedUrl()

virtual bool swift::core::db::CDatabaseReader::hasChangedUrl ( swift::misc::network::CEntityFlags::Entity entity,
swift::misc::network::CUrl & oldUrlInfo,
swift::misc::network::CUrl & newUrlInfo ) const
protectedpure virtual

Changed URL, means the cache values have been read from elsewhere.

Remarks
testing based on swift::misc::db::CDbFlags::DbReading

Implemented in swift::core::db::CAirportDataReader, swift::core::db::CIcaoDataReader, swift::core::db::CInfoDataReader, and swift::core::db::CModelDataReader.

◆ hasDbInfoObjects()

bool swift::core::db::CDatabaseReader::hasDbInfoObjects ( ) const

DB info objects available?

Definition at line 398 of file databasereader.cpp.

◆ hasReceivedFirstReply()

bool swift::core::db::CDatabaseReader::hasReceivedFirstReply ( ) const

Has received 1st reply?

Remarks
This function is thread safe.

Definition at line 656 of file databasereader.cpp.

◆ hasReceivedOkReply() [1/2]

bool swift::core::db::CDatabaseReader::hasReceivedOkReply ( ) const

Has received Ok response from server at least once?

Remarks
This function is thread safe.

Definition at line 643 of file databasereader.cpp.

◆ hasReceivedOkReply() [2/2]

bool swift::core::db::CDatabaseReader::hasReceivedOkReply ( QString & message) const

Has received Ok response from server? A message why connect failed can be obtained.

Remarks
This function is thread safe.

Definition at line 649 of file databasereader.cpp.

◆ hasSharedFileHeader()

bool swift::core::db::CDatabaseReader::hasSharedFileHeader ( const swift::misc::network::CEntityFlags::Entity entity) const

Header of shared file read (for single entity)?

Definition at line 402 of file databasereader.cpp.

◆ hasSharedFileHeaders()

bool swift::core::db::CDatabaseReader::hasSharedFileHeaders ( const swift::misc::network::CEntityFlags::Entity entities) const

Headers of shared file read (for single entity)?

Definition at line 408 of file databasereader.cpp.

◆ hasSharedInfoObjects()

bool swift::core::db::CDatabaseReader::hasSharedInfoObjects ( ) const

Shared info objects available?

Definition at line 400 of file databasereader.cpp.

◆ initFromLocalResourceFiles() [1/2]

CStatusMessageList swift::core::db::CDatabaseReader::initFromLocalResourceFiles ( bool inBackground)

Init from local resource file.

Remarks
normally used after installation for a 1st time init

Definition at line 689 of file databasereader.cpp.

◆ initFromLocalResourceFiles() [2/2]

swift::misc::CStatusMessageList swift::core::db::CDatabaseReader::initFromLocalResourceFiles ( swift::misc::network::CEntityFlags::Entity entities,
bool inBackground )

Init from local resource file.

Remarks
normally used after installation for a 1st time init

◆ invalidateCaches()

virtual void swift::core::db::CDatabaseReader::invalidateCaches ( swift::misc::network::CEntityFlags::Entity entities)
protectedpure virtual

◆ isChangedUrl()

bool swift::core::db::CDatabaseReader::isChangedUrl ( const swift::misc::network::CUrl & oldUrl,
const swift::misc::network::CUrl & currentUrl )
staticprotected

Has URL been changed? Means we load from a different server.

Definition at line 600 of file databasereader.cpp.

◆ isSharedHeaderNewerThanCacheTimestamp()

bool swift::core::db::CDatabaseReader::isSharedHeaderNewerThanCacheTimestamp ( swift::misc::network::CEntityFlags::Entity entity) const

Is the file timestamp newer than cache timestamp?

Deprecated
use isSharedInfoNewerThanCacheTimestamp

Definition at line 471 of file databasereader.cpp.

◆ isSharedInfoObjectNewerThanCacheTimestamp()

bool swift::core::db::CDatabaseReader::isSharedInfoObjectNewerThanCacheTimestamp ( swift::misc::network::CEntityFlags::Entity entity) const

Is the shared info timestamp newer than cache timestamp?

Definition at line 488 of file databasereader.cpp.

◆ logNoWorkingUrl()

void swift::core::db::CDatabaseReader::logNoWorkingUrl ( swift::misc::network::CEntityFlags::Entity entity)
protected

Log if no working URL exists, using m_noWorkingUrlSeverity.

Definition at line 577 of file databasereader.cpp.

◆ logParseMessage()

void swift::core::db::CDatabaseReader::logParseMessage ( const QString & entity,
int size,
int msElapsed,
const JsonDatastoreResponse & response ) const
protected

Parsing info message.

Definition at line 767 of file databasereader.cpp.

◆ maskBySupportedEntities()

CEntityFlags::Entity swift::core::db::CDatabaseReader::maskBySupportedEntities ( swift::misc::network::CEntityFlags::Entity entities) const

Mask by supported entities.

Definition at line 667 of file databasereader.cpp.

◆ networkReplyProgress()

void swift::core::db::CDatabaseReader::networkReplyProgress ( int logId,
qint64 current,
qint64 max,
const QUrl & url )
protectedvirtual

Network request progress.

Reimplemented from swift::core::CThreadedReader.

Definition at line 774 of file databasereader.cpp.

◆ overrideCacheFromFile()

bool swift::core::db::CDatabaseReader::overrideCacheFromFile ( bool overrideNewerOnly,
const QFileInfo & fileInfo,
swift::misc::network::CEntityFlags::Entity entity,
swift::misc::CStatusMessageList & msgs ) const
protected

Override cache from file.

Remarks
This function is thread safe.

Definition at line 734 of file databasereader.cpp.

◆ parameterLatestTimestamp()

const QString & swift::core::db::CDatabaseReader::parameterLatestTimestamp ( )
staticprotected

Name of latest timestamp.

Definition at line 815 of file databasereader.cpp.

◆ queryLatestTimestamp()

QString swift::core::db::CDatabaseReader::queryLatestTimestamp ( const QDateTime & ts)
staticprotected

Latest timestamp query for DB.

Definition at line 821 of file databasereader.cpp.

◆ readFromJsonFiles()

virtual swift::misc::CStatusMessageList swift::core::db::CDatabaseReader::readFromJsonFiles ( const QString & dir,
swift::misc::network::CEntityFlags::Entity whatToRead,
bool overrideNewer )
pure virtual

◆ readFromJsonFilesInBackground()

virtual bool swift::core::db::CDatabaseReader::readFromJsonFilesInBackground ( const QString & dir,
swift::misc::network::CEntityFlags::Entity whatToRead,
bool overrideNewer )
pure virtual

◆ readInBackgroundThread()

void swift::core::db::CDatabaseReader::readInBackgroundThread ( swift::misc::network::CEntityFlags::Entity entities,
const QDateTime & newerThan )

Start reading in own thread.

Remarks
uses caches, info objects

Definition at line 45 of file databasereader.cpp.

◆ receivedSharedFileHeader()

void swift::core::db::CDatabaseReader::receivedSharedFileHeader ( QNetworkReply * nwReplyPtr)
protected

Received a reply of a header for a shared file.

Definition at line 613 of file databasereader.cpp.

◆ receivedSharedFileHeaderNonClosing()

void swift::core::db::CDatabaseReader::receivedSharedFileHeaderNonClosing ( QNetworkReply * nwReplyPtr)
protected

Received a reply of a header for a shared file.

Definition at line 626 of file databasereader.cpp.

◆ setHeaderInfoPart()

bool swift::core::db::CDatabaseReader::setHeaderInfoPart ( CDatabaseReader::HeaderResponse & headerResponse,
QNetworkReply * nwReply ) const
protected

Set the header part.

Definition at line 319 of file databasereader.cpp.

◆ setReplyStatus() [1/2]

void swift::core::db::CDatabaseReader::setReplyStatus ( QNetworkReply * nwReply)
protected

Feedback about connection status.

Remarks
This function is thread safe.

Definition at line 724 of file databasereader.cpp.

◆ setReplyStatus() [2/2]

void swift::core::db::CDatabaseReader::setReplyStatus ( QNetworkReply::NetworkError status,
const QString & message = "" )
protected

Feedback about connection status.

Remarks
This function is thread safe.

Definition at line 716 of file databasereader.cpp.

◆ setSeverityNoWorkingUrl()

void swift::core::db::CDatabaseReader::setSeverityNoWorkingUrl ( swift::misc::CStatusMessage::StatusSeverity s)
inline

Severity used for log messages in case of no URLs.

Definition at line 275 of file databasereader.h.

◆ setStatusAndTransformReplyIntoDatastoreResponse()

CDatabaseReader::JsonDatastoreResponse swift::core::db::CDatabaseReader::setStatusAndTransformReplyIntoDatastoreResponse ( QNetworkReply * nwReply)
protected

Check if terminated or error, otherwise split into array of objects.

Definition at line 351 of file databasereader.cpp.

◆ startReadFromBackendInBackgroundThread()

void swift::core::db::CDatabaseReader::startReadFromBackendInBackgroundThread ( swift::misc::network::CEntityFlags::Entity entities,
swift::misc::db::CDbFlags::DataRetrievalModeFlag mode,
const QDateTime & newerThan = QDateTime() )
protected

Start reading in own thread (without config/caching).

Remarks
can handle DB or shared file reads

Definition at line 265 of file databasereader.cpp.

◆ supportsAnyOfEntities()

bool swift::core::db::CDatabaseReader::supportsAnyOfEntities ( swift::misc::network::CEntityFlags::Entity entities) const

Is any of the given entities supported here by this reader.

Definition at line 672 of file databasereader.cpp.

◆ synchronizeCaches()

virtual void swift::core::db::CDatabaseReader::synchronizeCaches ( swift::misc::network::CEntityFlags::Entity entities)
protectedpure virtual

◆ transformReplyIntoDatastoreResponse()

CDatabaseReader::JsonDatastoreResponse swift::core::db::CDatabaseReader::transformReplyIntoDatastoreResponse ( QNetworkReply * nwReply) const
protected

Check if terminated or error, otherwise split into array of objects.

Definition at line 288 of file databasereader.cpp.

◆ transformReplyIntoHeaderResponse()

CDatabaseReader::HeaderResponse swift::core::db::CDatabaseReader::transformReplyIntoHeaderResponse ( QNetworkReply * nwReply) const
protected

Check if terminated or error, otherwise set header information.

Definition at line 311 of file databasereader.cpp.

◆ triggerLoadingDirectlyFromDb()

CEntityFlags::Entity swift::core::db::CDatabaseReader::triggerLoadingDirectlyFromDb ( swift::misc::network::CEntityFlags::Entity entities,
const QDateTime & newerThan )

Start loading from DB in own thread.

Remarks
bypass caches/config

Definition at line 214 of file databasereader.cpp.

◆ triggerLoadingDirectlyFromSharedFiles()

CEntityFlags::Entity swift::core::db::CDatabaseReader::triggerLoadingDirectlyFromSharedFiles ( swift::misc::network::CEntityFlags::Entity entities,
bool checkCacheTsUpfront )

Start loading from shared files in own thread.

Remarks
bypass caches/config

Definition at line 221 of file databasereader.cpp.

Member Data Documentation

◆ m_1stReplyReceived

bool swift::core::db::CDatabaseReader::m_1stReplyReceived = false
protected

Successful connection?

Does not mean data / authorizations are correct

Definition at line 328 of file databasereader.h.

◆ m_1stReplyStatus

QNetworkReply::NetworkError swift::core::db::CDatabaseReader::m_1stReplyStatus = QNetworkReply::UnknownServerError
protected

Successful connection?

Definition at line 330 of file databasereader.h.

◆ m_config

CDatabaseReaderConfigList swift::core::db::CDatabaseReader::m_config
protected

DB reder configuration.

Definition at line 326 of file databasereader.h.

◆ m_severityNoWorkingUrl

swift::misc::CStatusMessage::StatusSeverity swift::core::db::CDatabaseReader::m_severityNoWorkingUrl
protected
Initial value:

severity of message if there is no working URL

Definition at line 333 of file databasereader.h.

◆ m_sharedFileResponses

QMap<swift::misc::network::CEntityFlags::Entity, HeaderResponse> swift::core::db::CDatabaseReader::m_sharedFileResponses
protected

file responses of the shared files

Definition at line 332 of file databasereader.h.

◆ m_statusLock

QReadWriteLock swift::core::db::CDatabaseReader::m_statusLock
mutableprotected

Lock.

Definition at line 329 of file databasereader.h.

◆ m_statusMessage

QString swift::core::db::CDatabaseReader::m_statusMessage
protected

Returned status message from watchdog.

Definition at line 327 of file databasereader.h.


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