mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-30 05:51:23 +08:00
refs #697 BlackCore settings renamed and reorganized.
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "blackcore/blackcoreexport.h"
|
||||
#include "blackcore/network.h"
|
||||
#include "blackcore/settings/network.h"
|
||||
#include "blackcore/vatsim/vatsimsettings.h"
|
||||
#include "blackcore/tokenbucket.h"
|
||||
#include "blackmisc/aviation/aircrafticaocode.h"
|
||||
#include "blackmisc/aviation/aircraftparts.h"
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace BlackCore
|
||||
// void
|
||||
}
|
||||
|
||||
Settings::CSettingsReader CVatsimBookingReader::getSettings() const
|
||||
CReaderSettings CVatsimBookingReader::getSettings() const
|
||||
{
|
||||
return this->m_settings.get();
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace BlackCore
|
||||
//! \name BlackCore::CThreadedReader overrides
|
||||
//! @{
|
||||
virtual void cleanup() override;
|
||||
virtual BlackCore::Settings::CSettingsReader getSettings() const override;
|
||||
virtual BlackCore::Vatsim::CReaderSettings getSettings() const override;
|
||||
//! @}
|
||||
|
||||
private slots:
|
||||
@@ -60,7 +60,7 @@ namespace BlackCore
|
||||
void ps_read();
|
||||
|
||||
private:
|
||||
BlackMisc::CSettingReadOnly<BlackCore::Settings::SettingsVatsimBookings> m_settings { this };
|
||||
BlackMisc::CSettingReadOnly<BlackCore::Vatsim::TVatsimBookings> m_settings { this };
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -52,7 +52,6 @@ using namespace BlackMisc::Geo;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackCore::Data;
|
||||
using namespace BlackCore::Settings;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
@@ -179,7 +178,7 @@ namespace BlackCore
|
||||
// void
|
||||
}
|
||||
|
||||
CSettingsReader CVatsimDataFileReader::getSettings() const
|
||||
CReaderSettings CVatsimDataFileReader::getSettings() const
|
||||
{
|
||||
return this->m_settings.get();
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace BlackCore
|
||||
//! \name BlackCore::CThreadedReader overrides
|
||||
//! @{
|
||||
virtual void cleanup() override;
|
||||
virtual BlackCore::Settings::CSettingsReader getSettings() const override;
|
||||
virtual BlackCore::Vatsim::CReaderSettings getSettings() const override;
|
||||
//! @}
|
||||
|
||||
private slots:
|
||||
@@ -142,7 +142,7 @@ namespace BlackCore
|
||||
BlackMisc::Aviation::CAtcStationList m_atcStations;
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_aircraft;
|
||||
BlackMisc::CData<BlackCore::Data::VatsimSetup> m_lastGoodSetup { this };
|
||||
BlackMisc::CSettingReadOnly<BlackCore::Settings::SettingsVatsimDataFile> m_settings { this };
|
||||
BlackMisc::CSettingReadOnly<BlackCore::Vatsim::TVatsimDataFile> m_settings { this };
|
||||
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Network::CVoiceCapabilities> m_voiceCapabilities;
|
||||
|
||||
//! Split line and assign values to their corresponding attribute names
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace BlackCore
|
||||
// void
|
||||
}
|
||||
|
||||
Settings::CSettingsReader CVatsimMetarReader::getSettings() const
|
||||
CReaderSettings CVatsimMetarReader::getSettings() const
|
||||
{
|
||||
return m_settings.get();
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace BlackCore
|
||||
//! \name BlackCore::CThreadedReader overrides
|
||||
//! @{
|
||||
virtual void cleanup() override;
|
||||
virtual BlackCore::Settings::CSettingsReader getSettings() const override;
|
||||
virtual BlackCore::Vatsim::CReaderSettings getSettings() const override;
|
||||
//! @}
|
||||
|
||||
private:
|
||||
@@ -77,7 +77,7 @@ namespace BlackCore
|
||||
private:
|
||||
BlackMisc::Weather::CMetarDecoder m_metarDecoder;
|
||||
BlackMisc::Weather::CMetarList m_metars;
|
||||
BlackMisc::CSettingReadOnly<BlackCore::Settings::SettingsVatsimMetars> m_settings { this };
|
||||
BlackMisc::CSettingReadOnly<BlackCore::Vatsim::TVatsimMetars> m_settings { this };
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
78
src/blackcore/vatsim/vatsimsettings.cpp
Normal file
78
src/blackcore/vatsim/vatsimsettings.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/* 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 "vatsimsettings.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
namespace Vatsim
|
||||
{
|
||||
CReaderSettings::CReaderSettings()
|
||||
{ }
|
||||
|
||||
CReaderSettings::CReaderSettings(const CTime &initialTime, const CTime &periodicTime, bool neverUpdate) :
|
||||
m_initialTime(initialTime), m_periodicTime(periodicTime), m_neverUpdate(neverUpdate)
|
||||
{ }
|
||||
|
||||
QString CReaderSettings::convertToQString(bool i18n) const
|
||||
{
|
||||
QString s("CReaderSettings");
|
||||
s.append(" ").append(this->m_initialTime.convertToQString(i18n));
|
||||
s.append(" ").append(this->m_periodicTime.convertToQString(i18n));
|
||||
return s;
|
||||
}
|
||||
|
||||
const CReaderSettings &CReaderSettings::neverUpdateSettings()
|
||||
{
|
||||
static const CReaderSettings s(CTime{ 1.0, CTimeUnit::d()}, CTime{ 1.0, CTimeUnit::d()}, true);
|
||||
return s;
|
||||
}
|
||||
|
||||
CVariant CReaderSettings::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexInitialTime:
|
||||
return this->m_initialTime.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexPeriodicTime:
|
||||
return this->m_periodicTime.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexNeverUpdate:
|
||||
return CVariant::fromValue(this->m_neverUpdate);
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void CReaderSettings::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CReaderSettings>(); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexInitialTime:
|
||||
this->m_initialTime.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexPeriodicTime:
|
||||
this->m_periodicTime.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexNeverUpdate:
|
||||
this->m_neverUpdate = variant.toBool();
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
159
src/blackcore/vatsim/vatsimsettings.h
Normal file
159
src/blackcore/vatsim/vatsimsettings.h
Normal file
@@ -0,0 +1,159 @@
|
||||
/* 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_VATSIM_SETTINGS_H
|
||||
#define BLACKCORE_VATSIM_SETTINGS_H
|
||||
|
||||
#include "blackcore/blackcoreexport.h"
|
||||
#include "blackmisc/settingscache.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include "blackmisc/pq/time.h"
|
||||
#include "blackmisc/network/serverlist.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
namespace Vatsim
|
||||
{
|
||||
/*!
|
||||
* Virtual air traffic servers
|
||||
*/
|
||||
struct TTrafficServers : public BlackMisc::TSettingTrait<BlackMisc::Network::CServerList>
|
||||
{
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "network/trafficservers"; }
|
||||
};
|
||||
|
||||
/*!
|
||||
* Currently selected virtual air traffic server
|
||||
*/
|
||||
struct TCurrentTrafficServer : public BlackMisc::TSettingTrait<BlackMisc::Network::CServer>
|
||||
{
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "network/currenttrafficserver"; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::defaultValue
|
||||
static const BlackMisc::Network::CServer &defaultValue()
|
||||
{
|
||||
using namespace BlackMisc::Network;
|
||||
static const CServer dv("Testserver", "Client project testserver", "vatsim-germany.org", 6809, CUser("guest", "Guest Client project", "", "guest"));
|
||||
return dv;
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
* Settings used with readers
|
||||
*/
|
||||
class BLACKCORE_EXPORT CReaderSettings : public BlackMisc::CValueObject<BlackCore::Vatsim::CReaderSettings>
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexInitialTime = BlackMisc::CPropertyIndex::GlobalIndexCSettingsReaders,
|
||||
IndexPeriodicTime,
|
||||
IndexNeverUpdate
|
||||
};
|
||||
|
||||
//! Default constructor.
|
||||
CReaderSettings();
|
||||
|
||||
//! Simplified constructor
|
||||
CReaderSettings(const BlackMisc::PhysicalQuantities::CTime &initialTime, const BlackMisc::PhysicalQuantities::CTime &periodicTime, bool neverUpdate = false);
|
||||
|
||||
//! Get time
|
||||
const BlackMisc::PhysicalQuantities::CTime &getInitialTime() const { return m_initialTime; }
|
||||
|
||||
//! Set time
|
||||
void setInitialTime(const BlackMisc::PhysicalQuantities::CTime &time) { m_initialTime = time; }
|
||||
|
||||
//! Get time
|
||||
const BlackMisc::PhysicalQuantities::CTime &getPeriodicTime() const { return m_periodicTime; }
|
||||
|
||||
//! Set time
|
||||
void setPeriodicTime(const BlackMisc::PhysicalQuantities::CTime &time) { m_periodicTime = time; }
|
||||
|
||||
//! Never ever update?
|
||||
bool isNeverUpdate() const { return m_neverUpdate; }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
BlackMisc::CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const BlackMisc::CVariant &variant);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! Settings used when a reader is manually triggered and never updates
|
||||
static const CReaderSettings &neverUpdateSettings();
|
||||
|
||||
private:
|
||||
BlackMisc::PhysicalQuantities::CTime m_initialTime { 30.0, BlackMisc::PhysicalQuantities::CTimeUnit::s()};
|
||||
BlackMisc::PhysicalQuantities::CTime m_periodicTime { 30.0, BlackMisc::PhysicalQuantities::CTimeUnit::s()};
|
||||
bool m_neverUpdate = false;
|
||||
|
||||
BLACK_METACLASS(
|
||||
CReaderSettings,
|
||||
BLACK_METAMEMBER(initialTime),
|
||||
BLACK_METAMEMBER(periodicTime),
|
||||
BLACK_METAMEMBER(neverUpdate)
|
||||
);
|
||||
};
|
||||
|
||||
//! Reader settings
|
||||
struct TVatsimBookings : public BlackMisc::TSettingTrait<CReaderSettings>
|
||||
{
|
||||
//! \copydoc BlackCore::TSettingTrait::key
|
||||
static const char *key() { return "vatsimreaders/bookings"; }
|
||||
|
||||
//! \copydoc BlackCore::TSettingTrait::defaultValue
|
||||
static const BlackCore::Vatsim::CReaderSettings &defaultValue()
|
||||
{
|
||||
static const BlackCore::Vatsim::CReaderSettings reader {{30.0, BlackMisc::PhysicalQuantities::CTimeUnit::s()}, {120.0, BlackMisc::PhysicalQuantities::CTimeUnit::s()}};
|
||||
return reader;
|
||||
}
|
||||
};
|
||||
|
||||
//! Reader settings
|
||||
struct TVatsimDataFile : public BlackMisc::TSettingTrait<CReaderSettings>
|
||||
{
|
||||
//! \copydoc BlackCore::TSettingTrait::key
|
||||
static const char *key() { return "vatsimreaders/datafile"; }
|
||||
|
||||
//! \copydoc BlackCore::TSettingTrait::defaultValue
|
||||
static const BlackCore::Vatsim::CReaderSettings &defaultValue()
|
||||
{
|
||||
static const BlackCore::Vatsim::CReaderSettings reader {{25.0, BlackMisc::PhysicalQuantities::CTimeUnit::s()}, {120.0, BlackMisc::PhysicalQuantities::CTimeUnit::s()}};
|
||||
return reader;
|
||||
}
|
||||
};
|
||||
|
||||
//! Reader settings
|
||||
struct TVatsimMetars : public BlackMisc::TSettingTrait<CReaderSettings>
|
||||
{
|
||||
//! \copydoc BlackCore::TSettingTrait::key
|
||||
static const char *key() { return "vatsimreaders/metars"; }
|
||||
|
||||
//! \copydoc BlackCore::TSettingTrait::defaultValue
|
||||
static const BlackCore::Vatsim::CReaderSettings &defaultValue()
|
||||
{
|
||||
static const BlackCore::Vatsim::CReaderSettings reader {{35.0, BlackMisc::PhysicalQuantities::CTimeUnit::s()}, {300.0, BlackMisc::PhysicalQuantities::CTimeUnit::s()}};
|
||||
return reader;
|
||||
}
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Q_DECLARE_METATYPE(BlackCore::Vatsim::CReaderSettings)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackCore::Vatsim::CReaderSettings>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackCore::Vatsim::CReaderSettings>)
|
||||
|
||||
#endif
|
||||
@@ -35,7 +35,6 @@ using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackCore::Data;
|
||||
using namespace BlackCore::Settings;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user