mirror of
https://github.com/tnodir/fort
synced 2024-11-15 10:15:07 +00:00
UI: IocContainer: Use constexpr, not macros
This commit is contained in:
parent
ff53310b09
commit
9a74a8225b
@ -43,7 +43,7 @@ public:
|
|||||||
void setUp() override
|
void setUp() override
|
||||||
{
|
{
|
||||||
IocService::setUp();
|
IocService::setUp();
|
||||||
IoC()->setUpDependency<A>();
|
IoCPinned()->setUpDependency<A>();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ AppInfoCache::AppInfoCache(QObject *parent) : QObject(parent), m_cache(1000)
|
|||||||
|
|
||||||
void AppInfoCache::setUp()
|
void AppInfoCache::setUp()
|
||||||
{
|
{
|
||||||
auto appInfoManager = IoC()->setUpDependency<AppInfoManager>();
|
auto appInfoManager = IoCPinned()->setUpDependency<AppInfoManager>();
|
||||||
|
|
||||||
connect(appInfoManager, &AppInfoManager::lookupInfoFinished, this,
|
connect(appInfoManager, &AppInfoManager::lookupInfoFinished, this,
|
||||||
&AppInfoCache::handleFinishedInfoLookup);
|
&AppInfoCache::handleFinishedInfoLookup);
|
||||||
|
@ -142,7 +142,7 @@ FirewallConf *ConfAppManager::conf() const
|
|||||||
|
|
||||||
void ConfAppManager::setUp()
|
void ConfAppManager::setUp()
|
||||||
{
|
{
|
||||||
m_confManager = IoC()->setUpDependency<ConfManager>();
|
m_confManager = IoCPinned()->setUpDependency<ConfManager>();
|
||||||
|
|
||||||
setupDriveListManager();
|
setupDriveListManager();
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ SqliteDb *ConfZoneManager::sqliteDb() const
|
|||||||
|
|
||||||
void ConfZoneManager::setUp()
|
void ConfZoneManager::setUp()
|
||||||
{
|
{
|
||||||
m_confManager = IoC()->setUpDependency<ConfManager>();
|
m_confManager = IoCPinned()->setUpDependency<ConfManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfZoneManager::addOrUpdateZone(Zone &zone)
|
bool ConfZoneManager::addOrUpdateZone(Zone &zone)
|
||||||
|
@ -207,7 +207,7 @@ void FortManager::updateLogger(const FirewallConf *conf)
|
|||||||
|
|
||||||
void FortManager::createManagers()
|
void FortManager::createManagers()
|
||||||
{
|
{
|
||||||
IocContainer *ioc = IoC();
|
IocContainer *ioc = IoCPinned();
|
||||||
|
|
||||||
const auto settings = IoC<FortSettings>();
|
const auto settings = IoC<FortSettings>();
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ void FortManager::createManagers()
|
|||||||
|
|
||||||
void FortManager::deleteManagers()
|
void FortManager::deleteManagers()
|
||||||
{
|
{
|
||||||
IocContainer *ioc = IoC();
|
IocContainer *ioc = IoCPinned();
|
||||||
|
|
||||||
ioc->tearDownAll();
|
ioc->tearDownAll();
|
||||||
ioc->autoDeleteAll();
|
ioc->autoDeleteAll();
|
||||||
|
@ -62,7 +62,7 @@ void LogManager::setCurrentUnixTime(qint64 unixTime)
|
|||||||
|
|
||||||
void LogManager::setUp()
|
void LogManager::setUp()
|
||||||
{
|
{
|
||||||
const auto driverManager = IoC()->setUpDependency<DriverManager>();
|
const auto driverManager = IoCPinned()->setUpDependency<DriverManager>();
|
||||||
|
|
||||||
connect(driverManager->driverWorker(), &DriverWorker::readLogResult, this,
|
connect(driverManager->driverWorker(), &DriverWorker::readLogResult, this,
|
||||||
&LogManager::processLogBuffer, Qt::QueuedConnection);
|
&LogManager::processLogBuffer, Qt::QueuedConnection);
|
||||||
|
@ -25,7 +25,7 @@ void HotKeyManager::initialize(bool enabled, bool global)
|
|||||||
|
|
||||||
void HotKeyManager::setUp()
|
void HotKeyManager::setUp()
|
||||||
{
|
{
|
||||||
auto nativeEventFilter = IoC()->setUpDependency<NativeEventFilter>();
|
auto nativeEventFilter = IoCPinned()->setUpDependency<NativeEventFilter>();
|
||||||
|
|
||||||
connect(nativeEventFilter, &NativeEventFilter::hotKeyPressed, this,
|
connect(nativeEventFilter, &NativeEventFilter::hotKeyPressed, this,
|
||||||
&HotKeyManager::onHotKeyPressed);
|
&HotKeyManager::onHotKeyPressed);
|
||||||
|
@ -54,7 +54,7 @@ void ServiceManager::initialize(qintptr hstatus)
|
|||||||
|
|
||||||
void ServiceManager::setupControlManager()
|
void ServiceManager::setupControlManager()
|
||||||
{
|
{
|
||||||
auto controlManager = IoC()->setUpDependency<ControlManager>();
|
auto controlManager = IoCPinned()->setUpDependency<ControlManager>();
|
||||||
|
|
||||||
connect(this, &ServiceManager::pauseRequested, controlManager, [controlManager] {
|
connect(this, &ServiceManager::pauseRequested, controlManager, [controlManager] {
|
||||||
controlManager->close();
|
controlManager->close();
|
||||||
@ -65,7 +65,7 @@ void ServiceManager::setupControlManager()
|
|||||||
|
|
||||||
void ServiceManager::setupConfManager()
|
void ServiceManager::setupConfManager()
|
||||||
{
|
{
|
||||||
auto confManager = IoC()->setUpDependency<ConfManager>();
|
auto confManager = IoCPinned()->setUpDependency<ConfManager>();
|
||||||
|
|
||||||
connect(confManager, &ConfManager::iniChanged, this, &ServiceManager::setupByConf);
|
connect(confManager, &ConfManager::iniChanged, this, &ServiceManager::setupByConf);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ QString TranslationManager::languageName() const
|
|||||||
|
|
||||||
void TranslationManager::setUp()
|
void TranslationManager::setUp()
|
||||||
{
|
{
|
||||||
auto confManager = IoC()->setUpDependency<ConfManager>();
|
auto confManager = IoCPinned()->setUpDependency<ConfManager>();
|
||||||
|
|
||||||
connect(confManager, &ConfManager::iniUserChanged, this, &TranslationManager::setupByIniUser);
|
connect(confManager, &ConfManager::iniUserChanged, this, &TranslationManager::setupByIniUser);
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ void WindowManager::setupMainWindow()
|
|||||||
m_mainWindow->setFont(defaultFont());
|
m_mainWindow->setFont(defaultFont());
|
||||||
|
|
||||||
// Register Native events
|
// Register Native events
|
||||||
auto nativeEventFilter = IoC()->setUpDependency<NativeEventFilter>();
|
auto nativeEventFilter = IoCPinned()->setUpDependency<NativeEventFilter>();
|
||||||
|
|
||||||
nativeEventFilter->registerSessionNotification(mainWindow()->winId());
|
nativeEventFilter->registerSessionNotification(mainWindow()->winId());
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ void WindowManager::setupStatisticsWindow()
|
|||||||
|
|
||||||
void WindowManager::setupConfManager()
|
void WindowManager::setupConfManager()
|
||||||
{
|
{
|
||||||
auto confManager = IoC()->setUpDependency<ConfManager>();
|
auto confManager = IoCPinned()->setUpDependency<ConfManager>();
|
||||||
|
|
||||||
connect(confManager, &ConfManager::iniUserChanged, this, &WindowManager::setupByIniUser);
|
connect(confManager, &ConfManager::iniUserChanged, this, &WindowManager::setupByIniUser);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ SqliteDb *ZoneListModel::sqliteDb() const
|
|||||||
|
|
||||||
void ZoneListModel::setUp()
|
void ZoneListModel::setUp()
|
||||||
{
|
{
|
||||||
auto confZoneManager = IoC()->setUpDependency<ConfZoneManager>();
|
auto confZoneManager = IoCPinned()->setUpDependency<ConfZoneManager>();
|
||||||
|
|
||||||
setupZoneTypes();
|
setupZoneTypes();
|
||||||
setupZoneSources();
|
setupZoneSources();
|
||||||
|
@ -687,7 +687,7 @@ void RpcManager::setupTaskManagerSignals()
|
|||||||
|
|
||||||
void RpcManager::setupClient()
|
void RpcManager::setupClient()
|
||||||
{
|
{
|
||||||
auto controlManager = IoC()->setUpDependency<ControlManager>();
|
auto controlManager = IoCPinned()->setUpDependency<ControlManager>();
|
||||||
|
|
||||||
m_client = controlManager->newServiceClient(this);
|
m_client = controlManager->newServiceClient(this);
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ QString QuotaManager::alertTypeText(qint8 alertType)
|
|||||||
|
|
||||||
void QuotaManager::setupConfManager()
|
void QuotaManager::setupConfManager()
|
||||||
{
|
{
|
||||||
auto confManager = IoC()->setUpDependency<ConfManager>();
|
auto confManager = IoCPinned()->setUpDependency<ConfManager>();
|
||||||
|
|
||||||
connect(confManager, &ConfManager::iniChanged, this, &QuotaManager::setupByConf);
|
connect(confManager, &ConfManager::iniChanged, this, &QuotaManager::setupByConf);
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ void StatBlockManager::setupWorker()
|
|||||||
|
|
||||||
void StatBlockManager::setupConfManager()
|
void StatBlockManager::setupConfManager()
|
||||||
{
|
{
|
||||||
auto confManager = IoC()->setUpDependency<ConfManager>();
|
auto confManager = IoCPinned()->setUpDependency<ConfManager>();
|
||||||
|
|
||||||
connect(confManager, &ConfManager::iniChanged, this, &StatBlockManager::setupByConf);
|
connect(confManager, &ConfManager::iniChanged, this, &StatBlockManager::setupByConf);
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ void TaskManager::appendTaskInfo(TaskInfo *taskInfo)
|
|||||||
|
|
||||||
void TaskManager::loadSettings()
|
void TaskManager::loadSettings()
|
||||||
{
|
{
|
||||||
auto confManager = IoC()->setUpDependency<ConfManager>();
|
auto confManager = IoCPinned()->setUpDependency<ConfManager>();
|
||||||
|
|
||||||
confManager->loadTasks(taskInfoList());
|
confManager->loadTasks(taskInfoList());
|
||||||
}
|
}
|
||||||
|
@ -119,14 +119,14 @@ private:
|
|||||||
IocObject *m_objects[IOC_MAX_SIZE] = {};
|
IocObject *m_objects[IOC_MAX_SIZE] = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constexpr auto IoCPinned = IocContainer::getPinned;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline static T *IoC()
|
inline static T *IoC()
|
||||||
{
|
{
|
||||||
const IocContainer *container = IocContainer::getPinned();
|
const IocContainer *container = IoCPinned();
|
||||||
Q_ASSERT(container);
|
Q_ASSERT(container);
|
||||||
return container->resolve<T>();
|
return container->resolve<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define IoC() IocContainer::getPinned()
|
|
||||||
|
|
||||||
#endif // IOCCONTAINER_H
|
#endif // IOCCONTAINER_H
|
||||||
|
Loading…
Reference in New Issue
Block a user