mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 01:45:38 +08:00
Use nested namespaces (C++17 feature)
This commit is contained in:
@@ -16,31 +16,25 @@
|
||||
#include "blackmisc/settingscache.h"
|
||||
#include "blackmisc/dbusserver.h"
|
||||
|
||||
namespace BlackMisc
|
||||
namespace BlackMisc::Simulation::Settings
|
||||
{
|
||||
namespace Simulation
|
||||
/*!
|
||||
* Setting for FGSwiftBus.
|
||||
*/
|
||||
struct TFGSwiftBusServer : public BlackMisc::TSettingTrait<QString>
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
/*!
|
||||
* Setting for FGSwiftBus.
|
||||
*/
|
||||
struct TFGSwiftBusServer : public BlackMisc::TSettingTrait<QString>
|
||||
{
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "fgswiftbus/server"; }
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "fgswiftbus/server"; }
|
||||
|
||||
//! \copydoc BlackCore::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("FGSwiftBus"); return name; }
|
||||
//! \copydoc BlackCore::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("FGSwiftBus"); return name; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::defaultValue
|
||||
static QString defaultValue() { return "tcp:host=127.0.0.1,port=45003"; }
|
||||
//! \copydoc BlackMisc::TSettingTrait::defaultValue
|
||||
static QString defaultValue() { return "tcp:host=127.0.0.1,port=45003"; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::isValid
|
||||
static bool isValid(const QString &dBusAddress, QString &) { return BlackMisc::CDBusServer::isSessionOrSystemAddress(dBusAddress) || BlackMisc::CDBusServer::isQtDBusAddress(dBusAddress); }
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
//! \copydoc BlackMisc::TSettingTrait::isValid
|
||||
static bool isValid(const QString &dBusAddress, QString &) { return BlackMisc::CDBusServer::isSessionOrSystemAddress(dBusAddress) || BlackMisc::CDBusServer::isQtDBusAddress(dBusAddress); }
|
||||
};
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -14,23 +14,17 @@
|
||||
#include "blackmisc/simulation/interpolationrenderingsetup.h"
|
||||
#include "blackmisc/settingscache.h"
|
||||
|
||||
namespace BlackMisc
|
||||
namespace BlackMisc::Simulation::Settings
|
||||
{
|
||||
namespace Simulation
|
||||
//! Last model used
|
||||
struct TInterpolationAndRenderingSetupGlobal : public TSettingTrait<CInterpolationAndRenderingSetupGlobal>
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
//! Last model used
|
||||
struct TInterpolationAndRenderingSetupGlobal : public TSettingTrait<CInterpolationAndRenderingSetupGlobal>
|
||||
{
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "settingsglobalinterpolationsetup"; }
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "settingsglobalinterpolationsetup"; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("Interpolation setup"); return name; }
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
//! \copydoc BlackMisc::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("Interpolation setup"); return name; }
|
||||
};
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -14,23 +14,17 @@
|
||||
#include "blackmisc/simulation/aircraftmatchersetup.h"
|
||||
#include "blackmisc/settingscache.h"
|
||||
|
||||
namespace BlackMisc
|
||||
namespace BlackMisc::Simulation::Settings
|
||||
{
|
||||
namespace Simulation
|
||||
//! Trait for simulator settings
|
||||
struct TModelMatching : public TSettingTrait<CAircraftMatcherSetup>
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
//! Trait for simulator settings
|
||||
struct TModelMatching : public TSettingTrait<CAircraftMatcherSetup>
|
||||
{
|
||||
//! Key in data cache
|
||||
static const char *key() { return "matching"; }
|
||||
//! Key in data cache
|
||||
static const char *key() { return "matching"; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("Model matching"); return name; }
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
//! \copydoc BlackMisc::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("Model matching"); return name; }
|
||||
};
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -9,42 +9,36 @@
|
||||
#include "modelsettings.h"
|
||||
#include "blackmisc/stringutils.h"
|
||||
|
||||
namespace BlackMisc
|
||||
namespace BlackMisc::Simulation::Settings
|
||||
{
|
||||
namespace Simulation
|
||||
CModelSettings::CModelSettings()
|
||||
{ }
|
||||
|
||||
QString CModelSettings::convertToQString(bool i18n) const
|
||||
{
|
||||
namespace Settings
|
||||
Q_UNUSED(i18n);
|
||||
return QStringLiteral("Allow exclude: %1").arg(boolToYesNo(this->m_allowExcludeModels));
|
||||
}
|
||||
|
||||
QVariant CModelSettings::propertyByIndex(CPropertyIndexRef index) const
|
||||
{
|
||||
if (index.isMyself()) { return QVariant::fromValue(*this); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
CModelSettings::CModelSettings()
|
||||
{ }
|
||||
case IndexAllowExclude: return QVariant::fromValue(this->m_allowExcludeModels);
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
QString CModelSettings::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
return QStringLiteral("Allow exclude: %1").arg(boolToYesNo(this->m_allowExcludeModels));
|
||||
}
|
||||
|
||||
QVariant CModelSettings::propertyByIndex(CPropertyIndexRef index) const
|
||||
{
|
||||
if (index.isMyself()) { return QVariant::fromValue(*this); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAllowExclude: return QVariant::fromValue(this->m_allowExcludeModels);
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void CModelSettings::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.value<CModelSettings>(); return; }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAllowExclude: this->setAllowExcludedModels(variant.toBool()); break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
void CModelSettings::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.value<CModelSettings>(); return; }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAllowExclude: this->setAllowExcludedModels(variant.toBool()); break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -16,70 +16,64 @@
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/propertyindexref.h"
|
||||
|
||||
namespace BlackMisc
|
||||
namespace BlackMisc::Simulation::Settings
|
||||
{
|
||||
namespace Simulation
|
||||
//! Settings for models
|
||||
class BLACKMISC_EXPORT CModelSettings : public CValueObject<CModelSettings>
|
||||
{
|
||||
namespace Settings
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
//! Settings for models
|
||||
class BLACKMISC_EXPORT CModelSettings : public CValueObject<CModelSettings>
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexAllowExclude = CPropertyIndexRef::GlobalIndexCSimulatorSettings
|
||||
};
|
||||
IndexAllowExclude = CPropertyIndexRef::GlobalIndexCSimulatorSettings
|
||||
};
|
||||
|
||||
//! Default constructor
|
||||
CModelSettings();
|
||||
//! Default constructor
|
||||
CModelSettings();
|
||||
|
||||
//! Allow excluded models?
|
||||
bool getAllowExcludedModels() const { return m_allowExcludeModels; }
|
||||
//! Allow excluded models?
|
||||
bool getAllowExcludedModels() const { return m_allowExcludeModels; }
|
||||
|
||||
//! Allow excluded models?
|
||||
void setAllowExcludedModels(bool allow) { m_allowExcludeModels = allow; }
|
||||
//! Allow excluded models?
|
||||
void setAllowExcludedModels(bool allow) { m_allowExcludeModels = allow; }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
QVariant propertyByIndex(CPropertyIndexRef index) const;
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
QVariant propertyByIndex(CPropertyIndexRef index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
|
||||
|
||||
private:
|
||||
bool m_allowExcludeModels = false; //!< Allow excluded models in sets
|
||||
private:
|
||||
bool m_allowExcludeModels = false; //!< Allow excluded models in sets
|
||||
|
||||
BLACK_METACLASS(
|
||||
CModelSettings,
|
||||
BLACK_METAMEMBER(allowExcludeModels)
|
||||
);
|
||||
};
|
||||
BLACK_METACLASS(
|
||||
CModelSettings,
|
||||
BLACK_METAMEMBER(allowExcludeModels)
|
||||
);
|
||||
};
|
||||
|
||||
//! Trait for simulator settings
|
||||
struct TModel : public TSettingTrait<CModelSettings>
|
||||
{
|
||||
//! Key in data cache
|
||||
static const char *key() { return "Models"; }
|
||||
//! Trait for simulator settings
|
||||
struct TModel : public TSettingTrait<CModelSettings>
|
||||
{
|
||||
//! Key in data cache
|
||||
static const char *key() { return "Models"; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("Model settings"); return name; }
|
||||
};
|
||||
//! \copydoc BlackMisc::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("Model settings"); return name; }
|
||||
};
|
||||
|
||||
//! Mapping preferences for model distributor list
|
||||
struct TDistributorListPreferences : public TSettingTrait<Simulation::CDistributorListPreferences>
|
||||
{
|
||||
//! \copydoc BlackMisc::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("Distributor preferences"); return name; }
|
||||
//! Mapping preferences for model distributor list
|
||||
struct TDistributorListPreferences : public TSettingTrait<Simulation::CDistributorListPreferences>
|
||||
{
|
||||
//! \copydoc BlackMisc::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("Distributor preferences"); return name; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "mapping/distributorpreferences"; }
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "mapping/distributorpreferences"; }
|
||||
};
|
||||
} // ns
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::Settings::CModelSettings)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -9,70 +9,64 @@
|
||||
#include "swiftpluginsettings.h"
|
||||
#include "blackmisc/stringutils.h"
|
||||
|
||||
namespace BlackMisc
|
||||
namespace BlackMisc::Simulation::Settings
|
||||
{
|
||||
namespace Simulation
|
||||
CSwiftPluginSettings::CSwiftPluginSettings()
|
||||
{ }
|
||||
|
||||
void CSwiftPluginSettings::setEmulatedSimulator(const CSimulatorInfo &simulator)
|
||||
{
|
||||
namespace Settings
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
|
||||
m_emulatedSimulator = simulator;
|
||||
}
|
||||
|
||||
QString CSwiftPluginSettings::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
static const QString ms("Emulated simulator: %1, default model: '%2', log.function calls: %3");
|
||||
return ms.arg(this->m_emulatedSimulator.toQString(), m_defaultModel.getModelStringAndDbKey(), boolToYesNo(m_logFunctionCalls));
|
||||
}
|
||||
|
||||
QVariant CSwiftPluginSettings::propertyByIndex(CPropertyIndexRef index) const
|
||||
{
|
||||
if (index.isMyself()) { return QVariant::fromValue(*this); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
CSwiftPluginSettings::CSwiftPluginSettings()
|
||||
{ }
|
||||
case IndexEmulatedSimulator:
|
||||
return this->m_emulatedSimulator.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexOwnModel:
|
||||
return QVariant::fromValue(m_ownModel);
|
||||
case IndexDefaultModel:
|
||||
return QVariant::fromValue(m_defaultModel);
|
||||
case IndexLoggingFunctionCalls:
|
||||
return QVariant::fromValue(m_logFunctionCalls);
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void CSwiftPluginSettings::setEmulatedSimulator(const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
|
||||
m_emulatedSimulator = simulator;
|
||||
}
|
||||
|
||||
QString CSwiftPluginSettings::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
static const QString ms("Emulated simulator: %1, default model: '%2', log.function calls: %3");
|
||||
return ms.arg(this->m_emulatedSimulator.toQString(), m_defaultModel.getModelStringAndDbKey(), boolToYesNo(m_logFunctionCalls));
|
||||
}
|
||||
|
||||
QVariant CSwiftPluginSettings::propertyByIndex(CPropertyIndexRef index) const
|
||||
{
|
||||
if (index.isMyself()) { return QVariant::fromValue(*this); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexEmulatedSimulator:
|
||||
return this->m_emulatedSimulator.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexOwnModel:
|
||||
return QVariant::fromValue(m_ownModel);
|
||||
case IndexDefaultModel:
|
||||
return QVariant::fromValue(m_defaultModel);
|
||||
case IndexLoggingFunctionCalls:
|
||||
return QVariant::fromValue(m_logFunctionCalls);
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void CSwiftPluginSettings::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.value<CSwiftPluginSettings>(); return; }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexEmulatedSimulator:
|
||||
this->m_emulatedSimulator.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexOwnModel:
|
||||
this->m_ownModel.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexDefaultModel:
|
||||
this->m_defaultModel.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexLoggingFunctionCalls:
|
||||
this->m_logFunctionCalls = variant.toBool();
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
void CSwiftPluginSettings::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.value<CSwiftPluginSettings>(); return; }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexEmulatedSimulator:
|
||||
this->m_emulatedSimulator.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexOwnModel:
|
||||
this->m_ownModel.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexDefaultModel:
|
||||
this->m_defaultModel.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexLoggingFunctionCalls:
|
||||
this->m_logFunctionCalls = variant.toBool();
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -17,90 +17,84 @@
|
||||
#include "blackmisc/propertyindexref.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
|
||||
namespace BlackMisc
|
||||
namespace BlackMisc::Simulation::Settings
|
||||
{
|
||||
namespace Simulation
|
||||
//! Settings for models
|
||||
class BLACKMISC_EXPORT CSwiftPluginSettings : public BlackMisc::CValueObject<CSwiftPluginSettings>
|
||||
{
|
||||
namespace Settings
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
//! Settings for models
|
||||
class BLACKMISC_EXPORT CSwiftPluginSettings : public BlackMisc::CValueObject<CSwiftPluginSettings>
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexEmulatedSimulator = CPropertyIndexRef::GlobalIndexCSwiftPluignSettings,
|
||||
IndexOwnModel,
|
||||
IndexDefaultModel,
|
||||
IndexLoggingFunctionCalls
|
||||
};
|
||||
IndexEmulatedSimulator = CPropertyIndexRef::GlobalIndexCSwiftPluignSettings,
|
||||
IndexOwnModel,
|
||||
IndexDefaultModel,
|
||||
IndexLoggingFunctionCalls
|
||||
};
|
||||
|
||||
//! Default constructor
|
||||
CSwiftPluginSettings();
|
||||
//! Default constructor
|
||||
CSwiftPluginSettings();
|
||||
|
||||
//! Emulated simualtor
|
||||
CSimulatorInfo getEmulatedSimulator() const { return m_emulatedSimulator; }
|
||||
//! Emulated simualtor
|
||||
CSimulatorInfo getEmulatedSimulator() const { return m_emulatedSimulator; }
|
||||
|
||||
//! Emulated simualtor
|
||||
void setEmulatedSimulator(const CSimulatorInfo &simulator);
|
||||
//! Emulated simualtor
|
||||
void setEmulatedSimulator(const CSimulatorInfo &simulator);
|
||||
|
||||
//! Get own model
|
||||
const CAircraftModel &getOwnModel() const { return m_ownModel; }
|
||||
//! Get own model
|
||||
const CAircraftModel &getOwnModel() const { return m_ownModel; }
|
||||
|
||||
//! Set own model
|
||||
void setOwnModel(const CAircraftModel &ownModel) { m_ownModel = ownModel; }
|
||||
//! Set own model
|
||||
void setOwnModel(const CAircraftModel &ownModel) { m_ownModel = ownModel; }
|
||||
|
||||
//! Get default model
|
||||
const CAircraftModel &getDefaultModel() const { return m_defaultModel; }
|
||||
//! Get default model
|
||||
const CAircraftModel &getDefaultModel() const { return m_defaultModel; }
|
||||
|
||||
//! Set default model
|
||||
void setDefaultModel(const CAircraftModel &defaultModel) { m_defaultModel = defaultModel; }
|
||||
//! Set default model
|
||||
void setDefaultModel(const CAircraftModel &defaultModel) { m_defaultModel = defaultModel; }
|
||||
|
||||
//! Log function calls?
|
||||
bool isLoggingFunctionCalls() const { return m_logFunctionCalls; }
|
||||
//! Log function calls?
|
||||
bool isLoggingFunctionCalls() const { return m_logFunctionCalls; }
|
||||
|
||||
//! Log function calls?
|
||||
void setLoggingFunctionCalls(bool log) { m_logFunctionCalls = log; }
|
||||
//! Log function calls?
|
||||
void setLoggingFunctionCalls(bool log) { m_logFunctionCalls = log; }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
QVariant propertyByIndex(CPropertyIndexRef index) const;
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
QVariant propertyByIndex(CPropertyIndexRef index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
|
||||
|
||||
private:
|
||||
CSimulatorInfo m_emulatedSimulator { CSimulatorInfo::P3D }; // simulator with default value
|
||||
CAircraftModel m_ownModel;
|
||||
CAircraftModel m_defaultModel;
|
||||
bool m_logFunctionCalls = true;
|
||||
private:
|
||||
CSimulatorInfo m_emulatedSimulator { CSimulatorInfo::P3D }; // simulator with default value
|
||||
CAircraftModel m_ownModel;
|
||||
CAircraftModel m_defaultModel;
|
||||
bool m_logFunctionCalls = true;
|
||||
|
||||
BLACK_METACLASS(
|
||||
CSwiftPluginSettings,
|
||||
BLACK_METAMEMBER(emulatedSimulator),
|
||||
BLACK_METAMEMBER(ownModel),
|
||||
BLACK_METAMEMBER(defaultModel),
|
||||
BLACK_METAMEMBER(logFunctionCalls)
|
||||
);
|
||||
};
|
||||
BLACK_METACLASS(
|
||||
CSwiftPluginSettings,
|
||||
BLACK_METAMEMBER(emulatedSimulator),
|
||||
BLACK_METAMEMBER(ownModel),
|
||||
BLACK_METAMEMBER(defaultModel),
|
||||
BLACK_METAMEMBER(logFunctionCalls)
|
||||
);
|
||||
};
|
||||
|
||||
//! Trait for swift plugin settings
|
||||
struct TSwiftPlugin : public BlackMisc::TSettingTrait<CSwiftPluginSettings>
|
||||
{
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "settingsswiftplugin"; }
|
||||
//! Trait for swift plugin settings
|
||||
struct TSwiftPlugin : public BlackMisc::TSettingTrait<CSwiftPluginSettings>
|
||||
{
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "settingsswiftplugin"; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("swift plugin"); return name; }
|
||||
//! \copydoc BlackMisc::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("swift plugin"); return name; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::isValid
|
||||
static bool isValid(const CSwiftPluginSettings &value, QString &) { return value.getEmulatedSimulator().isSingleSimulator(); }
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
//! \copydoc BlackMisc::TSettingTrait::isValid
|
||||
static bool isValid(const CSwiftPluginSettings &value, QString &) { return value.getEmulatedSimulator().isSingleSimulator(); }
|
||||
};
|
||||
} // ns
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::Settings::CSwiftPluginSettings)
|
||||
|
||||
@@ -9,94 +9,88 @@
|
||||
#include "xswiftbussettings.h"
|
||||
#include "xswiftbussettingsqtfree.inc"
|
||||
|
||||
namespace BlackMisc
|
||||
namespace BlackMisc::Simulation::Settings
|
||||
{
|
||||
namespace Simulation
|
||||
CXSwiftBusSettings::CXSwiftBusSettings() { }
|
||||
|
||||
CXSwiftBusSettings::CXSwiftBusSettings(const QString &json)
|
||||
{
|
||||
namespace Settings
|
||||
this->parseXSwiftBusStringQt(json);
|
||||
}
|
||||
|
||||
QVariant CXSwiftBusSettings::propertyByIndex(CPropertyIndexRef index) const
|
||||
{
|
||||
if (index.isMyself()) { return QVariant::fromValue(*this); }
|
||||
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::propertyByIndex(index); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
CXSwiftBusSettings::CXSwiftBusSettings() { }
|
||||
case IndexMaxPlanes: return QVariant::fromValue(m_maxPlanes);
|
||||
case IndexDBusServerAddress: return QVariant::fromValue(QString::fromStdString(m_dBusServerAddress));
|
||||
case IndexNightTextureMode: return QVariant::fromValue(QString::fromStdString(m_nightTextureMode));
|
||||
case IndexMessageBoxMargins: return QVariant::fromValue(QString::fromStdString(m_msgBox));
|
||||
case IndexDrawingLabels: return QVariant::fromValue(m_drawingLabels);
|
||||
case IndexBundleTaxiLandingLights: return QVariant::fromValue(m_bundleTaxiLandingLights);
|
||||
case IndexMaxDrawingDistance: return QVariant::fromValue(m_maxDrawDistanceNM);
|
||||
case IndexFollowAircraftDistance: return QVariant::fromValue(m_followAircraftDistanceM);
|
||||
default: break;
|
||||
}
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
|
||||
CXSwiftBusSettings::CXSwiftBusSettings(const QString &json)
|
||||
{
|
||||
this->parseXSwiftBusStringQt(json);
|
||||
}
|
||||
void CXSwiftBusSettings::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.value<CXSwiftBusSettings>(); return; }
|
||||
if (ITimestampBased::canHandleIndex(index)) { ITimestampBased::setPropertyByIndex(index, variant); }
|
||||
|
||||
QVariant CXSwiftBusSettings::propertyByIndex(CPropertyIndexRef index) const
|
||||
{
|
||||
if (index.isMyself()) { return QVariant::fromValue(*this); }
|
||||
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::propertyByIndex(index); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexMaxPlanes: return QVariant::fromValue(m_maxPlanes);
|
||||
case IndexDBusServerAddress: return QVariant::fromValue(QString::fromStdString(m_dBusServerAddress));
|
||||
case IndexNightTextureMode: return QVariant::fromValue(QString::fromStdString(m_nightTextureMode));
|
||||
case IndexMessageBoxMargins: return QVariant::fromValue(QString::fromStdString(m_msgBox));
|
||||
case IndexDrawingLabels: return QVariant::fromValue(m_drawingLabels);
|
||||
case IndexBundleTaxiLandingLights: return QVariant::fromValue(m_bundleTaxiLandingLights);
|
||||
case IndexMaxDrawingDistance: return QVariant::fromValue(m_maxDrawDistanceNM);
|
||||
case IndexFollowAircraftDistance: return QVariant::fromValue(m_followAircraftDistanceM);
|
||||
default: break;
|
||||
}
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexMaxPlanes: m_maxPlanes = variant.toInt(); break;
|
||||
case IndexDBusServerAddress: m_dBusServerAddress = variant.toString().toStdString(); break;
|
||||
case IndexMessageBoxMargins: m_msgBox = variant.toString().toStdString(); break;
|
||||
case IndexNightTextureMode: m_nightTextureMode = variant.toString().toStdString(); break;
|
||||
case IndexDrawingLabels: m_drawingLabels = variant.toBool(); break;
|
||||
case IndexBundleTaxiLandingLights: m_bundleTaxiLandingLights = variant.toBool(); break;
|
||||
case IndexMaxDrawingDistance: m_maxDrawDistanceNM = variant.toDouble(); break;
|
||||
case IndexFollowAircraftDistance: m_followAircraftDistanceM = variant.toInt(); break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CXSwiftBusSettings::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.value<CXSwiftBusSettings>(); return; }
|
||||
if (ITimestampBased::canHandleIndex(index)) { ITimestampBased::setPropertyByIndex(index, variant); }
|
||||
QString CXSwiftBusSettings::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
return QString::fromStdString(CXSwiftBusSettingsQtFree::convertToString());
|
||||
}
|
||||
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexMaxPlanes: m_maxPlanes = variant.toInt(); break;
|
||||
case IndexDBusServerAddress: m_dBusServerAddress = variant.toString().toStdString(); break;
|
||||
case IndexMessageBoxMargins: m_msgBox = variant.toString().toStdString(); break;
|
||||
case IndexNightTextureMode: m_nightTextureMode = variant.toString().toStdString(); break;
|
||||
case IndexDrawingLabels: m_drawingLabels = variant.toBool(); break;
|
||||
case IndexBundleTaxiLandingLights: m_bundleTaxiLandingLights = variant.toBool(); break;
|
||||
case IndexMaxDrawingDistance: m_maxDrawDistanceNM = variant.toDouble(); break;
|
||||
case IndexFollowAircraftDistance: m_followAircraftDistanceM = variant.toInt(); break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
break;
|
||||
}
|
||||
}
|
||||
void CXSwiftBusSettings::setCurrentUtcTime()
|
||||
{
|
||||
ITimestampBased::setCurrentUtcTime();
|
||||
m_msSinceEpochQtFree = m_timestampMSecsSinceEpoch;
|
||||
}
|
||||
|
||||
QString CXSwiftBusSettings::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
return QString::fromStdString(CXSwiftBusSettingsQtFree::convertToString());
|
||||
}
|
||||
CStatusMessageList CXSwiftBusSettings::validate() const
|
||||
{
|
||||
CStatusMessageList msgs;
|
||||
const QString dbus = QString::fromStdString(m_dBusServerAddress);
|
||||
if (!CDBusServer::isSessionOrSystemAddress(dbus) && !CDBusServer::isQtDBusAddress(dbus))
|
||||
{
|
||||
msgs.addValidationMessage(QStringLiteral("Invalid DBus address '%1'").arg(dbus), CStatusMessage::SeverityError);
|
||||
}
|
||||
return msgs;
|
||||
}
|
||||
|
||||
void CXSwiftBusSettings::setCurrentUtcTime()
|
||||
{
|
||||
ITimestampBased::setCurrentUtcTime();
|
||||
m_msSinceEpochQtFree = m_timestampMSecsSinceEpoch;
|
||||
}
|
||||
const CXSwiftBusSettings &CXSwiftBusSettings::defaultValue()
|
||||
{
|
||||
static const CXSwiftBusSettings s;
|
||||
return s;
|
||||
}
|
||||
|
||||
CStatusMessageList CXSwiftBusSettings::validate() const
|
||||
{
|
||||
CStatusMessageList msgs;
|
||||
const QString dbus = QString::fromStdString(m_dBusServerAddress);
|
||||
if (!CDBusServer::isSessionOrSystemAddress(dbus) && !CDBusServer::isQtDBusAddress(dbus))
|
||||
{
|
||||
msgs.addValidationMessage(QStringLiteral("Invalid DBus address '%1'").arg(dbus), CStatusMessage::SeverityError);
|
||||
}
|
||||
return msgs;
|
||||
}
|
||||
|
||||
const CXSwiftBusSettings &CXSwiftBusSettings::defaultValue()
|
||||
{
|
||||
static const CXSwiftBusSettings s;
|
||||
return s;
|
||||
}
|
||||
|
||||
void CXSwiftBusSettings::objectUpdated()
|
||||
{
|
||||
m_timestampMSecsSinceEpoch = m_msSinceEpochQtFree;
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
void CXSwiftBusSettings::objectUpdated()
|
||||
{
|
||||
m_timestampMSecsSinceEpoch = m_msSinceEpochQtFree;
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -20,121 +20,115 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace BlackMisc
|
||||
namespace BlackMisc::Simulation::Settings
|
||||
{
|
||||
namespace Simulation
|
||||
//! XSwiftBus settings
|
||||
class BLACKMISC_EXPORT CXSwiftBusSettings final :
|
||||
public CValueObject<CXSwiftBusSettings>,
|
||||
public CXSwiftBusSettingsQtFree,
|
||||
public ITimestampBased
|
||||
{
|
||||
namespace Settings
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
//! XSwiftBus settings
|
||||
class BLACKMISC_EXPORT CXSwiftBusSettings final :
|
||||
public CValueObject<CXSwiftBusSettings>,
|
||||
public CXSwiftBusSettingsQtFree,
|
||||
public ITimestampBased
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexDBusServerAddress = CPropertyIndexRef::GlobalIndexCXSwiftBusSettings,
|
||||
IndexMaxPlanes,
|
||||
IndexDrawingLabels,
|
||||
IndexBundleTaxiLandingLights,
|
||||
IndexMessageBoxMargins,
|
||||
IndexMaxDrawingDistance,
|
||||
IndexFollowAircraftDistance,
|
||||
IndexNightTextureMode
|
||||
};
|
||||
IndexDBusServerAddress = CPropertyIndexRef::GlobalIndexCXSwiftBusSettings,
|
||||
IndexMaxPlanes,
|
||||
IndexDrawingLabels,
|
||||
IndexBundleTaxiLandingLights,
|
||||
IndexMessageBoxMargins,
|
||||
IndexMaxDrawingDistance,
|
||||
IndexFollowAircraftDistance,
|
||||
IndexNightTextureMode
|
||||
};
|
||||
|
||||
//! Default constructor
|
||||
CXSwiftBusSettings();
|
||||
//! Default constructor
|
||||
CXSwiftBusSettings();
|
||||
|
||||
//! From JSON constructor
|
||||
CXSwiftBusSettings(const QString &json);
|
||||
//! From JSON constructor
|
||||
CXSwiftBusSettings(const QString &json);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
QVariant propertyByIndex(BlackMisc::CPropertyIndexRef index) const;
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
QVariant propertyByIndex(BlackMisc::CPropertyIndexRef index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(BlackMisc::CPropertyIndexRef index, const QVariant &variant);
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(BlackMisc::CPropertyIndexRef index, const QVariant &variant);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::getDBusServerAddress
|
||||
QString getDBusServerAddressQt() const { return QString::fromStdString(this->getDBusServerAddress()); }
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::getDBusServerAddress
|
||||
QString getDBusServerAddressQt() const { return QString::fromStdString(this->getDBusServerAddress()); }
|
||||
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::setDBusServerAddress
|
||||
void setDBusServerAddressQt(const QString &dBusAddress) { this->setDBusServerAddress(dBusAddress.toStdString()); }
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::setDBusServerAddress
|
||||
void setDBusServerAddressQt(const QString &dBusAddress) { this->setDBusServerAddress(dBusAddress.toStdString()); }
|
||||
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::getNightTextureMode
|
||||
QString getNightTextureModeQt() const { return QString::fromStdString(this->getNightTextureMode()); }
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::getNightTextureMode
|
||||
QString getNightTextureModeQt() const { return QString::fromStdString(this->getNightTextureMode()); }
|
||||
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::setNightTextureMode
|
||||
void setNightTextureModeQt(const QString &nightTexture) { this->setNightTextureMode(nightTexture.toStdString()); }
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::setNightTextureMode
|
||||
void setNightTextureModeQt(const QString &nightTexture) { this->setNightTextureMode(nightTexture.toStdString()); }
|
||||
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::toXSwiftBusJsonString
|
||||
QString toXSwiftBusJsonStringQt() const { return QString::fromStdString(this->toXSwiftBusJsonString()); }
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::toXSwiftBusJsonString
|
||||
QString toXSwiftBusJsonStringQt() const { return QString::fromStdString(this->toXSwiftBusJsonString()); }
|
||||
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::parseXSwiftBusString
|
||||
void parseXSwiftBusStringQt(const QString &json) { this->parseXSwiftBusString(json.toStdString()); }
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::parseXSwiftBusString
|
||||
void parseXSwiftBusStringQt(const QString &json) { this->parseXSwiftBusString(json.toStdString()); }
|
||||
|
||||
//! Sets both timestamps
|
||||
virtual void setCurrentUtcTime() override;
|
||||
//! Sets both timestamps
|
||||
virtual void setCurrentUtcTime() override;
|
||||
|
||||
//! Valid settings?
|
||||
CStatusMessageList validate() const;
|
||||
//! Valid settings?
|
||||
CStatusMessageList validate() const;
|
||||
|
||||
//! Default value for settings
|
||||
static const CXSwiftBusSettings &defaultValue();
|
||||
//! Default value for settings
|
||||
static const CXSwiftBusSettings &defaultValue();
|
||||
|
||||
protected:
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::objectUpdated
|
||||
virtual void objectUpdated() override final;
|
||||
protected:
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::objectUpdated
|
||||
virtual void objectUpdated() override final;
|
||||
|
||||
private:
|
||||
BLACK_METACLASS(
|
||||
CXSwiftBusSettings,
|
||||
BLACK_METAMEMBER(dBusServerAddress),
|
||||
BLACK_METAMEMBER(msgBox),
|
||||
BLACK_METAMEMBER(nightTextureMode),
|
||||
BLACK_METAMEMBER(maxPlanes),
|
||||
BLACK_METAMEMBER(drawingLabels),
|
||||
BLACK_METAMEMBER(labelColor),
|
||||
BLACK_METAMEMBER(bundleTaxiLandingLights),
|
||||
BLACK_METAMEMBER(maxDrawDistanceNM),
|
||||
BLACK_METAMEMBER(followAircraftDistanceM),
|
||||
BLACK_METAMEMBER(logRenderPhases),
|
||||
BLACK_METAMEMBER(tcasEnabled),
|
||||
BLACK_METAMEMBER(terrainProbeEnabled),
|
||||
BLACK_METAMEMBER(timestampMSecsSinceEpoch, 0, DisabledForComparison | DisabledForHashing)
|
||||
);
|
||||
};
|
||||
private:
|
||||
BLACK_METACLASS(
|
||||
CXSwiftBusSettings,
|
||||
BLACK_METAMEMBER(dBusServerAddress),
|
||||
BLACK_METAMEMBER(msgBox),
|
||||
BLACK_METAMEMBER(nightTextureMode),
|
||||
BLACK_METAMEMBER(maxPlanes),
|
||||
BLACK_METAMEMBER(drawingLabels),
|
||||
BLACK_METAMEMBER(labelColor),
|
||||
BLACK_METAMEMBER(bundleTaxiLandingLights),
|
||||
BLACK_METAMEMBER(maxDrawDistanceNM),
|
||||
BLACK_METAMEMBER(followAircraftDistanceM),
|
||||
BLACK_METAMEMBER(logRenderPhases),
|
||||
BLACK_METAMEMBER(tcasEnabled),
|
||||
BLACK_METAMEMBER(terrainProbeEnabled),
|
||||
BLACK_METAMEMBER(timestampMSecsSinceEpoch, 0, DisabledForComparison | DisabledForHashing)
|
||||
);
|
||||
};
|
||||
|
||||
/*!
|
||||
* Setting for XSwiftBus.
|
||||
*/
|
||||
struct TXSwiftBusSettings : public TSettingTrait<CXSwiftBusSettings>
|
||||
{
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "xswiftbus/settings"; }
|
||||
/*!
|
||||
* Setting for XSwiftBus.
|
||||
*/
|
||||
struct TXSwiftBusSettings : public TSettingTrait<CXSwiftBusSettings>
|
||||
{
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "xswiftbus/settings"; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("XSwiftBus"); return name; }
|
||||
//! \copydoc BlackMisc::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable() { static const QString name("XSwiftBus"); return name; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::defaultValue
|
||||
static CXSwiftBusSettings defaultValue() { return CXSwiftBusSettings::defaultValue(); }
|
||||
//! \copydoc BlackMisc::TSettingTrait::defaultValue
|
||||
static CXSwiftBusSettings defaultValue() { return CXSwiftBusSettings::defaultValue(); }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::isValid
|
||||
static bool isValid(const CXSwiftBusSettings &settings, QString &reason)
|
||||
{
|
||||
const CStatusMessageList msgs = settings.validate();
|
||||
reason = msgs.toQString(true);
|
||||
return msgs.isSuccess();
|
||||
}
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
//! \copydoc BlackMisc::TSettingTrait::isValid
|
||||
static bool isValid(const CXSwiftBusSettings &settings, QString &reason)
|
||||
{
|
||||
const CStatusMessageList msgs = settings.validate();
|
||||
reason = msgs.toQString(true);
|
||||
return msgs.isSuccess();
|
||||
}
|
||||
};
|
||||
} // ns
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::Settings::CXSwiftBusSettings)
|
||||
|
||||
@@ -14,195 +14,189 @@
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
|
||||
namespace BlackMisc
|
||||
namespace BlackMisc::Simulation::Settings
|
||||
{
|
||||
namespace Simulation
|
||||
/*!
|
||||
* XSwiftBus/swift side settings class, JSON capable, shared among all services
|
||||
* \details Used on swift and XSwiftBus side, MUST BE Qt free
|
||||
*/
|
||||
class CXSwiftBusSettingsQtFree
|
||||
{
|
||||
namespace Settings
|
||||
protected:
|
||||
//! Constructor.
|
||||
CXSwiftBusSettingsQtFree() {}
|
||||
|
||||
//! Destructor.
|
||||
virtual ~CXSwiftBusSettingsQtFree() {}
|
||||
|
||||
public:
|
||||
//! DBus server
|
||||
const std::string &getDBusServerAddress() const { return m_dBusServerAddress; }
|
||||
|
||||
//! Set DBus server
|
||||
void setDBusServerAddress(const std::string &dBusServer) { m_dBusServerAddress = dBusServer; }
|
||||
|
||||
//! Set whether the plugin draws type and callsign labels above aircraft
|
||||
void setDrawingLabels(bool drawing) { m_drawingLabels = drawing; }
|
||||
|
||||
//! Get whether the plugin draws type and callsign labels above aircraft
|
||||
bool isDrawingLabels() const { return m_drawingLabels; }
|
||||
|
||||
//! Set the color to draw the callsign labels above aircraft
|
||||
void setLabelColor(int rgb) { m_labelColor = rgb; }
|
||||
|
||||
//! Get the color to draw the callsign labels above aircraft
|
||||
int getLabelColor() const { return m_labelColor; }
|
||||
|
||||
//! Bundle taxi and landing lights
|
||||
void setBundlingTaxiAndLandingLights(bool bundle) { m_bundleTaxiLandingLights = bundle; }
|
||||
|
||||
//! Bundle taxi and landing lights
|
||||
bool isBundlingTaxiAndLandingLights() const { return m_bundleTaxiLandingLights; }
|
||||
|
||||
//! The the night texture mode
|
||||
void setNightTextureMode(const std::string &mode) { m_nightTextureMode = XPlane::QtFreeUtils::toLower(mode); }
|
||||
|
||||
//! The the night texture mode
|
||||
const std::string &getNightTextureMode() const { return m_nightTextureMode; }
|
||||
|
||||
//! Left, top, right, bottom, lines, duration, color(freq, priv, serv, stat, sup)
|
||||
void setMessageBoxValues(const std::string &positions) { m_msgBox = positions; }
|
||||
|
||||
//! Left, top, right, bottom, lines, duration, color(freq, priv, serv, stat, sup)
|
||||
void setMessageBoxValues(int leftPx, int topPx, int rightPx, int bottomPx, int lines, int durationMs, int freqRgb, int privRgb, int servRgb, int statRgb, int supRgb)
|
||||
{
|
||||
/*!
|
||||
* XSwiftBus/swift side settings class, JSON capable, shared among all services
|
||||
* \details Used on swift and XSwiftBus side, MUST BE Qt free
|
||||
*/
|
||||
class CXSwiftBusSettingsQtFree
|
||||
if (topPx >= 0) { bottomPx = -1; }
|
||||
if (lines < 3) { lines = 3; }
|
||||
this->setMessageBoxValues(std::to_string(leftPx) + ";" + std::to_string(topPx) + ";" + std::to_string(rightPx) + ";" + std::to_string(bottomPx) + ";" + std::to_string(lines) + ";" + std::to_string(durationMs) + ";"
|
||||
+ std::to_string(freqRgb) + ";" + std::to_string(privRgb) + ";" + std::to_string(servRgb) + ";" + std::to_string(statRgb) + ";" + std::to_string(supRgb));
|
||||
}
|
||||
|
||||
//! Left, top, right, bottom, lines, duration, color(freq, priv, serv, stat, sup)
|
||||
const std::string &getMessageBoxValues() const { return m_msgBox; }
|
||||
|
||||
//! Left, top, right, bottom, lines, duration, color(freq, priv, serv, stat, sup)
|
||||
std::vector<int> getMessageBoxValuesVector() const
|
||||
{
|
||||
constexpr int partCount = 11;
|
||||
std::vector<int> partsInt = {20, 20, 20, -1, 5, 5000, 0x00ff00, 0xff00ff, 0xda70d6, 0x00ffff, 0xffff00};
|
||||
const std::vector<std::string> parts = XPlane::QtFreeUtils::split(m_msgBox, partCount, ";");
|
||||
|
||||
size_t c = 0;
|
||||
for (const std::string &p : parts)
|
||||
{
|
||||
protected:
|
||||
//! Constructor.
|
||||
CXSwiftBusSettingsQtFree() {}
|
||||
const int i = std::stoi(p);
|
||||
partsInt[c++] = i;
|
||||
}
|
||||
return partsInt;
|
||||
}
|
||||
|
||||
//! Destructor.
|
||||
virtual ~CXSwiftBusSettingsQtFree() {}
|
||||
//! Set the maximum number of aircraft.
|
||||
bool setMaxPlanes(int planes)
|
||||
{
|
||||
if (planes == m_maxPlanes) { return false; }
|
||||
m_maxPlanes = planes;
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
//! DBus server
|
||||
const std::string &getDBusServerAddress() const { return m_dBusServerAddress; }
|
||||
//! Get the maximum number of aircraft.
|
||||
int getMaxPlanes() const { return m_maxPlanes; }
|
||||
|
||||
//! Set DBus server
|
||||
void setDBusServerAddress(const std::string &dBusServer) { m_dBusServerAddress = dBusServer; }
|
||||
//! Set follow aircraft distance
|
||||
bool setFollowAircraftDistanceM(int meters)
|
||||
{
|
||||
if (meters == m_followAircraftDistanceM) { return false; }
|
||||
m_followAircraftDistanceM = meters;
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Set whether the plugin draws type and callsign labels above aircraft
|
||||
void setDrawingLabels(bool drawing) { m_drawingLabels = drawing; }
|
||||
//! Get follow aircraft distance
|
||||
int getFollowAircraftDistanceM() const { return m_followAircraftDistanceM; }
|
||||
|
||||
//! Get whether the plugin draws type and callsign labels above aircraft
|
||||
bool isDrawingLabels() const { return m_drawingLabels; }
|
||||
//! Set the maximum distance at which to draw aircraft (nautical miles).
|
||||
double getMaxDrawDistanceNM() const { return m_maxDrawDistanceNM; }
|
||||
|
||||
//! Set the color to draw the callsign labels above aircraft
|
||||
void setLabelColor(int rgb) { m_labelColor = rgb; }
|
||||
//! Set the maximum distance at which to draw aircraft (nautical miles).
|
||||
bool setMaxDrawDistanceNM(double nauticalMiles)
|
||||
{
|
||||
if (BlackMisc::Simulation::XPlane::QtFreeUtils::isFuzzyEqual(nauticalMiles, m_maxDrawDistanceNM)) { return false; }
|
||||
m_maxDrawDistanceNM = nauticalMiles;
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Get the color to draw the callsign labels above aircraft
|
||||
int getLabelColor() const { return m_labelColor; }
|
||||
//! Debug messages?
|
||||
bool isLogRenderPhases() const { return m_logRenderPhases; }
|
||||
|
||||
//! Bundle taxi and landing lights
|
||||
void setBundlingTaxiAndLandingLights(bool bundle) { m_bundleTaxiLandingLights = bundle; }
|
||||
//! Debug messages?
|
||||
void setLogRenderPhases(bool log) { m_logRenderPhases = log; }
|
||||
|
||||
//! Bundle taxi and landing lights
|
||||
bool isBundlingTaxiAndLandingLights() const { return m_bundleTaxiLandingLights; }
|
||||
//! TCAS functionality?
|
||||
bool isTcasEnabled() const { return m_tcasEnabled; }
|
||||
|
||||
//! The the night texture mode
|
||||
void setNightTextureMode(const std::string &mode) { m_nightTextureMode = XPlane::QtFreeUtils::toLower(mode); }
|
||||
//! TCAS functionality?
|
||||
void setTcasEnabled(bool tcas) { m_tcasEnabled = tcas; }
|
||||
|
||||
//! The the night texture mode
|
||||
const std::string &getNightTextureMode() const { return m_nightTextureMode; }
|
||||
//! Terrain probe to query ground elevation enabled?
|
||||
bool isTerrainProbeEnabled() const { return m_terrainProbeEnabled; }
|
||||
|
||||
//! Left, top, right, bottom, lines, duration, color(freq, priv, serv, stat, sup)
|
||||
void setMessageBoxValues(const std::string &positions) { m_msgBox = positions; }
|
||||
//! Terrain probe to query ground elevation enabled?
|
||||
void setTerrainProbeEnabled(bool enabled) { m_terrainProbeEnabled = enabled; }
|
||||
|
||||
//! Left, top, right, bottom, lines, duration, color(freq, priv, serv, stat, sup)
|
||||
void setMessageBoxValues(int leftPx, int topPx, int rightPx, int bottomPx, int lines, int durationMs, int freqRgb, int privRgb, int servRgb, int statRgb, int supRgb)
|
||||
{
|
||||
if (topPx >= 0) { bottomPx = -1; }
|
||||
if (lines < 3) { lines = 3; }
|
||||
this->setMessageBoxValues(std::to_string(leftPx) + ";" + std::to_string(topPx) + ";" + std::to_string(rightPx) + ";" + std::to_string(bottomPx) + ";" + std::to_string(lines) + ";" + std::to_string(durationMs) + ";"
|
||||
+ std::to_string(freqRgb) + ";" + std::to_string(privRgb) + ";" + std::to_string(servRgb) + ";" + std::to_string(statRgb) + ";" + std::to_string(supRgb));
|
||||
}
|
||||
//! Load and parse config file
|
||||
bool parseXSwiftBusString(const std::string &json);
|
||||
|
||||
//! Left, top, right, bottom, lines, duration, color(freq, priv, serv, stat, sup)
|
||||
const std::string &getMessageBoxValues() const { return m_msgBox; }
|
||||
//! As JSON string
|
||||
std::string toXSwiftBusJsonString() const;
|
||||
|
||||
//! Left, top, right, bottom, lines, duration, color(freq, priv, serv, stat, sup)
|
||||
std::vector<int> getMessageBoxValuesVector() const
|
||||
{
|
||||
constexpr int partCount = 11;
|
||||
std::vector<int> partsInt = {20, 20, 20, -1, 5, 5000, 0x00ff00, 0xff00ff, 0xda70d6, 0x00ffff, 0xffff00};
|
||||
const std::vector<std::string> parts = XPlane::QtFreeUtils::split(m_msgBox, partCount, ";");
|
||||
//! Convert to string
|
||||
std::string convertToString() const;
|
||||
|
||||
size_t c = 0;
|
||||
for (const std::string &p : parts)
|
||||
{
|
||||
const int i = std::stoi(p);
|
||||
partsInt[c++] = i;
|
||||
}
|
||||
return partsInt;
|
||||
}
|
||||
//! Update only changed values
|
||||
int update(const CXSwiftBusSettingsQtFree &newValues);
|
||||
|
||||
//! Set the maximum number of aircraft.
|
||||
bool setMaxPlanes(int planes)
|
||||
{
|
||||
if (planes == m_maxPlanes) { return false; }
|
||||
m_maxPlanes = planes;
|
||||
return true;
|
||||
}
|
||||
//! Sets timestamp to now
|
||||
virtual void setCurrentUtcTime()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
const milliseconds ms = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
||||
m_msSinceEpochQtFree = static_cast<int64_t>(ms.count());
|
||||
}
|
||||
|
||||
//! Get the maximum number of aircraft.
|
||||
int getMaxPlanes() const { return m_maxPlanes; }
|
||||
protected:
|
||||
//! The JSON members
|
||||
//! @{
|
||||
static constexpr char JsonDBusServerAddress[] = "dbusserveradress";
|
||||
static constexpr char JsonDrawingLabels[] = "drawinglabels";
|
||||
static constexpr char JsonLabelColor[] = "labelcolor";
|
||||
static constexpr char JsonLogRenderPhases[] = "renderPhases";
|
||||
static constexpr char JsonTcas[] = "tcas";
|
||||
static constexpr char JsonTerrainProbe[] = "terrainProbe";
|
||||
static constexpr char JsonMaxPlanes[] = "maxplanes";
|
||||
static constexpr char JsonMaxDrawDistance[] = "maxDrawDistance";
|
||||
static constexpr char JsonNightTextureMode[] = "nighttexture";
|
||||
static constexpr char JsonTimestamp[] = "timestamp";
|
||||
static constexpr char JsonMessageBox[] = "msgbox";
|
||||
static constexpr char JsonBundleTaxiLandingLights[] = "bundleLights";
|
||||
static constexpr char JsonFollowAircraftDistanceM[] = "followAircraftDistance";
|
||||
//! @}
|
||||
|
||||
//! Set follow aircraft distance
|
||||
bool setFollowAircraftDistanceM(int meters)
|
||||
{
|
||||
if (meters == m_followAircraftDistanceM) { return false; }
|
||||
m_followAircraftDistanceM = meters;
|
||||
return true;
|
||||
}
|
||||
//! Object has been updated
|
||||
virtual void objectUpdated() = 0;
|
||||
|
||||
//! Get follow aircraft distance
|
||||
int getFollowAircraftDistanceM() const { return m_followAircraftDistanceM; }
|
||||
|
||||
//! Set the maximum distance at which to draw aircraft (nautical miles).
|
||||
double getMaxDrawDistanceNM() const { return m_maxDrawDistanceNM; }
|
||||
|
||||
//! Set the maximum distance at which to draw aircraft (nautical miles).
|
||||
bool setMaxDrawDistanceNM(double nauticalMiles)
|
||||
{
|
||||
if (BlackMisc::Simulation::XPlane::QtFreeUtils::isFuzzyEqual(nauticalMiles, m_maxDrawDistanceNM)) { return false; }
|
||||
m_maxDrawDistanceNM = nauticalMiles;
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Debug messages?
|
||||
bool isLogRenderPhases() const { return m_logRenderPhases; }
|
||||
|
||||
//! Debug messages?
|
||||
void setLogRenderPhases(bool log) { m_logRenderPhases = log; }
|
||||
|
||||
//! TCAS functionality?
|
||||
bool isTcasEnabled() const { return m_tcasEnabled; }
|
||||
|
||||
//! TCAS functionality?
|
||||
void setTcasEnabled(bool tcas) { m_tcasEnabled = tcas; }
|
||||
|
||||
//! Terrain probe to query ground elevation enabled?
|
||||
bool isTerrainProbeEnabled() const { return m_terrainProbeEnabled; }
|
||||
|
||||
//! Terrain probe to query ground elevation enabled?
|
||||
void setTerrainProbeEnabled(bool enabled) { m_terrainProbeEnabled = enabled; }
|
||||
|
||||
//! Load and parse config file
|
||||
bool parseXSwiftBusString(const std::string &json);
|
||||
|
||||
//! As JSON string
|
||||
std::string toXSwiftBusJsonString() const;
|
||||
|
||||
//! Convert to string
|
||||
std::string convertToString() const;
|
||||
|
||||
//! Update only changed values
|
||||
int update(const CXSwiftBusSettingsQtFree &newValues);
|
||||
|
||||
//! Sets timestamp to now
|
||||
virtual void setCurrentUtcTime()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
const milliseconds ms = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
||||
m_msSinceEpochQtFree = static_cast<int64_t>(ms.count());
|
||||
}
|
||||
|
||||
protected:
|
||||
//! The JSON members
|
||||
//! @{
|
||||
static constexpr char JsonDBusServerAddress[] = "dbusserveradress";
|
||||
static constexpr char JsonDrawingLabels[] = "drawinglabels";
|
||||
static constexpr char JsonLabelColor[] = "labelcolor";
|
||||
static constexpr char JsonLogRenderPhases[] = "renderPhases";
|
||||
static constexpr char JsonTcas[] = "tcas";
|
||||
static constexpr char JsonTerrainProbe[] = "terrainProbe";
|
||||
static constexpr char JsonMaxPlanes[] = "maxplanes";
|
||||
static constexpr char JsonMaxDrawDistance[] = "maxDrawDistance";
|
||||
static constexpr char JsonNightTextureMode[] = "nighttexture";
|
||||
static constexpr char JsonTimestamp[] = "timestamp";
|
||||
static constexpr char JsonMessageBox[] = "msgbox";
|
||||
static constexpr char JsonBundleTaxiLandingLights[] = "bundleLights";
|
||||
static constexpr char JsonFollowAircraftDistanceM[] = "followAircraftDistance";
|
||||
//! @}
|
||||
|
||||
//! Object has been updated
|
||||
virtual void objectUpdated() = 0;
|
||||
|
||||
std::string m_dBusServerAddress { "tcp:host=127.0.0.1,port=45001" }; //!< DBus server (also in class CXSwiftBusConfigWriter)
|
||||
std::string m_nightTextureMode { "auto" }; //!< night texture mode
|
||||
std::string m_msgBox { "20;20;20;-1;5;5000;65280;16711935;14315734;65535;16776960" }; //!< left, top, right, bottom, lines, duration, colors
|
||||
int m_maxPlanes = 100; //!< max. planes in XPlane
|
||||
int m_followAircraftDistanceM = 200; //!< follow aircraft in distance
|
||||
bool m_drawingLabels = true; //!< labels in XPlane
|
||||
int m_labelColor = 0xffc000;//!< labels in XPlane
|
||||
bool m_bundleTaxiLandingLights = true; //!< bundle taxi and landing lights
|
||||
bool m_logRenderPhases = false; //!< render phases debug messages
|
||||
bool m_tcasEnabled = true; //!< TCAS functionality
|
||||
bool m_terrainProbeEnabled = true; //!< terrain probe to establish ground elevation
|
||||
double m_maxDrawDistanceNM = 50.0; //!< distance in XPlane
|
||||
int64_t m_msSinceEpochQtFree = 0; //!< timestamp
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
std::string m_dBusServerAddress { "tcp:host=127.0.0.1,port=45001" }; //!< DBus server (also in class CXSwiftBusConfigWriter)
|
||||
std::string m_nightTextureMode { "auto" }; //!< night texture mode
|
||||
std::string m_msgBox { "20;20;20;-1;5;5000;65280;16711935;14315734;65535;16776960" }; //!< left, top, right, bottom, lines, duration, colors
|
||||
int m_maxPlanes = 100; //!< max. planes in XPlane
|
||||
int m_followAircraftDistanceM = 200; //!< follow aircraft in distance
|
||||
bool m_drawingLabels = true; //!< labels in XPlane
|
||||
int m_labelColor = 0xffc000;//!< labels in XPlane
|
||||
bool m_bundleTaxiLandingLights = true; //!< bundle taxi and landing lights
|
||||
bool m_logRenderPhases = false; //!< render phases debug messages
|
||||
bool m_tcasEnabled = true; //!< TCAS functionality
|
||||
bool m_terrainProbeEnabled = true; //!< terrain probe to establish ground elevation
|
||||
double m_maxDrawDistanceNM = 50.0; //!< distance in XPlane
|
||||
int64_t m_msSinceEpochQtFree = 0; //!< timestamp
|
||||
};
|
||||
} // ns
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user