swift
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"
14 #include "misc/statusmessagelist.h"
15 #include "misc/swiftmiscexport.h"
16 #include "misc/valueobject.h"
17 
18 SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::simulation::Settings, CXSwiftBusSettings)
19 
20 namespace 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 
44 
46  CXSwiftBusSettings(const QString &json);
47 
49  QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const;
50 
52  void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant);
53 
55  QString convertToQString(bool i18n = false) const;
56 
58  QString getDBusServerAddressQt() const { return QString::fromStdString(this->getDBusServerAddress()); }
59 
61  void setDBusServerAddressQt(const QString &dBusAddress)
62  {
63  this->setDBusServerAddress(dBusAddress.toStdString());
64  }
65 
67  QString getNightTextureModeQt() const { return QString::fromStdString(this->getNightTextureMode()); }
68 
70  void setNightTextureModeQt(const QString &nightTexture)
71  {
72  this->setNightTextureMode(nightTexture.toStdString());
73  }
74 
76  QString toXSwiftBusJsonStringQt() const { return QString::fromStdString(this->toXSwiftBusJsonString()); }
77 
79  void parseXSwiftBusStringQt(const QString &json) { this->parseXSwiftBusString(json.toStdString()); }
80 
82  virtual void setCurrentUtcTime() override;
83 
85  CStatusMessageList validate() const;
86 
88  static const CXSwiftBusSettings &defaultValue();
89 
90  protected:
92  virtual void objectUpdated() override final;
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 
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.
Mix of the most commonly used mixin classes.
Definition: valueobject.h:114
Entity with timestamp.
ColumnIndex
Base class enums.
Definition: mixinindex.h:44
QString toQString(bool i18n=false) const
Cast as QString.
Definition: mixinstring.h:76
void parseXSwiftBusStringQt(const QString &json)
Load and parse config file.
static const CXSwiftBusSettings & defaultValue()
Default value for settings.
void setDBusServerAddressQt(const QString &dBusAddress)
Set DBus server.
void setNightTextureModeQt(const QString &nightTexture)
The the night texture mode.
CStatusMessageList validate() const
Valid settings?
QString getNightTextureModeQt() const
The the night texture mode.
xswiftbus/swift side settings class, JSON capable, shared among all services
#define SWIFT_METAMEMBER(MEMBER,...)
Macro to define an element within a metaclass.
Definition: metaclass.h:73
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition: metaclass.h:53
@ DisabledForComparison
Element will be ignored by compare() and comparison operators.
Definition: metaclass.h:202
@ DisabledForHashing
Element will be ignored by qHash()
Definition: metaclass.h:205
Base class for traits to be used as template argument to swift::misc::CSetting.
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 QString & humanReadable()
Optional human readable name.
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