Caches: rename "get" to "getThreadLocal" and rename "getCopy" to get.

This commit is contained in:
Mathew Sutcliffe
2016-06-06 15:47:11 +01:00
committed by Klaus Basan
parent 332d8e5fc8
commit 9bef6854ca
30 changed files with 83 additions and 83 deletions

View File

@@ -419,7 +419,7 @@ namespace BlackCore
Q_ASSERT(this->m_voice); Q_ASSERT(this->m_voice);
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << notification; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << notification; }
bool play = !considerSettings || m_audioSettings.get().getNotificationFlag(notification); bool play = !considerSettings || m_audioSettings.getThreadLocal().getNotificationFlag(notification);
if (play) if (play)
{ {
CSoundGenerator::playNotificationSound(90, notification); CSoundGenerator::playNotificationSound(90, notification);

View File

@@ -110,7 +110,7 @@ namespace BlackCore
CAltitude(312, CAltitude::MeanSeaLevel, CLengthUnit::ft()) CAltitude(312, CAltitude::MeanSeaLevel, CLengthUnit::ft())
); );
this->m_ownAircraft.setSituation(situation); this->m_ownAircraft.setSituation(situation);
this->m_ownAircraft.setPilot(this->m_currentNetworkServer.get().getUser()); this->m_ownAircraft.setPilot(this->m_currentNetworkServer.getThreadLocal().getUser());
// from simulator, if available // from simulator, if available
this->m_ownAircraft.setCallsign(CCallsign("SWIFT")); // would come from settings this->m_ownAircraft.setCallsign(CCallsign("SWIFT")); // would come from settings

View File

