refs #485, Restricted<T>

This commit is contained in:
Klaus Basan
2016-03-13 19:37:26 +00:00
committed by Mathew Sutcliffe
parent 18a907086d
commit c36028ca9c
8 changed files with 47 additions and 20 deletions

View File

@@ -42,6 +42,7 @@ BlackCore::CApplication *sApp = nullptr; // set by constructor
namespace BlackCore
{
CApplication::CApplication(const QString &applicationName) :
m_cookieManager( {}, this),
m_applicationName(applicationName),
m_coreFacadeConfig(CCoreFacadeConfig::allEmpty())
{
@@ -450,7 +451,7 @@ namespace BlackCore
{
CLogMessage(this).info("Will start web data services now");
this->m_webDataServices.reset(
new CWebDataServices(this->m_webReader, this->m_dbReaderHint)
new CWebDataServices(this->m_webReader, this->m_dbReaderHint, {}, this)
);
}
return true;

View File

@@ -18,7 +18,7 @@ using namespace BlackMisc;
namespace BlackCore
{
CCookieManager::CCookieManager(QObject *parent) : QNetworkCookieJar(parent)
CCookieManager::CCookieManager(BlackMisc::Restricted<CApplication>, QObject *parent) : QNetworkCookieJar(parent)
{
// code
}

View File

@@ -12,6 +12,7 @@
#ifndef BLACKCORE_COOKIEMANAGER_H
#define BLACKCORE_COOKIEMANAGER_H
#include "blackmisc/restricted.h"
#include "blackcore/blackcoreexport.h"
#include <QNetworkCookieJar>
#include <QNetworkCookie>
@@ -30,9 +31,10 @@ namespace BlackCore
{
Q_OBJECT
friend class CApplication;
public:
//! Constructor, only allowed from BlackCore::CApplication
CCookieManager(BlackMisc::Restricted<CApplication>, QObject *parent = nullptr);
//! \copydoc QNetworkCookieJar::setCookiesFromUrl
//! \threadsafe
virtual bool setCookiesFromUrl(const QList<QNetworkCookie> &cookies, const QUrl &url) override;
@@ -62,9 +64,6 @@ namespace BlackCore
virtual bool updateCookie(const QNetworkCookie &cookie) override;
private:
//! Constructor
CCookieManager(QObject *parent = nullptr);
mutable QReadWriteLock m_lock { QReadWriteLock::Recursive };
};

View File

@@ -37,7 +37,7 @@ using namespace BlackMisc::Weather;
namespace BlackCore
{
CWebDataServices::CWebDataServices(CWebReaderFlags::WebReader readerFlags, CWebReaderFlags::DbReaderHint hint, QObject *parent) :
CWebDataServices::CWebDataServices(CWebReaderFlags::WebReader readerFlags, CWebReaderFlags::DbReaderHint hint, BlackMisc::Restricted<CApplication>, QObject *parent) :
QObject(parent), m_readerFlags(readerFlags), m_dbHint(hint)
{
if (!sApp) { return; } // shutting down

View File

@@ -28,6 +28,7 @@
#include "blackmisc/logcategorylist.h"
#include "blackmisc/countrylist.h"
#include "blackmisc/project.h"
#include "blackmisc/restricted.h"
#include <QObject>
namespace BlackCore
@@ -48,12 +49,14 @@ namespace BlackCore
public QObject
{
Q_OBJECT
friend class CApplication;
public:
//! Log categories
static const BlackMisc::CLogCategoryList &getLogCategories();
//! Constructor, only allowed from BlackCore::CApplication
CWebDataServices(CWebReaderFlags::WebReader readerFlags, CWebReaderFlags:: DbReaderHint hint, BlackMisc::Restricted<CApplication>, QObject *parent = nullptr);
//! Shutdown
void gracefulShutdown();
@@ -261,10 +264,6 @@ namespace BlackCore
//! First read (allows to immediately read in background)
void readInBackground(BlackMisc::Network::CEntityFlags::Entity entities = BlackMisc::Network::CEntityFlags::AllEntities, int delayMs = 0);
protected:
//! Constructor
CWebDataServices(CWebReaderFlags::WebReader readerFlags, CWebReaderFlags:: DbReaderHint hint, QObject *parent = nullptr);
private slots:
//! ATC bookings received
void ps_receivedBookings(const BlackMisc::Aviation::CAtcStationList &bookedStations);