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  };
38 
40  CAircraftLights() = default;
41 
43  CAircraftLights(std::nullptr_t) : m_isNull(true) {}
44 
46  CAircraftLights(bool strobeOn, bool landingOn, bool taxiOn, bool beaconOn, bool navOn, bool logoOn);
47 
49  CAircraftLights(bool strobeOn, bool landingOn, bool taxiOn, bool beaconOn, bool navOn, bool logoOn,
50  bool recognition, bool cabin);
51 
53  bool isStrobeOn() const { return m_strobeOn; }
54 
56  void setStrobeOn(bool on) { m_strobeOn = on; }
57 
59  bool isLandingOn() const { return m_landingOn; }
60 
62  void setLandingOn(bool on) { m_landingOn = on; }
63 
65  bool isTaxiOn() const { return m_taxiOn; }
66 
68  void setTaxiOn(bool on) { m_taxiOn = on; }
69 
71  bool isBeaconOn() const { return m_beaconOn; }
72 
74  void setBeaconOn(bool on) { m_beaconOn = on; }
75 
77  bool isNavOn() const { return m_navOn; }
78 
80  void setNavOn(bool on) { m_navOn = on; }
81 
83  bool isLogoOn() const { return m_logoOn; }
84 
86  void setLogoOn(bool on) { m_logoOn = on; }
87 
89  bool isRecognitionOn() const { return m_recognition; }
90 
92  void setRecognitionOn(bool on) { m_recognition = on; }
93 
95  bool isCabinOn() const { return m_cabin; }
96 
98  void setCabinOn(bool on) { m_cabin = on; }
99 
101  void setAllOn();
102 
104  void setAllOff();
105 
107  QVariant propertyByIndex(CPropertyIndexRef index) const;
108 
110  void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
111 
113  int comparePropertyByIndex(CPropertyIndexRef index, const CAircraftLights &compareValue) const;
114 
116  QString convertToQString(bool i18n = false) const;
117 
119  static CAircraftLights allLightsOn();
120 
122  static CAircraftLights allLightsOff();
123 
125  bool isNull() const { return m_isNull; }
126 
128  void setNull(bool null) { m_isNull = null; }
129 
130  private:
131  bool m_isNull = false;
132  bool m_strobeOn = false;
133  bool m_landingOn = false;
134  bool m_taxiOn = false;
135  bool m_beaconOn = false;
136  bool m_navOn = false;
137  bool m_logoOn = false;
138  bool m_recognition = false;
139  bool m_cabin = false;
140 
143  SWIFT_METAMEMBER(isNull, 0, DisabledForJson), // disable since JSON is used for network
144  SWIFT_METAMEMBER_NAMED(strobeOn, "strobe_on"),
145  SWIFT_METAMEMBER_NAMED(landingOn, "landing_on"),
146  SWIFT_METAMEMBER_NAMED(taxiOn, "taxi_on"),
147  SWIFT_METAMEMBER_NAMED(beaconOn, "beacon_on"),
148  SWIFT_METAMEMBER_NAMED(navOn, "nav_on"),
149  SWIFT_METAMEMBER_NAMED(logoOn, "logo_on"),
150  SWIFT_METAMEMBER(recognition, 0, DisabledForJson), // disable since JSON is used for network
151  SWIFT_METAMEMBER(cabin, 0, DisabledForJson) // disable since JSON is used for network
152  );
153  };
154 } // namespace swift::misc::aviation
155 
156 Q_DECLARE_METATYPE(swift::misc::aviation::CAircraftLights)
157 
158 #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.
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 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:73
#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:81
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition: metaclass.h:53
@ DisabledForJson
Element will be ignored during JSON serialization.
Definition: metaclass.h:206
#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