@@ -576,7 +576,7 @@ namespace BlackCore
{ {
stopSimulatorListeners(); stopSimulatorListeners();
auto enabledSimulators = m_enabledSimulators.get(); auto enabledSimulators = m_enabledSimulators.getThreadLocal();
auto allSimulators = m_plugins->getAvailableSimulatorPlugins(); auto allSimulators = m_plugins->getAvailableSimulatorPlugins();
for (const CSimulatorPluginInfo& s: allSimulators) for (const CSimulatorPluginInfo& s: allSimulators)
{ {

View File

@@ -66,7 +66,7 @@ namespace BlackCore
} }
else else
{ {
dbusAddress = m_dbusServerAddress.get(); dbusAddress = m_dbusServerAddress.getThreadLocal();
} }
// DBus // DBus

View File

@@ -47,7 +47,7 @@ namespace BlackCore
CAircraftIcaoCodeList CIcaoDataReader::getAircraftIcaoCodes() const CAircraftIcaoCodeList CIcaoDataReader::getAircraftIcaoCodes() const
{ {
return m_aircraftIcaoCache.getCopy(); return m_aircraftIcaoCache.get();
} }
CAircraftIcaoCode CIcaoDataReader::getAircraftIcaoCodeForDesignator(const QString &designator) const CAircraftIcaoCode CIcaoDataReader::getAircraftIcaoCodeForDesignator(const QString &designator) const
@@ -62,7 +62,7 @@ namespace BlackCore
CAirlineIcaoCodeList CIcaoDataReader::getAirlineIcaoCodes() const CAirlineIcaoCodeList CIcaoDataReader::getAirlineIcaoCodes() const
{ {
return m_airlineIcaoCache.getCopy(); return m_airlineIcaoCache.get();
} }
CAircraftIcaoCode CIcaoDataReader::smartAircraftIcaoSelector(const CAircraftIcaoCode &icaoPattern) const CAircraftIcaoCode CIcaoDataReader::smartAircraftIcaoSelector(const CAircraftIcaoCode &icaoPattern) const
@@ -73,7 +73,7 @@ namespace BlackCore
CCountryList CIcaoDataReader::getCountries() const CCountryList CIcaoDataReader::getCountries() const
{ {
return m_countryCache.getCopy(); return m_countryCache.get();
} }
CCountry CIcaoDataReader::getCountryForIsoCode(const QString &isoCode) const CCountry CIcaoDataReader::getCountryForIsoCode(const QString &isoCode) const
@@ -201,7 +201,7 @@ namespace BlackCore
void CIcaoDataReader::updateReaderUrl(const CUrl &url) void CIcaoDataReader::updateReaderUrl(const CUrl &url)
{ {
const CUrl current = this->m_readerUrlCache.getCopy(); const CUrl current = this->m_readerUrlCache.get();
if (current == url) { return; } if (current == url) { return; }
const CStatusMessage m = this->m_readerUrlCache.set(url); const CStatusMessage m = this->m_readerUrlCache.set(url);
if (m.isFailure()) if (m.isFailure())
@@ -420,9 +420,9 @@ namespace BlackCore
{ {
switch (entity) switch (entity)
{ {
case CEntityFlags::AircraftIcaoEntity: return this->m_aircraftIcaoCache.getCopy().size(); case CEntityFlags::AircraftIcaoEntity: return this->m_aircraftIcaoCache.get().size();
case CEntityFlags::AirlineIcaoEntity: return this->m_airlineIcaoCache.getCopy().size(); case CEntityFlags::AirlineIcaoEntity: return this->m_airlineIcaoCache.get().size();
case CEntityFlags::CountryEntity: return this->m_countryCache.getCopy().size(); case CEntityFlags::CountryEntity: return this->m_countryCache.get().size();
default: return 0; default: return 0;
} }
} }
@@ -430,7 +430,7 @@ namespace BlackCore
bool CIcaoDataReader::hasChangedUrl(CEntityFlags::Entity entity) const bool CIcaoDataReader::hasChangedUrl(CEntityFlags::Entity entity) const
{ {
Q_UNUSED(entity); Q_UNUSED(entity);
return CDatabaseReader::isChangedUrl(this->m_readerUrlCache.getCopy(), this->getBaseUrl()); return CDatabaseReader::isChangedUrl(this->m_readerUrlCache.get(), this->getBaseUrl());
} }
CUrl CIcaoDataReader::getAircraftIcaoUrl(bool shared) const CUrl CIcaoDataReader::getAircraftIcaoUrl(bool shared) const

View File

@@ -47,7 +47,7 @@ namespace BlackCore
CLiveryList CModelDataReader::getLiveries() const CLiveryList CModelDataReader::getLiveries() const
{ {
return this->m_liveryCache.getCopy(); return this->m_liveryCache.get();
} }
CLivery CModelDataReader::getLiveryForCombinedCode(const QString &combinedCode) const CLivery CModelDataReader::getLiveryForCombinedCode(const QString &combinedCode) const
@@ -79,12 +79,12 @@ namespace BlackCore
CDistributorList CModelDataReader::getDistributors() const CDistributorList CModelDataReader::getDistributors() const
{ {
return m_distributorCache.getCopy(); return m_distributorCache.get();
} }
CAircraftModelList CModelDataReader::getModels() const CAircraftModelList CModelDataReader::getModels() const
{ {
return m_modelCache.getCopy(); return m_modelCache.get();
} }
CAircraftModel CModelDataReader::getModelForModelString(const QString &modelString) const CAircraftModel CModelDataReader::getModelForModelString(const QString &modelString) const
@@ -231,7 +231,7 @@ namespace BlackCore
void CModelDataReader::updateReaderUrl(const CUrl &url) void CModelDataReader::updateReaderUrl(const CUrl &url)
{ {
const CUrl current = this->m_readerUrlCache.getCopy(); const CUrl current = this->m_readerUrlCache.get();
if (current == url) { return; } if (current == url) { return; }
const CStatusMessage m = this->m_readerUrlCache.set(url); const CStatusMessage m = this->m_readerUrlCache.set(url);
if (m.isFailure()) if (m.isFailure())
@@ -489,9 +489,9 @@ namespace BlackCore
{ {
switch (entity) switch (entity)
{ {
case CEntityFlags::LiveryEntity: return this->m_liveryCache.getCopy().size(); case CEntityFlags::LiveryEntity: return this->m_liveryCache.get().size();
case CEntityFlags::ModelEntity: return this->m_modelCache.getCopy().size(); case CEntityFlags::ModelEntity: return this->m_modelCache.get().size();
case CEntityFlags::DistributorEntity: return this->m_distributorCache.getCopy().size(); case CEntityFlags::DistributorEntity: return this->m_distributorCache.get().size();
default: return 0; default: return 0;
} }
} }
@@ -499,7 +499,7 @@ namespace BlackCore
bool CModelDataReader::hasChangedUrl(CEntityFlags::Entity entity) const bool CModelDataReader::hasChangedUrl(CEntityFlags::Entity entity) const
{ {
Q_UNUSED(entity); Q_UNUSED(entity);
return CDatabaseReader::isChangedUrl(this->m_readerUrlCache.getCopy(), this->getBaseUrl()); return CDatabaseReader::isChangedUrl(this->m_readerUrlCache.get(), this->getBaseUrl());
} }
const CUrl &CModelDataReader::getBaseUrl() const CUrl &CModelDataReader::getBaseUrl()

View File

@@ -71,7 +71,7 @@ namespace BlackCore
void CInputManager::ps_changeHotkeySettings() void CInputManager::ps_changeHotkeySettings()
{ {
m_configuredActions.clear(); m_configuredActions.clear();
for (CActionHotkey actionHotkey : m_actionHotkeys.get()) for (CActionHotkey actionHotkey : m_actionHotkeys.getThreadLocal())
{ {
CHotkeyCombination combination = actionHotkey.getCombination(); CHotkeyCombination combination = actionHotkey.getCombination();
if (combination.isEmpty()) continue; if (combination.isEmpty()) continue;

View File

@@ -75,7 +75,7 @@ namespace BlackCore
: INetwork(parent), COwnAircraftAware(ownAircraft), : INetwork(parent), COwnAircraftAware(ownAircraft),
m_loginMode(LoginNormal), m_loginMode(LoginNormal),
m_status(vatStatusIdle), m_status(vatStatusIdle),
m_fsdTextCodec(QTextCodec::codecForName(m_fsdTextCodecSetting.get().toLocal8Bit())), m_fsdTextCodec(QTextCodec::codecForName(m_fsdTextCodecSetting.getThreadLocal().toLocal8Bit())),
m_tokenBucket(10, CTime(5, CTimeUnit::s()), 1) m_tokenBucket(10, CTime(5, CTimeUnit::s()), 1)
{ {
connect(this, &CNetworkVatlib::terminate, this, &INetwork::terminateConnection, Qt::QueuedConnection); connect(this, &CNetworkVatlib::terminate, this, &INetwork::terminateConnection, Qt::QueuedConnection);

View File

@@ -62,7 +62,7 @@ namespace BlackCore
} }
m_setup.synchronize(); // make sure it is loaded m_setup.synchronize(); // make sure it is loaded
CGlobalSetup cachedSetup = m_setup.getCopy(); CGlobalSetup cachedSetup = m_setup.get();
const bool cacheAvailable = cachedSetup.wasLoaded(); const bool cacheAvailable = cachedSetup.wasLoaded();
msgs.push_back(cacheAvailable ? msgs.push_back(cacheAvailable ?
CStatusMessage(this, CStatusMessage::SeverityInfo , "Cached setup syncronized and contains data") : CStatusMessage(this, CStatusMessage::SeverityInfo , "Cached setup syncronized and contains data") :
@@ -281,7 +281,7 @@ namespace BlackCore
} }
else else
{ {
const CGlobalSetup currentSetup = m_setup.getCopy(); const CGlobalSetup currentSetup = m_setup.get();
CGlobalSetup loadedSetup; CGlobalSetup loadedSetup;
loadedSetup.convertFromJson(Json::jsonObjectFromString(setupJson)); loadedSetup.convertFromJson(Json::jsonObjectFromString(setupJson));
loadedSetup.markAsLoaded(true); loadedSetup.markAsLoaded(true);
@@ -410,12 +410,12 @@ namespace BlackCore
CGlobalSetup CSetupReader::getSetup() const CGlobalSetup CSetupReader::getSetup() const
{ {
return m_setup.getCopy(); return m_setup.get();
} }
CUpdateInfo CSetupReader::getUpdateInfo() const CUpdateInfo CSetupReader::getUpdateInfo() const
{ {
return m_updateInfo.getCopy(); return m_updateInfo.get();
} }
CStatusMessageList CSetupReader::manageSetupAvailability(bool webRead, bool localRead) CStatusMessageList CSetupReader::manageSetupAvailability(bool webRead, bool localRead)
@@ -440,7 +440,7 @@ namespace BlackCore
} }
else else
{ {
bool cacheAvailable = this->m_setup.get().wasLoaded(); bool cacheAvailable = this->m_setup.getThreadLocal().wasLoaded();
available = cacheAvailable && this->m_bootstrapMode != Explicit; available = cacheAvailable && this->m_bootstrapMode != Explicit;
} }

View File

@@ -86,12 +86,12 @@ namespace BlackCore
CServerList CVatsimDataFileReader::getVoiceServers() const CServerList CVatsimDataFileReader::getVoiceServers() const
{ {
return this->m_lastGoodSetup.getCopy().getVoiceServers(); return this->m_lastGoodSetup.get().getVoiceServers();
} }
CServerList CVatsimDataFileReader::getFsdServers() const CServerList CVatsimDataFileReader::getFsdServers() const
{ {
return this->m_lastGoodSetup.getCopy().getFsdServers(); return this->m_lastGoodSetup.get().getFsdServers();
} }
CUserList CVatsimDataFileReader::getPilotsForCallsigns(const CCallsignSet &callsigns) CUserList CVatsimDataFileReader::getPilotsForCallsigns(const CCallsignSet &callsigns)
@@ -379,7 +379,7 @@ namespace BlackCore
this->m_aircraft = aircraft; this->m_aircraft = aircraft;
this->m_atcStations = atcStations; this->m_atcStations = atcStations;
this->m_voiceCapabilities = voiceCapabilities; this->m_voiceCapabilities = voiceCapabilities;
CVatsimSetup vs(this->m_lastGoodSetup.get()); CVatsimSetup vs(this->m_lastGoodSetup.getThreadLocal());
vs.setVoiceServers(voiceServers); vs.setVoiceServers(voiceServers);
vs.setFsdServers(fsdServers); vs.setFsdServers(fsdServers);
vs.setUtcTimestamp(updateTimestampFromFile); vs.setUtcTimestamp(updateTimestampFromFile);

View File

@@ -53,12 +53,12 @@ namespace BlackCore
CUrlList CVatsimStatusFileReader::getMetarFileUrls() const CUrlList CVatsimStatusFileReader::getMetarFileUrls() const
{ {
return this->m_lastGoodSetup.getCopy().getMetarFileUrls(); return this->m_lastGoodSetup.get().getMetarFileUrls();
} }
CUrlList CVatsimStatusFileReader::getDataFileUrls() const CUrlList CVatsimStatusFileReader::getDataFileUrls() const
{ {
return this->m_lastGoodSetup.getCopy().getDataFileUrls(); return this->m_lastGoodSetup.get().getDataFileUrls();
} }
void CVatsimStatusFileReader::cleanup() void CVatsimStatusFileReader::cleanup()
@@ -148,7 +148,7 @@ namespace BlackCore
// this part needs to be synchronized // this part needs to be synchronized
{ {
// cache itself is thread safe // cache itself is thread safe
CVatsimSetup vs(this->m_lastGoodSetup.getCopy()); CVatsimSetup vs(this->m_lastGoodSetup.get());
vs.setDataFileUrls(dataFiles); vs.setDataFileUrls(dataFiles);
vs.setMetarFileUrls(metarFiles); vs.setMetarFileUrls(metarFiles);
vs.setServerFileUrls(serverFiles); vs.setServerFileUrls(serverFiles);

View File

@@ -75,7 +75,7 @@ namespace BlackGui
void CAudioSetupComponent::ps_reloadSettings() void CAudioSetupComponent::ps_reloadSettings()
{ {
CSettingsAudio as(m_audioSettings.get()); CSettingsAudio as(m_audioSettings.getThreadLocal());
this->ui->cb_SetupAudioPlayNotificationSounds->setChecked(true); this->ui->cb_SetupAudioPlayNotificationSounds->setChecked(true);
this->ui->cb_SetupAudioNotificationTextMessage->setChecked(as.getNotificationFlag(CNotificationSounds::NotificationTextMessagePrivate)); this->ui->cb_SetupAudioNotificationTextMessage->setChecked(as.getNotificationFlag(CNotificationSounds::NotificationTextMessagePrivate));
this->ui->cb_SetupAudioNotificationVoiceRoom->setChecked(as.getNotificationFlag(CNotificationSounds::NotificationVoiceRoomJoined)); this->ui->cb_SetupAudioNotificationVoiceRoom->setChecked(as.getNotificationFlag(CNotificationSounds::NotificationVoiceRoomJoined));

View File

@@ -43,7 +43,7 @@ namespace BlackGui
void CDbDebugDatabaseSetup::ps_debugChanged(bool set) void CDbDebugDatabaseSetup::ps_debugChanged(bool set)
{ {
CGlobalSetup gs(m_setup.get()); CGlobalSetup gs(m_setup.getThreadLocal());
gs.setServerDebugFlag(set); gs.setServerDebugFlag(set);
m_setup.set(gs); m_setup.set(gs);
} }

View File

@@ -48,7 +48,7 @@ namespace BlackGui
// should be single simulator or no simulator (default) // should be single simulator or no simulator (default)
this->m_simulatorSelection.synchronize(); this->m_simulatorSelection.synchronize();
const CSimulatorInfo simulator(this->m_simulatorSelection.getCopy()); const CSimulatorInfo simulator(this->m_simulatorSelection.get());
const bool s = this->initModelLoader(!simulator.isSingleSimulator() ? CSimulatorInfo(CSimulatorInfo::FSX) : simulator); const bool s = this->initModelLoader(!simulator.isSingleSimulator() ? CSimulatorInfo(CSimulatorInfo::FSX) : simulator);
if (s) if (s)
{ {

View File

@@ -278,7 +278,7 @@ namespace BlackGui
void CDbOwnModelSetComponent::ps_distributorPreferencesChanged() void CDbOwnModelSetComponent::ps_distributorPreferencesChanged()
{ {
const CDistributorListPreferences preferences = this->m_distributorPreferences.get(); const CDistributorListPreferences preferences = this->m_distributorPreferences.getThreadLocal();
const CSimulatorInfo simuulator = preferences.getLastUpdatedSimulator(); const CSimulatorInfo simuulator = preferences.getLastUpdatedSimulator();
if (simuulator.isSingleSimulator()) if (simuulator.isSingleSimulator())
{ {
@@ -316,7 +316,7 @@ namespace BlackGui
{ {
CAircraftModelList modelSet = this->m_modelSetLoader.getAircraftModels(simulator); CAircraftModelList modelSet = this->m_modelSetLoader.getAircraftModels(simulator);
if (modelSet.isEmpty()) { return; } if (modelSet.isEmpty()) { return; }
const CDistributorListPreferences preferences = this->m_distributorPreferences.get(); const CDistributorListPreferences preferences = this->m_distributorPreferences.getThreadLocal();
const CDistributorList distributors = preferences.getDistributors(simulator); const CDistributorList distributors = preferences.getDistributors(simulator);
if (distributors.isEmpty()) { return; } if (distributors.isEmpty()) { return; }
modelSet.updateDistributorOrder(distributors); modelSet.updateDistributorOrder(distributors);

View File

@@ -74,7 +74,7 @@ namespace BlackGui
{ {
// changed somewhere else // changed somewhere else
const CSimulatorInfo sim(ui->comp_SimulatorSelector->getValue()); const CSimulatorInfo sim(ui->comp_SimulatorSelector->getValue());
const CDistributorList distributors = this->m_distributorPreferences.get().getDistributors(sim); const CDistributorList distributors = this->m_distributorPreferences.getThreadLocal().getDistributors(sim);
this->updateContainerMaybeAsync(distributors); this->updateContainerMaybeAsync(distributors);
} }
@@ -128,7 +128,7 @@ namespace BlackGui
{ {
const CDistributorList distributors(ui->tvp_Distributors->container()); const CDistributorList distributors(ui->tvp_Distributors->container());
const CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue(); const CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue();
CDistributorListPreferences preferences = this->m_distributorPreferences.get(); CDistributorListPreferences preferences = this->m_distributorPreferences.getThreadLocal();
preferences.setDistributors(distributors, simulator); preferences.setDistributors(distributors, simulator);
const CStatusMessage m = this->m_distributorPreferences.setAndSave(preferences); const CStatusMessage m = this->m_distributorPreferences.setAndSave(preferences);
CLogMessage::preformatted(m); CLogMessage::preformatted(m);
@@ -137,7 +137,7 @@ namespace BlackGui
void CDistributorPreferencesComponent::ps_simulatorChanged(const CSimulatorInfo &simulator) void CDistributorPreferencesComponent::ps_simulatorChanged(const CSimulatorInfo &simulator)
{ {
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Expect single simulator"); Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Expect single simulator");
const CDistributorList distributors(this->m_distributorPreferences.get().getDistributors(simulator)); const CDistributorList distributors(this->m_distributorPreferences.getThreadLocal().getDistributors(simulator));
ui->tvp_Distributors->updateContainerMaybeAsync(distributors); ui->tvp_Distributors->updateContainerMaybeAsync(distributors);
} }

View File

@@ -129,7 +129,7 @@ namespace BlackGui
ps_validateAircraftValues(); ps_validateAircraftValues();
ps_validateVatsimValues(); ps_validateVatsimValues();
ps_onWebServiceDataRead(CEntityFlags::VatsimDataFile, CEntityFlags::ReadFinished, -1); ps_onWebServiceDataRead(CEntityFlags::VatsimDataFile, CEntityFlags::ReadFinished, -1);
CServerList otherServers(this->m_otherTrafficNetworkServers.get()); CServerList otherServers(this->m_otherTrafficNetworkServers.getThreadLocal());
// add a testserver when no servers can be loaded // add a testserver when no servers can be loaded
if (otherServers.isEmpty() && (sGui->isRunningInDeveloperEnvironment() || CBuildConfig::isBetaTest())) if (otherServers.isEmpty() && (sGui->isRunningInDeveloperEnvironment() || CBuildConfig::isBetaTest()))
@@ -470,7 +470,7 @@ namespace BlackGui
void CLoginComponent::ps_reloadSettings() void CLoginComponent::ps_reloadSettings()
{ {
CServerList otherServers(this->m_otherTrafficNetworkServers.get()); CServerList otherServers(this->m_otherTrafficNetworkServers.getThreadLocal());
this->ui->cbp_OtherServers->setServers(otherServers); this->ui->cbp_OtherServers->setServers(otherServers);
} }

View File

@@ -106,28 +106,28 @@ namespace BlackGui
void CSettingsHotkeyComponent::addHotkeytoSettings(const CActionHotkey &actionHotkey) void CSettingsHotkeyComponent::addHotkeytoSettings(const CActionHotkey &actionHotkey)
{ {
CActionHotkeyList actionHotkeyList(m_actionHotkeys.get()); CActionHotkeyList actionHotkeyList(m_actionHotkeys.getThreadLocal());
actionHotkeyList.push_back(actionHotkey); actionHotkeyList.push_back(actionHotkey);
m_actionHotkeys.set(actionHotkeyList); m_actionHotkeys.set(actionHotkeyList);
} }
void CSettingsHotkeyComponent::updateHotkeyInSettings(const CActionHotkey &oldValue, const CActionHotkey &newValue) void CSettingsHotkeyComponent::updateHotkeyInSettings(const CActionHotkey &oldValue, const CActionHotkey &newValue)
{ {
CActionHotkeyList actionHotkeyList(m_actionHotkeys.get()); CActionHotkeyList actionHotkeyList(m_actionHotkeys.getThreadLocal());
actionHotkeyList.replace(oldValue, newValue); actionHotkeyList.replace(oldValue, newValue);
m_actionHotkeys.set(actionHotkeyList); m_actionHotkeys.set(actionHotkeyList);
} }
void CSettingsHotkeyComponent::removeHotkeyFromSettings(const CActionHotkey &actionHotkey) void CSettingsHotkeyComponent::removeHotkeyFromSettings(const CActionHotkey &actionHotkey)
{ {
CActionHotkeyList actionHotkeyList(m_actionHotkeys.get()); CActionHotkeyList actionHotkeyList(m_actionHotkeys.getThreadLocal());
actionHotkeyList.remove(actionHotkey); actionHotkeyList.remove(actionHotkey);
m_actionHotkeys.set(actionHotkeyList); m_actionHotkeys.set(actionHotkeyList);
} }
bool CSettingsHotkeyComponent::checkAndConfirmConflicts(const CActionHotkey &actionHotkey, const CActionHotkeyList &ignore) bool CSettingsHotkeyComponent::checkAndConfirmConflicts(const CActionHotkey &actionHotkey, const CActionHotkeyList &ignore)
{ {
auto configuredHotkeys = m_actionHotkeys.get(); auto configuredHotkeys = m_actionHotkeys.getThreadLocal();
CActionHotkeyList conflicts = configuredHotkeys.findSupersetsOf(actionHotkey); CActionHotkeyList conflicts = configuredHotkeys.findSupersetsOf(actionHotkey);
conflicts.push_back(configuredHotkeys.findSubsetsOf(actionHotkey)); conflicts.push_back(configuredHotkeys.findSubsetsOf(actionHotkey));
conflicts.removeIfIn(ignore); conflicts.removeIfIn(ignore);

View File

@@ -58,7 +58,7 @@ namespace BlackGui
void CSettingsNetworkServersComponent::ps_reloadSettings() void CSettingsNetworkServersComponent::ps_reloadSettings()
{ {
CServerList serverList(m_trafficNetworkServers.getCopy()); CServerList serverList(m_trafficNetworkServers.get());
// add swift test servers in case we have no servers: // add swift test servers in case we have no servers:
// this is debug/bootstrap feature we can continue to test when something goes wrong // this is debug/bootstrap feature we can continue to test when something goes wrong
@@ -81,7 +81,7 @@ namespace BlackGui
CStatusMessageList msgs = server.validate(); CStatusMessageList msgs = server.validate();
if (!msgs.isEmpty()) { msgs.addCategories(this); } if (!msgs.isEmpty()) { msgs.addCategories(this); }
CServerList serverList(m_trafficNetworkServers.get()); CServerList serverList(m_trafficNetworkServers.getThreadLocal());
QObject *sender = QObject::sender(); QObject *sender = QObject::sender();
CStatusMessage msg; CStatusMessage msg;
bool changed = false; bool changed = false;

View File

@@ -150,7 +150,7 @@ namespace BlackGui
return; return;
} }
auto e = m_enabledSimulators.get(); auto e = m_enabledSimulators.getThreadLocal();
if (enabled && !e.contains(selected->getIdentifier())) if (enabled && !e.contains(selected->getIdentifier()))
{ {
e << selected->getIdentifier(); e << selected->getIdentifier();
@@ -301,7 +301,7 @@ namespace BlackGui
void CSettingsSimulatorComponent::ps_reloadPluginConfig() void CSettingsSimulatorComponent::ps_reloadPluginConfig()
{ {
// list all available simulators // list all available simulators
auto enabledSimulators = m_enabledSimulators.get(); auto enabledSimulators = m_enabledSimulators.getThreadLocal();
for (const auto &p : getAvailablePlugins()) for (const auto &p : getAvailablePlugins())
{ {
ui->ps_EnabledSimulators->setEnabled(p.getIdentifier(), enabledSimulators.contains(p.getIdentifier())); ui->ps_EnabledSimulators->setEnabled(p.getIdentifier(), enabledSimulators.contains(p.getIdentifier()));

View File

@@ -536,7 +536,7 @@ namespace BlackGui
void CDockWidget::initSettings() void CDockWidget::initSettings()
{ {
const QString name(this->getNameForSettings()); const QString name(this->getNameForSettings());
CSettingsDockWidgets all = this->m_settings.getCopy(); CSettingsDockWidgets all = this->m_settings.get();
if (all.contains(name)) { return; } if (all.contains(name)) { return; }
all.getByNameOrInitToDefault(name); all.getByNameOrInitToDefault(name);
this->m_settings.set(all); this->m_settings.set(all);
@@ -551,7 +551,7 @@ namespace BlackGui
CSettingsDockWidget CDockWidget::getSettings() const CSettingsDockWidget CDockWidget::getSettings() const
{ {
const CSettingsDockWidgets all = this->m_settings.getCopy(); const CSettingsDockWidgets all = this->m_settings.get();
const QString name(this->getNameForSettings()); const QString name(this->getNameForSettings());
const CSettingsDockWidget s = all.value(name); const CSettingsDockWidget s = all.value(name);
return s; return s;
@@ -561,7 +561,7 @@ namespace BlackGui
{ {
const CSettingsDockWidget current = getSettings(); const CSettingsDockWidget current = getSettings();
if (current == settings) { return; } if (current == settings) { return; }
CSettingsDockWidgets all = this->m_settings.getCopy(); CSettingsDockWidgets all = this->m_settings.get();
const QString name(this->getNameForSettings()); const QString name(this->getNameForSettings());
all.insert(name, settings); all.insert(name, settings);
const CStatusMessage m = this->m_settings.set(all); // saved when shutdown const CStatusMessage m = this->m_settings.set(all); // saved when shutdown

View File

@@ -23,7 +23,7 @@ namespace BlackGui
const BlackMisc::Network::CAuthenticatedUser &CForm::getSwiftDbUser() const const BlackMisc::Network::CAuthenticatedUser &CForm::getSwiftDbUser() const
{ {
return this->m_swiftDbUser.get(); return this->m_swiftDbUser.getThreadLocal();
} }
void CForm::ps_userChanged() void CForm::ps_userChanged()

View File

@@ -89,7 +89,7 @@ namespace BlackGui
{ {
Q_ASSERT_X(sGui && sGui->hasWebDataServices(), Q_FUNC_INFO, "Missing web data services"); Q_ASSERT_X(sGui && sGui->hasWebDataServices(), Q_FUNC_INFO, "Missing web data services");
Q_ASSERT_X(this->m_simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator"); Q_ASSERT_X(this->m_simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
const CDistributorListPreferences prefs(this->m_distributorPreferences.getCopy()); const CDistributorListPreferences prefs(this->m_distributorPreferences.get());
const CDistributorList distributors(prefs.getDistributors(this->m_simulator)); const CDistributorList distributors(prefs.getDistributors(this->m_simulator));
if (!distributors.isEmpty()) { return distributors; } if (!distributors.isEmpty()) { return distributors; }
@@ -115,7 +115,7 @@ namespace BlackGui
bool COwnModelSetForm::hasDIstributorPreferences() const bool COwnModelSetForm::hasDIstributorPreferences() const
{ {
const CDistributorListPreferences prefs(this->m_distributorPreferences.getCopy()); const CDistributorListPreferences prefs(this->m_distributorPreferences.get());
return !prefs.getDistributors(this->m_simulator).isEmpty(); return !prefs.getDistributors(this->m_simulator).isEmpty();
} }
} // ns } // ns

View File

@@ -65,7 +65,7 @@ namespace BlackMisc
CModelCaches::CModelCaches(QObject *parent) : IMultiSimulatorModelCaches(parent) CModelCaches::CModelCaches(QObject *parent) : IMultiSimulatorModelCaches(parent)
{ {
this->m_currentSimulator.synchronize(); this->m_currentSimulator.synchronize();
const CSimulatorInfo sim(this->m_currentSimulator.getCopy()); const CSimulatorInfo sim(this->m_currentSimulator.get());
this->syncronizeCacheImpl(sim); this->syncronizeCacheImpl(sim);
const QString simStr(sim.toQString(true)); const QString simStr(sim.toQString(true));
CLogMessage(this).info("Initialized model caches to %1") << simStr; CLogMessage(this).info("Initialized model caches to %1") << simStr;
@@ -76,10 +76,10 @@ namespace BlackMisc
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator"); Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
switch (simulator.getSimulator()) switch (simulator.getSimulator())
{ {
case CSimulatorInfo::FS9: return this->m_modelCacheFs9.getCopy(); case CSimulatorInfo::FS9: return this->m_modelCacheFs9.get();
case CSimulatorInfo::FSX: return this->m_modelCacheFsx.getCopy(); case CSimulatorInfo::FSX: return this->m_modelCacheFsx.get();
case CSimulatorInfo::P3D: return this->m_modelCacheP3D.getCopy(); case CSimulatorInfo::P3D: return this->m_modelCacheP3D.get();
case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.getCopy(); case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.get();
default: default:
Q_ASSERT_X(false, Q_FUNC_INFO, "wrong simulator"); Q_ASSERT_X(false, Q_FUNC_INFO, "wrong simulator");
return CAircraftModelList(); return CAircraftModelList();
@@ -132,7 +132,7 @@ namespace BlackMisc
CStatusMessage CModelCaches::setCurrentSimulator(const CSimulatorInfo &simulator) CStatusMessage CModelCaches::setCurrentSimulator(const CSimulatorInfo &simulator)
{ {
static const CStatusMessage sameSimMsg = CStatusMessage(this).info("Same simulator"); static const CStatusMessage sameSimMsg = CStatusMessage(this).info("Same simulator");
const CSimulatorInfo s = this->m_currentSimulator.getCopy(); const CSimulatorInfo s = this->m_currentSimulator.get();
if (s == simulator) { return sameSimMsg; } if (s == simulator) { return sameSimMsg; }
const BlackMisc::CStatusMessage m = this->m_currentSimulator.set(simulator); const BlackMisc::CStatusMessage m = this->m_currentSimulator.set(simulator);
this->syncronizeCache(simulator); this->syncronizeCache(simulator);
@@ -157,7 +157,7 @@ namespace BlackMisc
CModelSetCaches::CModelSetCaches(QObject *parent) : IMultiSimulatorModelCaches(parent) CModelSetCaches::CModelSetCaches(QObject *parent) : IMultiSimulatorModelCaches(parent)
{ {
this->m_currentSimulator.synchronize(); this->m_currentSimulator.synchronize();
const CSimulatorInfo sim(this->m_currentSimulator.getCopy()); const CSimulatorInfo sim(this->m_currentSimulator.get());
this->syncronizeCacheImpl(sim); this->syncronizeCacheImpl(sim);
const QString simStr(sim.toQString(true)); const QString simStr(sim.toQString(true));
CLogMessage(this).info("Initialized model set caches to %1") << simStr; CLogMessage(this).info("Initialized model set caches to %1") << simStr;
@@ -168,10 +168,10 @@ namespace BlackMisc
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator"); Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
switch (simulator.getSimulator()) switch (simulator.getSimulator())
{ {
case CSimulatorInfo::FS9: return this->m_modelCacheFs9.getCopy(); case CSimulatorInfo::FS9: return this->m_modelCacheFs9.get();
case CSimulatorInfo::FSX: return this->m_modelCacheFsx.getCopy(); case CSimulatorInfo::FSX: return this->m_modelCacheFsx.get();
case CSimulatorInfo::P3D: return this->m_modelCacheP3D.getCopy(); case CSimulatorInfo::P3D: return this->m_modelCacheP3D.get();
case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.getCopy(); case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.get();
default: default:
Q_ASSERT_X(false, Q_FUNC_INFO, "wrong simulator"); Q_ASSERT_X(false, Q_FUNC_INFO, "wrong simulator");
return CAircraftModelList(); return CAircraftModelList();
@@ -226,7 +226,7 @@ namespace BlackMisc
CStatusMessage CModelSetCaches::setCurrentSimulator(const CSimulatorInfo &simulator) CStatusMessage CModelSetCaches::setCurrentSimulator(const CSimulatorInfo &simulator)
{ {
static const CStatusMessage sameSimMsg = CStatusMessage(this).info("Same simulator"); static const CStatusMessage sameSimMsg = CStatusMessage(this).info("Same simulator");
const CSimulatorInfo s = this->m_currentSimulator.getCopy(); const CSimulatorInfo s = this->m_currentSimulator.get();
if (s == simulator) { return sameSimMsg; } if (s == simulator) { return sameSimMsg; }
const BlackMisc::CStatusMessage m = this->m_currentSimulator.set(simulator); const BlackMisc::CStatusMessage m = this->m_currentSimulator.set(simulator);
this->syncronizeCache(simulator); this->syncronizeCache(simulator);

View File

@@ -236,7 +236,7 @@ namespace BlackMisc
virtual BlackMisc::CStatusMessage setCachedModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override; virtual BlackMisc::CStatusMessage setCachedModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
virtual QDateTime getCacheTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator) const override; virtual QDateTime getCacheTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator) const override;
virtual void syncronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) override; virtual void syncronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
virtual BlackMisc::Simulation::CSimulatorInfo getCurrentSimulator() const override { return this->m_currentSimulator.getCopy(); } virtual BlackMisc::Simulation::CSimulatorInfo getCurrentSimulator() const override { return this->m_currentSimulator.get(); }
virtual BlackMisc::CStatusMessage setCurrentSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) override; virtual BlackMisc::CStatusMessage setCurrentSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
//! @} //! @}
@@ -267,7 +267,7 @@ namespace BlackMisc
virtual BlackMisc::CStatusMessage setCachedModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override; virtual BlackMisc::CStatusMessage setCachedModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
virtual QDateTime getCacheTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator) const override; virtual QDateTime getCacheTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator) const override;
virtual void syncronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) override; virtual void syncronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
virtual BlackMisc::Simulation::CSimulatorInfo getCurrentSimulator() const override { return this->m_currentSimulator.getCopy(); } virtual BlackMisc::Simulation::CSimulatorInfo getCurrentSimulator() const override { return this->m_currentSimulator.get(); }
virtual BlackMisc::CStatusMessage setCurrentSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) override; virtual BlackMisc::CStatusMessage setCurrentSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
//! @} //! @}

View File

@@ -90,13 +90,13 @@ namespace BlackMisc
int CVPilotRulesReader::getModelsCount() const int CVPilotRulesReader::getModelsCount() const
{ {
return this->m_cachedVPilotModels.get().size(); return this->m_cachedVPilotModels.getThreadLocal().size();
} }
CAircraftModelList CVPilotRulesReader::getAsModels() CAircraftModelList CVPilotRulesReader::getAsModels()
{ {
// already cached? // already cached?
CAircraftModelList vPilotModels(this->m_cachedVPilotModels.getCopy()); CAircraftModelList vPilotModels(this->m_cachedVPilotModels.get());
if (!vPilotModels.isEmpty() || m_rules.isEmpty()) { return vPilotModels; } if (!vPilotModels.isEmpty() || m_rules.isEmpty()) { return vPilotModels; }
// important: that can take a while and should normally // important: that can take a while and should normally
@@ -109,7 +109,7 @@ namespace BlackMisc
CAircraftModelList CVPilotRulesReader::getAsModelsFromCache() const CAircraftModelList CVPilotRulesReader::getAsModelsFromCache() const
{ {
return this->m_cachedVPilotModels.getCopy(); return this->m_cachedVPilotModels.get();
} }
int CVPilotRulesReader::countRulesLoaded() const int CVPilotRulesReader::countRulesLoaded() const

View File

@@ -333,11 +333,11 @@ namespace BlackMisc
{} {}
//! Read the current value. //! Read the current value.
const T &get() const { static const T empty {}; return *(isValid() ? static_cast<const T *>(getVariant().data()) : &empty); } const T &getThreadLocal() const { static const T empty {}; return *(isValid() ? static_cast<const T *>(getVariant().data()) : &empty); }
//! Get a copy of the current value. //! Get a copy of the current value.
//! \threadsafe //! \threadsafe
T getCopy() const { return isValid() ? getVariantCopy().template value<T>() : T{}; } T get() const { return isValid() ? getVariantCopy().template value<T>() : T{}; }
//! Write a new value. Must be called from the thread in which the owner lives. //! Write a new value. Must be called from the thread in which the owner lives.
CStatusMessage set(const T &value, qint64 timestamp = 0) { return m_page.setValue(m_element, CVariant::from(value), timestamp); } CStatusMessage set(const T &value, qint64 timestamp = 0) { return m_page.setValue(m_element, CVariant::from(value), timestamp); }

View File

@@ -656,8 +656,8 @@ namespace BlackSimPlugin
} }
else else
{ {
CLogMessage(this).debug() << "Starting XBus on" << m_xbusServerSetting.get(); CLogMessage(this).debug() << "Starting XBus on" << m_xbusServerSetting.getThreadLocal();
m_conn = CSimulatorXPlane::connectionFromString(m_xbusServerSetting.get()); m_conn = CSimulatorXPlane::connectionFromString(m_xbusServerSetting.getThreadLocal());
m_watcher = new QDBusServiceWatcher(xbusServiceName(), m_conn, QDBusServiceWatcher::WatchForRegistration, this); m_watcher = new QDBusServiceWatcher(xbusServiceName(), m_conn, QDBusServiceWatcher::WatchForRegistration, this);
connect(m_watcher, &QDBusServiceWatcher::serviceRegistered, this, &CSimulatorXPlaneListener::ps_serviceRegistered); connect(m_watcher, &QDBusServiceWatcher::serviceRegistered, this, &CSimulatorXPlaneListener::ps_serviceRegistered);
} }
@@ -674,7 +674,7 @@ namespace BlackSimPlugin
bool CSimulatorXPlaneListener::isXBusRunning() const bool CSimulatorXPlaneListener::isXBusRunning() const
{ {
QDBusConnection conn = CSimulatorXPlane::connectionFromString(m_xbusServerSetting.get()); QDBusConnection conn = CSimulatorXPlane::connectionFromString(m_xbusServerSetting.getThreadLocal());
CXBusServiceProxy *service = new CXBusServiceProxy(conn); CXBusServiceProxy *service = new CXBusServiceProxy(conn);
CXBusTrafficProxy *traffic = new CXBusTrafficProxy(conn); CXBusTrafficProxy *traffic = new CXBusTrafficProxy(conn);

View File

@@ -54,7 +54,7 @@ namespace BlackSimPlugin
connect(ui->bb_OkCancel, &QDialogButtonBox::accepted, this, &CSimulatorXPlaneConfigWindow::close); connect(ui->bb_OkCancel, &QDialogButtonBox::accepted, this, &CSimulatorXPlaneConfigWindow::close);
connect(ui->bb_OkCancel, &QDialogButtonBox::rejected, this, &CSimulatorXPlaneConfigWindow::close); connect(ui->bb_OkCancel, &QDialogButtonBox::rejected, this, &CSimulatorXPlaneConfigWindow::close);
ui->cp_XBusServer->setCurrentText(m_xbusServerSetting.get()); ui->cp_XBusServer->setCurrentText(m_xbusServerSetting.getThreadLocal());
if (xBusAvailable()) if (xBusAvailable())
connect(ui->pb_InstallXBus, &QPushButton::clicked, this, &CSimulatorXPlaneConfigWindow::ps_installXBus); connect(ui->pb_InstallXBus, &QPushButton::clicked, this, &CSimulatorXPlaneConfigWindow::ps_installXBus);
@@ -74,7 +74,7 @@ namespace BlackSimPlugin
void CSimulatorXPlaneConfigWindow::ps_storeSettings() void CSimulatorXPlaneConfigWindow::ps_storeSettings()
{ {
if (ui->cp_XBusServer->currentText() != m_xbusServerSetting.get()) if (ui->cp_XBusServer->currentText() != m_xbusServerSetting.getThreadLocal())
{ {
m_xbusServerSetting.set(ui->cp_XBusServer->currentText()); m_xbusServerSetting.set(ui->cp_XBusServer->currentText());
} }

View File

@@ -54,7 +54,7 @@ CSwiftLauncher::CSwiftLauncher(QWidget *parent) :
this->ui->le_DBusServerPort->setValidator(new QIntValidator(0, 65535, this)); this->ui->le_DBusServerPort->setValidator(new QIntValidator(0, 65535, this));
// default from settings // default from settings
const QString dbus(this->m_dbusServerAddress.get()); const QString dbus(this->m_dbusServerAddress.getThreadLocal());
this->setDefault(dbus); this->setDefault(dbus);
} }
@@ -307,7 +307,7 @@ void CSwiftLauncher::ps_loadedUpdateInfo(bool success)
return; return;
} }
const CUpdateInfo updateInfo(this->m_updateInfo.get()); const CUpdateInfo updateInfo(this->m_updateInfo.getThreadLocal());
const QString latestVersion(updateInfo.getLatestVersion()) ; // need to get this from somewhere const QString latestVersion(updateInfo.getLatestVersion()) ; // need to get this from somewhere
CFailoverUrlList downloadUrls(updateInfo.getDownloadUrls()); CFailoverUrlList downloadUrls(updateInfo.getDownloadUrls());
bool newVersionAvailable = CVersion::isNewerVersion(latestVersion) && !downloadUrls.isEmpty(); bool newVersionAvailable = CVersion::isNewerVersion(latestVersion) && !downloadUrls.isEmpty();