swift
Loading...
Searching...
No Matches
aircraftparts.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2014 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_AVIATION_AIRCRAFTPARTS_H
7#define SWIFT_MISC_AVIATION_AIRCRAFTPARTS_H
8
9#include <QMetaType>
10#include <QString>
11
14#include "misc/metaclass.h"
17#include "misc/timestampbased.h"
18#include "misc/valueobject.h"
19
20SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::aviation, CAircraftParts)
21
22namespace swift::misc::aviation
23{
26 {
27 public:
30 {
31 IndexLights = CPropertyIndexRef::GlobalIndexCAircraftParts,
32 IndexGearDown,
33 IndexFlapsPercentage,
34 IndexSpoilersOut,
35 IndexEngines,
36 IndexEnginesAsString,
37 IndexIsOnGround
38 };
39
42 {
43 NotSet,
44 FSDAircraftParts,
45 GuessedParts
46 };
47
49 CAircraftParts() = default;
50
52 CAircraftParts(int flapsPercent);
53
55 CAircraftParts(const CAircraftLights &lights, bool gearDown, int flapsPercent, bool spoilersOut,
56 const CAircraftEngineList &engines, bool onGround);
57
59 CAircraftParts(const CAircraftLights &lights, bool gearDown, int flapsPercent, bool spoilersOut,
60 const CAircraftEngineList &engines, bool onGround, qint64 timestamp);
61
64
66 void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
67
69 int comparePropertyByIndex(CPropertyIndexRef index, const CAircraftParts &compareValue) const;
70
72 CAircraftLights getLights() const { return m_lights; }
73
75 CAircraftLights getAdjustedLights() const;
76
78 CAircraftLights &lights() { return m_lights; }
79
81 void setLights(const CAircraftLights &lights) { m_lights = lights; }
82
84 void setAllLightsOn();
85
87 void setAllLightsOff();
88
90 bool isGearDown() const { return m_gearDown; }
91
94 bool isFixedGearDown() const;
95
97 void setGearDown(bool down) { m_gearDown = down; }
98
100 int getFlapsPercent() const { return m_flapsPercentage; }
101
103 void setFlapsPercent(int flapsPercent) { m_flapsPercentage = flapsPercent; }
104
106 bool isSpoilersOut() const { return m_spoilersOut; }
107
109 void setSpoilersOut(bool out) { m_spoilersOut = out; }
110
112 CAircraftEngineList getEngines() const { return m_engines; }
113
115 CAircraftEngineList &engines() { return m_engines; }
116
118 CAircraftEngine getEngine(int number) const;
119
121 int getEnginesCount() const { return m_engines.size(); }
122
124 bool isEngineOn(int number) const;
125
127 bool isAnyEngineOn() const;
128
130 void setEngines(const CAircraftEngineList &engines) { m_engines = engines; }
131
133 void setEngines(const CAircraftEngine &engine, int engineNumber);
134
136 bool isOnGround() const { return m_isOnGround; }
137
139 void setOnGround(bool onGround) { m_isOnGround = onGround; }
140
142 PartsDetails getPartsDetails() const { return static_cast<PartsDetails>(m_partsDetails); }
143
146
148 void setPartsDetails(PartsDetails details) { m_partsDetails = static_cast<int>(details); }
149
151 QString convertToQString(bool i18n = false) const;
152
155 QJsonObject toIncrementalJson() const;
156
159 QJsonObject toFullJson() const;
160
162 bool isNull() const;
163
165 bool equalValues(const CAircraftParts &other) const;
166
168 static const CAircraftParts &null();
169
171 static const QString &partsDetailsToString(PartsDetails details);
172
174 static const QString &attributeNameIsFullJson();
175
177 static constexpr int attributesCountFullJson = 7;
178
179 private:
180 CAircraftLights m_lights;
181 CAircraftEngineList m_engines;
182 int m_partsDetails = static_cast<int>(NotSet);
183 int m_flapsPercentage = 0;
184 bool m_gearDown = false;
185 bool m_spoilersOut = false;
186 bool m_isOnGround = false;
187 QString m_guessingDetails;
188
192 SWIFT_METAMEMBER_NAMED(gearDown, "gear_down"),
193 SWIFT_METAMEMBER_NAMED(flapsPercentage, "flaps_pct"),
194 SWIFT_METAMEMBER_NAMED(spoilersOut, "spoilers_out"),
198 SWIFT_METAMEMBER(timestampMSecsSinceEpoch, 0, DisabledForJson | DisabledForComparison),
200 };
201} // namespace swift::misc::aviation
202
204
205#endif // SWIFT_MISC_AVIATION_AIRCRAFTPARTS_H
Non-owning reference to a CPropertyIndex with a subset of its features.
ITimestampWithOffsetBased()=default
Constructor.
Value object encapsulating information about aircraft's engines.
Value object encapsulating a list of aircraft engines.
Value object encapsulating information about aircraft's lights.
Value object encapsulating information of aircraft's parts.
void setOnGround(bool onGround)
Set aircraft on ground.
bool isGearDown() const
Is gear down?
CAircraftLights getLights() const
Get aircraft lights.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
bool isSpoilersOut() const
Are spoilers out?
const QString & getPartsDetailsAsString() const
Parts details as string.
CAircraftEngineList & engines()
Direct access to engines, meant for simple value modifications.
void setEngines(const CAircraftEngineList &engines)
Set engines.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
CAircraftParts()=default
Default constructor.
bool isOnGround() const
Is aircraft on ground?
void setGearDown(bool down)
Set gear down.
void setPartsDetails(PartsDetails details)
Set parts details.
void setLights(const CAircraftLights &lights)
Set aircraft lights.
PartsDetails getPartsDetails() const
Get parts details.
int comparePropertyByIndex(CPropertyIndexRef index, const CAircraftParts &compareValue) const
Compare for index.
CAircraftLights & lights()
Reference to lights, meant for easy direct changes of the values.
static constexpr int attributesCountFullJson
Number of attributes for full JSON.
void setFlapsPercent(int flapsPercent)
Set flaps position in percent.
static const QString & partsDetailsToString(PartsDetails details)
Convert to QString.
int getFlapsPercent() const
Get flaps position in percent.
void setSpoilersOut(bool out)
Set spoilers out.
CAircraftEngineList getEngines() const
Get engines.
int getEnginesCount() const
Number of engines.
#define SWIFT_METAMEMBER(MEMBER,...)
Macro to define an element within a metaclass.
Definition metaclass.h:72
#define SWIFT_METAMEMBER_NAMED(MEMBER, NAME,...)
Same as SWIFT_METAMEMBER but the second parameter is a string literal containing the JSON name of the...
Definition metaclass.h:80
#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
@ DisabledForJson
Element will be ignored during JSON serialization.
Definition metaclass.h:204
#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