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