From 74638c4c105d35912436479520ecae643318ab95 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 24 May 2016 00:15:56 +0200 Subject: [PATCH] refs #649, caches for DB data --- src/blackcore/data/dbcaches.cpp | 59 ++++++++++++++++++++ src/blackcore/data/dbcaches.h | 95 +++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 src/blackcore/data/dbcaches.cpp create mode 100644 src/blackcore/data/dbcaches.h diff --git a/src/blackcore/data/dbcaches.cpp b/src/blackcore/data/dbcaches.cpp new file mode 100644 index 000000000..157929095 --- /dev/null +++ b/src/blackcore/data/dbcaches.cpp @@ -0,0 +1,59 @@ +/* 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 BlackMisc::Network::CUrl &DbIcaoReaderBaseUrl::defaultValue() + { + static const CUrl url; + return url; + } + + } // ns +} // ns diff --git a/src/blackcore/data/dbcaches.h b/src/blackcore/data/dbcaches.h new file mode 100644 index 000000000..c39584fe9 --- /dev/null +++ b/src/blackcore/data/dbcaches.h @@ -0,0 +1,95 @@ +/* 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. + */ + +//! \file + +#ifndef BLACKCORE_DATA_DBCACHES +#define BLACKCORE_DATA_DBCACHES + +#include "blackmisc/datacache.h" +#include "blackmisc/simulation/aircraftmodellist.h" +#include "blackmisc/aviation/airlineicaocodelist.h" +#include "blackmisc/aviation/aircrafticaocodelist.h" +#include "blackmisc/aviation/liverylist.h" +#include "blackmisc/network/url.h" +#include "blackmisc/countrylist.h" + +#include +#include + +namespace BlackCore +{ + namespace Data + { + //! Trait for DB model cache + struct DbModelCache : public BlackMisc::CDataTrait + { + //! Default value + static const BlackMisc::Simulation::CAircraftModelList &defaultValue(); + + //! Key in data cache + static const char *key() { return "dbmodelcache"; } + }; + + //! Trait for DB airline ICAO codes + struct DbAirlineIcaoCache : public BlackMisc::CDataTrait + { + //! Default value + static const BlackMisc::Aviation::CAirlineIcaoCodeList &defaultValue(); + + //! Key in data cache + static const char *key() { return "dbairlineicaocache"; } + }; + + + //! Trait for DB aircraft ICAO codes + struct DbAircraftIcaoCache : public BlackMisc::CDataTrait + { + //! Default value + static const BlackMisc::Aviation::CAircraftIcaoCodeList &defaultValue(); + + //! Key in data cache + static const char *key() { return "dbaircrafticaocache"; } + }; + + //! Trait for DB countries + struct DbCountryCache : public BlackMisc::CDataTrait + { + //! Default value + static const BlackMisc::CCountryList &defaultValue(); + + //! Key in data cache + static const char *key() { return "dbcountrycache"; } + }; + + //! Trait for DB liveries + struct DbLiveryCache : public BlackMisc::CDataTrait + { + //! Default value + static const BlackMisc::Aviation::CLiveryList &defaultValue(); + + //! Key in data cache + static const char *key() { return "dbliverycache"; } + }; + + //! Trait for ICAO reader base URL + struct DbIcaoReaderBaseUrl : public BlackMisc::CDataTrait + { + //! Default value + static const BlackMisc::Network::CUrl &defaultValue(); + + //! Key in data cache + static const char *key() { return "dbicaoreaderurl"; } + }; + + + } // ns +} // ns + +#endif // guard