swift
aircraftlights.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_AIRCRAFTLIGHTS_H
7 #define SWIFT_MISC_AVIATION_AIRCRAFTLIGHTS_H
8 
9 #include <QMetaType>
10 #include <QString>
11 
12 #include "misc/metaclass.h"
13 #include "misc/propertyindexref.h"
14 #include "misc/swiftmiscexport.h"
15 #include "misc/valueobject.h"
16 
17 SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::aviation, CAircraftLights)
18 
19 namespace swift::misc::aviation
20 {
22  class SWIFT_MISC_EXPORT CAircraftLights : public CValueObject<CAircraftLights>
23  {
24  public:
27  {
28  IndexIsNull = CPropertyIndexRef::GlobalIndexINullable,
29  IndexStrobe = CPropertyIndexRef::GlobalIndexCAircraftLights,
30  IndexLanding,
31  IndexTaxi,
32  IndexBeacon,
33  IndexNav,
34  IndexLogo,
35  IndexRecognition,
36  IndexCabin,
37  IndexWing,
38  };
39 
41  CAircraftLights() = default;
42 
44  CAircraftLights(std::nullptr_t) : m_isNull(true) {}
45 
47  CAircraftLights(bool strobeOn, bool landingOn, bool taxiOn, bool beaconOn, bool navOn, bool logoOn);
48 
50  CAircraftLights(bool strobeOn, bool landingOn, bool taxiOn, bool beaconOn, bool navOn, bool logoOn,
51  bool recognition, bool cabin);
52 
54  CAircraftLights(bool strobeOn, bool landingOn, bool taxiOn, bool beaconOn, bool navOn, bool logoOn,
55  bool recognitionOn, bool cabin, bool wingOn);
56 
58  bool isStrobeOn() const { return m_strobeOn; }
59 
61  void setStrobeOn(bool on) { m_strobeOn = on; }
62 
64  bool isLandingOn() const { return m_landingOn; }
65 
67  void setLandingOn(bool on) { m_landingOn = on; }
68 
70  bool isTaxiOn() const { return m_taxiOn; }
71 
73  void setTaxiOn(bool on) { m_taxiOn = on; }
74 
76  bool isBeaconOn() const { return m_beaconOn; }
77 
79  void setBeaconOn(bool on) { m_beaconOn = on; }
80 
82  bool isNavOn() const { return m_navOn; }
83 
85  void setNavOn(bool on) { m_navOn = on; }
86 
88  bool isLogoOn() const { return m_logoOn; }
89 
91  void setLogoOn(bool on) { m_logoOn = on; }
92 
94  bool isRecognitionOn() const { return m_recognitionOn; }
95 
97  void setRecognitionOn(bool on) { m_recognitionOn = on; }
98 
100  bool isCabinOn() const { return m_cabinOn; }
101 
103  void setCabinOn(bool on) { m_cabinOn = on; }
104 
106  bool isWingOn() const { return m_wingOn; }
107 
109  void setWingOn(bool on) { m_wingOn = on; }
110 
112  void setAllOn();
113 
115  void setAllOff();
116 
118  QVariant propertyByIndex(CPropertyIndexRef index) const;
119 
121  void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
122 
124  int comparePropertyByIndex(CPropertyIndexRef index, const CAircraftLights &compareValue) const;
125 
127  QString convertToQString(bool i18n = false) const;
128 
130  static CAircraftLights allLightsOn();
131 
133  static CAircraftLights allLightsOff();
134 
136  bool isNull() const { return m_isNull; }
137 
139  void setNull(bool null) { m_isNull = null; }
140 
141  private:
142  bool m_isNull = false;
143  bool m_strobeOn = false;
144  bool m_landingOn = false;
145  bool m_taxiOn = false;
146  bool m_beaconOn = false;
147  bool m_navOn = false;
148  bool m_logoOn = false;
149  bool m_recognitionOn = false;
150  bool m_cabinOn = false;
151  bool m_wingOn = false;
152 
153  // TODO TZ check if disabled lights can be activated. for testing we keep them enabled in JSON
156  SWIFT_METAMEMBER(isNull, 0, DisabledForJson), // disable since JSON is used for network
157  SWIFT_METAMEMBER_NAMED(strobeOn, "strobe_on"),
158  SWIFT_METAMEMBER_NAMED(landingOn, "landing_on"),
159  SWIFT_METAMEMBER_NAMED(taxiOn, "taxi_on"),
160  SWIFT_METAMEMBER_NAMED(beaconOn, "beacon_on"),
161  SWIFT_METAMEMBER_NAMED(navOn, "nav_on"),
162  SWIFT_METAMEMBER_NAMED(logoOn, "logo_on"),
163  SWIFT_METAMEMBER_NAMED(recognitionOn,"recognition_on"),
164  SWIFT_METAMEMBER_NAMED(cabinOn, "cabin_on"),
165  SWIFT_METAMEMBER_NAMED(wingOn, "wing_on")
166  //SWIFT_METAMEMBER(recognitionOn, 0, DisabledForJson), // disable since JSON is used for network
167  //SWIFT_METAMEMBER(cabinOn, 0, DisabledForJson), // disable since JSON is used for network
168  //SWIFT_METAMEMBER(wingOn, 0, DisabledForJson) // disable since JSON is used for network
169  );
170  };
171 } // namespace swift::misc::aviation
172 
173 Q_DECLARE_METATYPE(swift::misc::aviation::CAircraftLights)
174 
175 #endif // SWIFT_MISC_AVIATION_AIRCRAFTLIGHTS_H
Non-owning reference to a CPropertyIndex with a subset of its features.
Mix of the most commonly used mixin classes.
Definition: valueobject.h:114
Value object encapsulating information about aircraft's lights.
void setStrobeOn(bool on)
Set strobe lights.
void setWingOn(bool on)
Set wing lights.
bool isRecognitionOn() const
Recognition lights on?
void setLogoOn(bool on)
Set logo lights.
CAircraftLights()=default
Default constructor.
bool isCabinOn() const
Cabin lights on?
void setBeaconOn(bool on)
Set beacon lights.
bool isLandingOn() const
Landing lights on?
bool isBeaconOn() const
Beacon lights on?
void setTaxiOn(bool on)
Set taxi lights.
void setCabinOn(bool on)
Set cabin lights.
void setNavOn(bool on)
Set nav lights.
CAircraftLights(std::nullptr_t)
Null constructor.
bool isNavOn() const
Nac lights on?
bool isWingOn() const
Wing light on?
bool isLogoOn() const
Logo lights on?
bool isTaxiOn() const
Taxi lights on?
void setRecognitionOn(bool on)
Set recognition lights.
bool isStrobeOn() const
Strobes lights on?
void setLandingOn(bool on)
Set landing lights.
#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
@ 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