From 2a99bed0cd6171d59dd04bf9454dc08514abdcdc Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 8 Jun 2016 16:46:03 +0200 Subject: [PATCH] refs #656, MS review items https://dev.vatsim-germany.org/issues/656#note-4 Remove defaultValue where not needed --- src/blackcore/data/authenticateduser.h | 9 +-- src/blackcore/data/dbcaches.cpp | 70 --------------------- src/blackcore/data/dbcaches.h | 24 ------- src/blackcore/data/globalsetup.h | 8 --- src/blackcore/data/updateinfo.h | 7 --- src/blackcore/data/vatsimsetup.h | 8 --- src/blackgui/settings/settingsdockwidget.h | 7 --- src/blackmisc/simulation/data/modelcaches.h | 7 --- 8 files changed, 2 insertions(+), 138 deletions(-) delete mode 100644 src/blackcore/data/dbcaches.cpp diff --git a/src/blackcore/data/authenticateduser.h b/src/blackcore/data/authenticateduser.h index f2d187a4e..281097573 100644 --- a/src/blackcore/data/authenticateduser.h +++ b/src/blackcore/data/authenticateduser.h @@ -30,14 +30,9 @@ namespace BlackCore //! First load is synchronous static constexpr bool isPinned() { return true; } - //! Default value - static const BlackMisc::Network::CAuthenticatedUser &defaultValue() - { - static const BlackMisc::Network::CAuthenticatedUser user; - return user; - } + //! Cache lifetime + static int timeToLive() { return 18 * 60 * 60 * 1000; } }; - } // ns } // ns diff --git a/src/blackcore/data/dbcaches.cpp b/src/blackcore/data/dbcaches.cpp deleted file mode 100644 index ef07a73c0..000000000 --- a/src/blackcore/data/dbcaches.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (C) 2016 - * swift project community / contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#include "dbcaches.h" -#include - -using namespace BlackMisc; -using namespace BlackMisc::Network; -using namespace BlackMisc::Aviation; -using namespace BlackMisc::Simulation; - -namespace BlackCore -{ - namespace Data - { - const BlackMisc::Simulation::CAircraftModelList &DbModelCache::defaultValue() - { - static const CAircraftModelList ml; - return ml; - } - - const BlackMisc::Aviation::CAirlineIcaoCodeList &DbAirlineIcaoCache::defaultValue() - { - static const CAirlineIcaoCodeList al; - return al; - } - - const BlackMisc::Aviation::CAircraftIcaoCodeList &DbAircraftIcaoCache::defaultValue() - { - static const CAircraftIcaoCodeList al; - return al; - } - - const BlackMisc::CCountryList &DbCountryCache::defaultValue() - { - static const CCountryList cl; - return cl; - } - - const BlackMisc::Aviation::CLiveryList &DbLiveryCache::defaultValue() - { - static const CLiveryList ll; - return ll; - } - - const CDistributorList &DbDistributorCache::defaultValue() - { - static const CDistributorList dl; - return dl; - } - - const BlackMisc::Network::CUrl &DbIcaoReaderBaseUrl::defaultValue() - { - static const CUrl url; - return url; - } - - const CUrl &DbModelReaderBaseUrl::defaultValue() - { - static const CUrl url; - return url; - } - } // ns -} // ns diff --git a/src/blackcore/data/dbcaches.h b/src/blackcore/data/dbcaches.h index 427e8e59b..d2eb186ea 100644 --- a/src/blackcore/data/dbcaches.h +++ b/src/blackcore/data/dbcaches.h @@ -31,9 +31,6 @@ namespace BlackCore //! Trait for DB model cache struct DbModelCache : public BlackMisc::CDataTrait { - //! Default value - static const BlackMisc::Simulation::CAircraftModelList &defaultValue(); - //! Defer loading static constexpr bool isDeferred() { return true; } @@ -44,9 +41,6 @@ namespace BlackCore //! Trait for DB distributor cache struct DbDistributorCache : public BlackMisc::CDataTrait { - //! Default value - static const BlackMisc::Simulation::CDistributorList &defaultValue(); - //! Defer loading (no currently small) static constexpr bool isDeferred() { return false; } @@ -57,9 +51,6 @@ namespace BlackCore //! Trait for DB liveries struct DbLiveryCache : public BlackMisc::CDataTrait { - //! Default value - static const BlackMisc::Aviation::CLiveryList &defaultValue(); - //! Defer loading static constexpr bool isDeferred() { return true; } @@ -70,9 +61,6 @@ namespace BlackCore //! Trait for DB airline ICAO codes struct DbAirlineIcaoCache : public BlackMisc::CDataTrait { - //! Default value - static const BlackMisc::Aviation::CAirlineIcaoCodeList &defaultValue(); - //! Defer loading static constexpr bool isDeferred() { return true; } @@ -84,9 +72,6 @@ namespace BlackCore //! Trait for DB aircraft ICAO codes struct DbAircraftIcaoCache : public BlackMisc::CDataTrait { - //! Default value - static const BlackMisc::Aviation::CAircraftIcaoCodeList &defaultValue(); - //! Defer loading static constexpr bool isDeferred() { return true; } @@ -97,9 +82,6 @@ namespace BlackCore //! Trait for DB countries struct DbCountryCache : public BlackMisc::CDataTrait { - //! Default value - static const BlackMisc::CCountryList &defaultValue(); - //! Defer loading (no currently small) static constexpr bool isDeferred() { return false; } @@ -110,9 +92,6 @@ namespace BlackCore //! Trait for ICAO reader base URL struct DbIcaoReaderBaseUrl : public BlackMisc::CDataTrait { - //! Default value - static const BlackMisc::Network::CUrl &defaultValue(); - //! First load is synchronous static constexpr bool isPinned() { return true; } @@ -123,9 +102,6 @@ namespace BlackCore //! Trait for ICAO reader base URL struct DbModelReaderBaseUrl : public BlackMisc::CDataTrait { - //! Default value - static const BlackMisc::Network::CUrl &defaultValue(); - //! First load is synchronous static constexpr bool isPinned() { return true; } diff --git a/src/blackcore/data/globalsetup.h b/src/blackcore/data/globalsetup.h index 2ac8d994b..45f58ca03 100644 --- a/src/blackcore/data/globalsetup.h +++ b/src/blackcore/data/globalsetup.h @@ -203,15 +203,7 @@ namespace BlackCore //! First load is synchronous static constexpr bool isPinned() { return true; } - - //! Default value - static const CGlobalSetup &defaultValue() - { - static const CGlobalSetup gs; - return gs; - } }; - } // ns } // ns diff --git a/src/blackcore/data/updateinfo.h b/src/blackcore/data/updateinfo.h index de628cb20..6201e625b 100644 --- a/src/blackcore/data/updateinfo.h +++ b/src/blackcore/data/updateinfo.h @@ -126,13 +126,6 @@ namespace BlackCore //! First load is synchronous static constexpr bool isPinned() { return true; } - - //! Default value - static const CUpdateInfo &defaultValue() - { - static const CUpdateInfo defaultValue; - return defaultValue; - } }; } // ns diff --git a/src/blackcore/data/vatsimsetup.h b/src/blackcore/data/vatsimsetup.h index c0bb65218..411e3941f 100644 --- a/src/blackcore/data/vatsimsetup.h +++ b/src/blackcore/data/vatsimsetup.h @@ -129,15 +129,7 @@ namespace BlackCore //! First load is synchronous static constexpr bool isPinned() { return true; } - - //! Default value - static const CVatsimSetup &defaultValue() - { - static const CVatsimSetup gs; - return gs; - } }; - } // ns } // ns diff --git a/src/blackgui/settings/settingsdockwidget.h b/src/blackgui/settings/settingsdockwidget.h index b1a60b76b..c7d703c68 100644 --- a/src/blackgui/settings/settingsdockwidget.h +++ b/src/blackgui/settings/settingsdockwidget.h @@ -144,13 +144,6 @@ namespace BlackGui { //! Key in data cache static const char *key() { return "guidockwidget"; } - - //! Default value - static const CSettingsDockWidgets &defaultValue() - { - static const CSettingsDockWidgets defaultValue; - return defaultValue; - } }; } // ns } // ns diff --git a/src/blackmisc/simulation/data/modelcaches.h b/src/blackmisc/simulation/data/modelcaches.h index 6b8edfe79..681082424 100644 --- a/src/blackmisc/simulation/data/modelcaches.h +++ b/src/blackmisc/simulation/data/modelcaches.h @@ -32,13 +32,6 @@ namespace BlackMisc { //! Defer loading static constexpr bool isDeferred() { return true; } - - //! Default value - static const BlackMisc::Simulation::CAircraftModelList &defaultValue() - { - static const BlackMisc::Simulation::CAircraftModelList ml; - return ml; - } }; //! \name Caches for own models on disk, loaded by BlackMisc::Simulation::IAircraftModelLoader