swift
Loading...
Searching...
No Matches
xswiftbussettings.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_MISC_SIMULATION_SETTINGS_XSWIFTBUSSETTINGS_H
7#define SWIFT_MISC_SIMULATION_SETTINGS_XSWIFTBUSSETTINGS_H
8
9#include <QString>
10
11#include "misc/dbusserver.h"
12#include "misc/settingscache.h"
13#include "misc/simulation/settings/xswiftbussettingsqtfree.h"
16#include "misc/valueobject.h"
17
18SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::simulation::Settings, CXSwiftBusSettings)
19
20namespace swift::misc::simulation::settings
21{
24 public CValueObject<CXSwiftBusSettings>,
26 public ITimestampBased
27 {
28 public:
31 {
32 IndexDBusServerAddress = CPropertyIndexRef::GlobalIndexCXSwiftBusSettings,
33 IndexMaxPlanes,
34 IndexDrawingLabels,
35 IndexBundleTaxiLandingLights,
36 IndexMessageBoxMargins,
37 IndexMaxDrawingDistance,
38 IndexFollowAircraftDistance,
39 IndexNightTextureMode
40 };
41
43 CXSwiftBusSettings() = default;
44
46 CXSwiftBusSettings(const QString &json);
47
50
53
55 QString convertToQString(bool i18n = false) const;
56
59
61 void setDBusServerAddressQt(const QString &dBusAddress)
62 {
63 this->setDBusServerAddress(dBusAddress.toStdString());
64 }
65
68
70 void setNightTextureModeQt(const QString &nightTexture)
71 {
72 this->setNightTextureMode(nightTexture.toStdString());
73 }
74
77
79 void parseXSwiftBusStringQt(const QString &json) { this->parseXSwiftBusString(json.toStdString()); }
80
82 void setCurrentUtcTime() override;
83
85 CStatusMessageList validate() const;
86
88 static const CXSwiftBusSettings &defaultValue();
89
90 protected:
92 void objectUpdated() override;
93
94 private:
97 SWIFT_METAMEMBER(dBusServerAddress),
98 SWIFT_METAMEMBER(msgBox),
99 SWIFT_METAMEMBER(nightTextureMode),
100 SWIFT_METAMEMBER(maxPlanes),
101 SWIFT_METAMEMBER(drawingLabels),
102 SWIFT_METAMEMBER(labelColor),
103 SWIFT_METAMEMBER(bundleTaxiLandingLights),
104 SWIFT_METAMEMBER(maxDrawDistanceNM),
105 SWIFT_METAMEMBER(followAircraftDistanceM),
106 SWIFT_METAMEMBER(logRenderPhases),
107 SWIFT_METAMEMBER(tcasEnabled),
108 SWIFT_METAMEMBER(terrainProbeEnabled),
109 SWIFT_METAMEMBER(timestampMSecsSinceEpoch, 0, DisabledForComparison | DisabledForHashing));
110 };
111
115 struct TXSwiftBusSettings : public TSettingTrait<CXSwiftBusSettings>
116 {
118 static const char *key() { return "xswiftbus/settings"; }
119
121 static const QString &humanReadable()
122 {
123 static const QString name("xswiftbus");
124 return name;
125 }
126
129
131 static bool isValid(const CXSwiftBusSettings &settings, QString &reason)
132 {
133 const CStatusMessageList msgs = settings.validate();
134 reason = msgs.toQString(true);
135 return msgs.isSuccess();
136 }
137 };
138} // namespace swift::misc::simulation::settings
139
141
142#endif // SWIFT_MISC_SIMULATION_SETTINGS_XSWIFTBUSSETTINGS_H
Non-owning reference to a CPropertyIndex with a subset of its features.
Status messages, e.g. from Core -> GUI.
bool isSuccess() const
All messages are marked as success.
ITimestampBased()=default
Constructor.
QString toQString(bool i18n=false) const
Cast as QString.
Definition mixinstring.h:74
QString convertToQString(bool i18n=false) const
Cast as QString.
void parseXSwiftBusStringQt(const QString &json)
Load and parse config file.
static const CXSwiftBusSettings & defaultValue()
Default value for settings.
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
void setDBusServerAddressQt(const QString &dBusAddress)
Set DBus server.
void setNightTextureModeQt(const QString &nightTexture)
The the night texture mode.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QString getNightTextureModeQt() const
The the night texture mode.
const std::string & getNightTextureMode() const
The the night texture mode.
void setDBusServerAddress(const std::string &dBusServer)
Set DBus server.
void setNightTextureMode(const std::string &mode)
The the night texture mode.
std::string toXSwiftBusJsonString() const
As JSON string.
bool parseXSwiftBusString(const std::string &json)
Load and parse config file.
#define SWIFT_METAMEMBER(MEMBER,...)
Macro to define an element within a metaclass.
Definition metaclass.h:72
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition metaclass.h:52
@ DisabledForComparison
Element will be ignored by compare() and comparison operators.
Definition metaclass.h:200
@ DisabledForHashing
Element will be ignored by qHash().
Definition metaclass.h:203
QString fromStdString(const std::string &str)
std::string toStdString() const const
static const QString & humanReadable()
Optional human readable name.
static CXSwiftBusSettings defaultValue()
Return the value to use in case the supplied value does not satisfy the validator....
static bool isValid(const CXSwiftBusSettings &settings, QString &reason)
Validator function. Return true if the argument is valid, false otherwise. Default implementation jus...
static const char * key()
Key string of the value. Reimplemented in derived class.
#define SWIFT_MISC_EXPORT
Export a class or function from the library.
#define SWIFT_DECLARE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template declaration of mixins for a CValueObject subclass to be placed near the top of the ...
Definition valueobject.h:65