refactor: Remove restricted class for less coupling

This commit is contained in:
Lars Toenning
2024-11-09 15:15:17 +01:00
parent eee9e92e7e
commit bcc5d62a59
8 changed files with 6 additions and 40 deletions

View File

@@ -805,7 +805,7 @@ namespace BlackCore
if (!m_webDataServices)
{
msgs.push_back(CStatusMessage(this).info(u"Will start web data services now"));
m_webDataServices.reset(new CWebDataServices(webReader, dbReaderConfig, {}, this));
m_webDataServices.reset(new CWebDataServices(webReader, dbReaderConfig, this));
Q_ASSERT_X(m_webDataServices, Q_FUNC_INFO, "Missing web services");
emit this->webDataServicesStarted(true);

View File

@@ -18,7 +18,6 @@
#include "blackmisc/fileutils.h"
#include "blackmisc/logcategories.h"
#include "blackmisc/logmessage.h"
#include "blackmisc/restricted.h"
#include "blackmisc/statusmessage.h"
#include "blackmisc/worker.h"
#include "blackmisc/threadutils.h"
@@ -47,7 +46,7 @@ using namespace BlackMisc::Weather;
namespace BlackCore
{
CWebDataServices::CWebDataServices(CWebReaderFlags::WebReader readers, const CDatabaseReaderConfigList &dbReaderConfig, BlackMisc::Restricted<CApplication>, QObject *parent) : QObject(parent), m_dbReaderConfig(dbReaderConfig)
CWebDataServices::CWebDataServices(CWebReaderFlags::WebReader readers, const CDatabaseReaderConfigList &dbReaderConfig, QObject *parent) : QObject(parent), m_dbReaderConfig(dbReaderConfig)
{
if (!sApp) { return; } // shutting down

View File

@@ -26,7 +26,6 @@
#include "blackmisc/network/voicecapabilities.h"
#include "blackmisc/weather/metarlist.h"
#include "blackmisc/weather/metar.h"
#include "blackmisc/restricted.h"
#include "blackmisc/statusmessagelist.h"
#include "blackmisc/countrylist.h"
@@ -55,8 +54,6 @@ namespace BlackMisc
namespace BlackCore
{
class CApplication;
namespace Vatsim
{
class CVatsimDataFileReader;
@@ -88,7 +85,7 @@ namespace BlackCore
static const QStringList &getLogCategories();
//! Constructor, only allowed from BlackCore::CApplication
CWebDataServices(CWebReaderFlags::WebReader readerFlags, const BlackCore::Db::CDatabaseReaderConfigList &dbReaderConfig, BlackMisc::Restricted<CApplication>, QObject *parent = nullptr);
CWebDataServices(CWebReaderFlags::WebReader readerFlags, const BlackCore::Db::CDatabaseReaderConfigList &dbReaderConfig, QObject *parent = nullptr);
//! Destructor
virtual ~CWebDataServices() override;

View File

@@ -325,7 +325,7 @@ namespace BlackGui
QCommandLineOption m_cmdWindowMode { "emptyWindowMode" }; //!< window mode (flags: frameless ...)
QCommandLineOption m_cmdWindowSizeReset { "emptySizeReset" }; //!< window size reset
QCommandLineOption m_cmdWindowScaleSize { "emptyScale" }; //!< window scale size
CStyleSheetUtility m_styleSheetUtility { {}, this }; //!< style sheet utility
CStyleSheetUtility m_styleSheetUtility { this }; //!< style sheet utility
bool m_uiSetupCompleted = false; //!< ui setup completed
bool m_saveMainWidgetState = true; //!< save/restore main widget's state
bool m_frontBack = true; //!< for front/back toggle

View File

@@ -7,7 +7,6 @@
#include "blackmisc/logmessage.h"
#include "blackmisc/swiftdirectories.h"
#include "blackmisc/directoryutils.h"
#include "blackmisc/restricted.h"
#include <QAbstractScrollArea>
#include <QCoreApplication>
@@ -31,7 +30,7 @@ using namespace BlackMisc;
namespace BlackGui
{
CStyleSheetUtility::CStyleSheetUtility(BlackMisc::Restricted<CGuiApplication>, QObject *parent) : QObject(parent)
CStyleSheetUtility::CStyleSheetUtility(QObject *parent) : QObject(parent)
{
this->read();
connect(&m_fileWatcher, &QFileSystemWatcher::directoryChanged, this, &CStyleSheetUtility::qssDirectoryChanged);

View File

@@ -8,7 +8,6 @@
#include "blackgui/blackguiexport.h"
#include "blackmisc/logcategories.h"
#include "blackmisc/restricted.h"
#include "blackmisc/digestsignal.h"
#include <QFileSystemWatcher>
@@ -25,8 +24,6 @@ class QWidget;
namespace BlackGui
{
class CGuiApplication;
//! Reads and provides style sheets
class BLACKGUI_EXPORT CStyleSheetUtility : public QObject
{
@@ -34,7 +31,7 @@ namespace BlackGui
public:
//! Constructor
explicit CStyleSheetUtility(BlackMisc::Restricted<CGuiApplication>, QObject *parent = nullptr);
explicit CStyleSheetUtility(QObject *parent = nullptr);
//! Log cats.
static const QStringList &getLogCategories();

View File

@@ -298,7 +298,6 @@ add_library(misc SHARED
range.h
registermetadata.cpp
registermetadata.h
restricted.h
rgbcolor.cpp
rgbcolor.h
sequence.cpp

View File

@@ -1,25 +0,0 @@
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
//! \file
#ifndef BLACKMISC_RESTRICTED_H
#define BLACKMISC_RESTRICTED_H
namespace BlackMisc
{
/*!
* Restricted<T> is just an empty class, that can only be constructed by the class T.
*/
template <typename T>
class Restricted
{
private:
friend T;
//! Constructor is only available to the template parameter T.
Restricted() {}
};
}
#endif // guard