swift
Loading...
Searching...
No Matches
simulatedaircraft.cpp
1// SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#include <tuple>
7
8#include <QStringBuilder>
9
12#include "misc/pq/constants.h"
14#include "misc/stringutils.h"
15#include "misc/verify.h"
16
17using namespace swift::misc;
18using namespace swift::misc::physical_quantities;
19using namespace swift::misc::aviation;
20using namespace swift::misc::network;
21
22SWIFT_DEFINE_VALUEOBJECT_MIXINS(swift::misc::simulation, CSimulatedAircraft)
23
24namespace swift::misc::simulation
25{
27
28 CSimulatedAircraft::CSimulatedAircraft(const CAircraftModel &model) : m_models({ model, model })
29 {
30 this->setCallsign(model.getCallsign());
31 this->init();
32 }
33
35 const CAircraftSituation &situation)
36 : m_callsign(callsign), m_pilot(user), m_situation(situation)
37 {
38 this->init();
39 }
40
41 CSimulatedAircraft::CSimulatedAircraft(const CCallsign &callsign, const CAircraftModel &model, const CUser &user,
42 const CAircraftSituation &situation)
43 : m_callsign(callsign), m_pilot(user), m_situation(situation)
44 {
45 this->setModel(model);
46 this->init();
47 }
48
49 void CSimulatedAircraft::init()
50 {
51 Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
52
53 // sync some values, order here is crucial
54 // set get/set thing here updates the redundant data (e.g. livery / model.livery)
55 this->setCallsign(this->getCallsign());
57 this->setModel(this->getModel());
58 }
59
60 void CSimulatedAircraft::setCockpit(const CComSystem &com1, const CComSystem &com2, const CTransponder &transponder)
61 {
62 this->setCom1System(com1);
63 this->setCom2System(com2);
64 this->setTransponder(transponder);
65 }
66
67 void CSimulatedAircraft::setCockpit(const CComSystem &com1, const CComSystem &com2, int transponderCode,
68 CTransponder::TransponderMode transponderMode)
69 {
70 this->setCom1System(com1);
71 this->setCom2System(com2);
72 m_transponder.setTransponderCode(transponderCode);
73 m_transponder.setTransponderMode(transponderMode);
74 }
75
77 const CTransponder &transponder) const
78 {
79 return this->getCom1System() != com1 || this->getCom2System() != com2 || this->getTransponder() != transponder;
80 }
81
83 const CTransponder &transponder)
84 {
85 return this->getCom1System() == com1 && this->getCom2System() == com2 && this->getTransponder() == transponder;
86 }
87
89 {
90 if (m_callsign.isEmpty())
91 {
92 return false;
93 }
94 if (m_pilot.isNull())
95 {
96 return false;
97 }
98 return true;
99 }
100
102 {
103 CAircraftVelocity velocity = m_situation.getVelocity();
104 m_situation = situation;
105 if (m_situation.getVelocity() == CAircraftVelocity {})
106 {
107 m_situation.setVelocity(velocity);
108 }
109
110 m_situation.setCallsign(this->getCallsign());
112 }
113
115 {
116 return m_models[CurrentModel].getAircraftIcaoCode();
117 }
118
120 {
121 m_pilot = user;
122 m_pilot.setCallsign(m_callsign);
123 }
124
126 {
127 if (!this->hasModelString())
128 {
129 return false;
130 }
131 return m_enabled;
132 }
133
135 {
136 if (m_enabled == enabled)
137 {
138 return false;
139 }
140 m_enabled = enabled;
141 return true;
142 }
143
145 {
146 if (m_fastPositionUpdates == useFastPositions)
147 {
148 return false;
149 }
150 m_fastPositionUpdates = useFastPositions;
151 return true;
152 }
153
158
160 {
161 if (m_rendered == rendered)
162 {
163 return false;
164 }
165 m_rendered = rendered;
166 return true;
167 }
168
173
175 {
177 {
178 return this->getAircraftIcaoCodeDesignator() % u'/' % this->getAirlineIcaoCodeDesignator();
179 }
180 if (this->hasAirlineDesignator())
181 {
182 return this->getAirlineIcaoCodeDesignator();
183 }
184 return this->getAircraftIcaoCodeDesignator();
185 }
186
191
193 const CAirlineIcaoCode &airlineIcaoCode)
194 {
195 if (this->getLivery().getAirlineIcaoCode() != airlineIcaoCode)
196 {
197 // create a dummy livery for given ICAO code
198 const CLivery newLivery(CLivery::getStandardCode(airlineIcaoCode), airlineIcaoCode,
199 "Standard auto generated");
200 m_models[CurrentModel].setLivery(newLivery);
201 }
202 return m_models[CurrentModel].setAircraftIcaoCode(aircraftIcaoCode);
203 }
204
206 {
207 return m_models[CurrentModel].getAirlineIcaoCode();
208 }
209
214
216 {
217 m_models[CurrentModel].setAircraftIcaoDesignator(designator);
218 }
219
221
226
228 {
229 switch (unit)
230 {
231 case CComSystem::Com1: return this->getCom1System();
232 case CComSystem::Com2: return this->getCom2System();
233 default: break;
234 }
235 SWIFT_VERIFY_X(false, Q_FUNC_INFO, "Wrong unit");
236 return {}; // avoid warning
237 }
238
240 {
241 this->setCockpit(aircraft.getCom1System(), aircraft.getCom2System(), aircraft.getTransponder());
242 this->setSelcal(aircraft.getSelcal());
243 }
244
246 {
247 switch (unit)
248 {
249 case CComSystem::Com1: this->setCom1System(com); break;
250 case CComSystem::Com2: this->setCom2System(com); break;
251 default: SWIFT_VERIFY_X(false, Q_FUNC_INFO, "Wrong unit"); break;
252 }
253 }
254
256 {
257 if (!CComSystem::isValidComFrequency(frequency))
258 {
259 return false;
260 }
261 m_com1system.setFrequencyActive(frequency);
262 return true;
263 }
264
266 {
267 if (!CComSystem::isValidComFrequency(frequency))
268 {
269 return false;
270 }
271 m_com2system.setFrequencyActive(frequency);
272 return true;
273 }
274
276 {
277 if (!CComSystem::isValidComFrequency(frequency))
278 {
279 return false;
280 }
281 switch (unit)
282 {
283 case CComSystem::Com1: return this->setCom1ActiveFrequency(frequency);
284 case CComSystem::Com2: return this->setCom2ActiveFrequency(frequency);
285 default: SWIFT_VERIFY_X(false, Q_FUNC_INFO, "Wrong unit"); break;
286 }
287 return false;
288 }
289
299
301 {
303 this->setTransponder(xpdr);
304 }
305
307 {
308 const int engines = this->getModel().getAircraftIcaoCode().getEnginesCount();
309 return engines >= 0 ? engines : m_parts.getEnginesCount();
310 }
311
312 CAircraftLights CSimulatedAircraft::getLights() const { return m_parts.getLights(); }
313
314 void CSimulatedAircraft::setParts(const CAircraftParts &parts) { m_parts = parts; }
315
316 void CSimulatedAircraft::setLights(CAircraftLights &lights) { m_parts.setLights(lights); }
317
318 void CSimulatedAircraft::setAllLightsOn() { m_parts.setAllLightsOn(); }
319
320 void CSimulatedAircraft::setAllLightsOff() { m_parts.setAllLightsOff(); }
321
322 bool CSimulatedAircraft::isVtol() const { return this->getModel().isVtol(); }
323
324 bool CSimulatedAircraft::isMilitary() const { return this->getModel().isMilitary(); }
325
327 {
328 const CAircraftModel model(networkModel ? this->getNetworkModel() : this->getModel());
330 {
331 if (model.getLivery().hasCombinedCode())
332 {
333 static const QString s("%1 (%2 %3)");
335 model.getLivery().getCombinedCode());
336 }
337 else
338 {
339 static const QString s("%1 (%2)");
341 }
342 }
343
344 if (!this->hasAircraftDesignator())
345 {
346 return model.getLivery().getCombinedCode();
347 }
348 else if (model.getLivery().hasCombinedCode())
349 {
350 static const QString s("%1 (%2)");
351 return s.arg(model.getAircraftIcaoCodeDesignator(), model.getLivery().getCombinedCode());
352 }
353
354 return model.getAircraftIcaoCode().getDesignator();
355 }
356
358 {
359 if (index.isMyself())
360 {
361 return QVariant::fromValue(*this);
362 }
363 const auto i = index.frontCasted<ColumnIndex>();
364 switch (i)
365 {
366 case IndexModel: return this->getModel().propertyByIndex(index.copyFrontRemoved());
367 case IndexNetworkModel: return this->getNetworkModel().propertyByIndex(index.copyFrontRemoved());
368 case IndexNetworkModelAircraftIcaoDifference: return this->getNetworkModelAircraftIcaoDifference();
369 case IndexNetworkModelAirlineIcaoDifference: return this->getNetworkModelAirlineIcaoDifference();
370 case IndexNetworkModelLiveryDifference: return this->getNetworkModelLiveryDifference();
371 case IndexEnabled: return QVariant::fromValue(this->isEnabled());
372 case IndexRendered: return QVariant::fromValue(this->isRendered());
373 case IndexPartsSynchronized: return QVariant::fromValue(this->isPartsSynchronized());
374 case IndexFastPositionUpdates: return QVariant::fromValue(this->fastPositionUpdates());
375 case IndexSupportsGndFlag: return QVariant::fromValue(this->isSupportingGndFlag());
376 case IndexCallsign: return m_callsign.propertyByIndex(index.copyFrontRemoved());
377 case IndexPilot: return m_pilot.propertyByIndex(index.copyFrontRemoved());
378 case IndexRelativeDistance: return m_relativeDistance.propertyByIndex(index.copyFrontRemoved());
379 case IndexCom1System: return m_com1system.propertyByIndex(index.copyFrontRemoved());
380 case IndexCom2System: return m_com2system.propertyByIndex(index.copyFrontRemoved());
381 case IndexTransponder: return m_transponder.propertyByIndex(index.copyFrontRemoved());
382 case IndexSituation: return m_situation.propertyByIndex(index.copyFrontRemoved());
383 case IndexAircraftIcaoCode: return this->getAircraftIcaoCode().propertyByIndex(index.copyFrontRemoved());
384 case IndexLivery: return this->getLivery().propertyByIndex(index.copyFrontRemoved());
385 case IndexParts: return m_parts.propertyByIndex(index.copyFrontRemoved());
386 case IndexIsVtol: return QVariant::fromValue(this->isVtol());
387 case IndexCombinedIcaoLiveryString: return QVariant::fromValue(this->getCombinedIcaoLiveryString(false));
388 case IndexCombinedIcaoLiveryStringNetworkModel:
390 default:
391 return (ICoordinateWithRelativePosition::canHandleIndex(index)) ?
392 ICoordinateWithRelativePosition::propertyByIndex(index) :
394 }
395 }
396
398 {
399 if (index.isMyself())
400 {
401 (*this) = variant.value<CSimulatedAircraft>();
402 return;
403 }
404 const auto i = index.frontCasted<ColumnIndex>();
405 switch (i)
406 {
407 case IndexCallsign: m_callsign.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
408 case IndexPilot: m_pilot.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
409 case IndexRelativeDistance: m_relativeDistance.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
410 case IndexCom1System: m_com1system.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
411 case IndexCom2System: m_com2system.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
412 case IndexTransponder: m_transponder.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
413 case IndexSituation: m_situation.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
414 case IndexParts: m_parts.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
415 case IndexNetworkModel: m_models[NetworkModel].setPropertyByIndex(index.copyFrontRemoved(), variant); break;
416 case IndexEnabled: m_enabled = variant.toBool(); break;
417 case IndexRendered: m_rendered = variant.toBool(); break;
418 case IndexPartsSynchronized: m_partsSynchronized = variant.toBool(); break;
419 case IndexFastPositionUpdates: m_fastPositionUpdates = variant.toBool(); break;
420 case IndexSupportsGndFlag: m_supportsGndFlag = variant.toBool(); break;
421 case IndexLivery: Q_ASSERT_X(false, Q_FUNC_INFO, "Unsupported"); break;
422 case IndexModel:
423 m_models[CurrentModel].setPropertyByIndex(index.copyFrontRemoved(), variant);
424 this->setModel(m_models[CurrentModel]); // sync some values such as callsign
425 break;
426 default:
427 if (ICoordinateWithRelativePosition::canHandleIndex(index))
428 {
429 ICoordinateWithRelativePosition::setPropertyByIndex(index, variant);
430 }
431 else
432 {
433 CValueObject::setPropertyByIndex(index, variant);
434 }
435 break;
436 }
437 }
438
440 const CSimulatedAircraft &compareValue) const
441 {
442 if (index.isMyself())
443 {
444 return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
445 }
446 const auto i = index.frontCasted<ColumnIndex>();
447 switch (i)
448 {
449 case IndexCallsign:
450 return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
451 case IndexPilot: return m_pilot.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPilot());
452 case IndexSituation:
453 return m_situation.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getSituation());
454 case IndexRelativeDistance:
455 return m_relativeDistance.comparePropertyByIndex(index.copyFrontRemoved(),
456 compareValue.getRelativeDistance());
457 case IndexCom1System:
458 return m_com1system.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCom1System());
459 case IndexCom2System:
460 return m_com2system.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCom2System());
461 case IndexTransponder:
462 return Compare::compare(m_transponder.getTransponderCode(),
463 compareValue.getTransponder().getTransponderCode());
464 case IndexLivery:
465 return this->getLivery().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getLivery());
466 case IndexParts: return m_parts.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getParts());
467 case IndexModel:
468 return m_models[CurrentModel].comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getModel());
469 case IndexNetworkModel:
470 return m_models[NetworkModel].comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getModel());
471 case IndexNetworkModelAircraftIcaoDifference:
474 case IndexNetworkModelAirlineIcaoDifference:
477 case IndexNetworkModelLiveryDifference:
479 case IndexEnabled: return Compare::compare(this->isEnabled(), compareValue.isEnabled());
480 case IndexRendered: return Compare::compare(this->isRendered(), compareValue.isRendered());
481 case IndexPartsSynchronized:
482 return Compare::compare(this->isPartsSynchronized(), compareValue.isPartsSynchronized());
483 case IndexFastPositionUpdates:
484 return Compare::compare(this->fastPositionUpdates(), compareValue.fastPositionUpdates());
485 case IndexSupportsGndFlag:
486 return Compare::compare(this->isSupportingGndFlag(), compareValue.isSupportingGndFlag());
487 case IndexCombinedIcaoLiveryString:
488 return this->getCombinedIcaoLiveryString(false).compare(compareValue.getCombinedIcaoLiveryString(false));
489 case IndexCombinedIcaoLiveryStringNetworkModel:
490 return this->getCombinedIcaoLiveryString(true).compare(compareValue.getCombinedIcaoLiveryString(true));
491 default:
492 if (ICoordinateWithRelativePosition::canHandleIndex(index))
493 {
494 return ICoordinateWithRelativePosition::comparePropertyByIndex(index, compareValue);
495 }
496 break;
497 }
498 SWIFT_VERIFY_X(false, Q_FUNC_INFO, qUtf8Printable("No comparison for index " + index.toQString()));
499 return 0;
500 }
501
503 {
504 Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
505 return this->hasNetworkModel() ? m_models[NetworkModel] : m_models[CurrentModel];
506 }
507
509 {
510 Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
511 return m_models[NetworkModel].hasModelString() || !m_models[NetworkModel].getCallsign().isEmpty();
512 }
513
515 {
517 if (!icaoNw.hasDesignator())
518 {
519 return QStringLiteral("[x] no nw. ICAO");
520 }
521
522 const CAircraftIcaoCode icaoModel(this->getModel().getAircraftIcaoCode());
523 if (!icaoModel.hasDesignator())
524 {
525 return QStringLiteral("[x] no sim. ICAO");
526 }
527
528 if (icaoModel.isDbEqual(icaoNw) || icaoModel == icaoNw)
529 {
530 return u"[==] " % icaoModel.getDesignatorDbKey();
531 }
532 if (icaoModel.getDesignator() == icaoNw.getDesignator())
533 {
534 return u"[=] " % icaoModel.getDesignator();
535 }
536 return QStringLiteral("%1 -> %2").arg(icaoNw.getDesignator(), icaoModel.getDesignator());
537 }
538
540 {
541 static const QString diff("%1 -> %2");
542
543 if (this->getModel().getLivery().isColorLivery() || this->getNetworkModel().getLivery().isColorLivery())
544 {
545 if (this->getModel().getLivery().isColorLivery() && this->getNetworkModel().getLivery().isColorLivery())
546 {
547 return ("col/col");
548 }
549
550 if (this->getModel().getLivery().isColorLivery())
551 {
552 return diff.arg("col", this->getNetworkModel().getAirlineIcaoCode().getDesignator());
553 }
554 return diff.arg(this->getNetworkModel().getAirlineIcaoCode().getDesignator(), "col");
555 }
556
557 const CAirlineIcaoCode icao(this->getModel().getAirlineIcaoCode());
559 if (icao.isDbEqual(icaoNw) || icao == icaoNw)
560 {
561 return u"[==] " % icao.getDesignatorDbKey();
562 }
563 if (icao.getDesignator() == icaoNw.getDesignator())
564 {
565 return u"[=] " % icao.getDesignatorDbKey();
566 }
567 return diff.arg(icaoNw.getDesignator(), icao.getDesignator());
568 }
569
571 {
572 Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
573
574 const CLivery livery(this->getModel().getLivery());
575 const CLivery liveryNw(this->getNetworkModel().getLivery());
576 if (livery.isDbEqual(liveryNw) || livery == liveryNw)
577 {
578 return QStringLiteral("[==] ") + livery.getCombinedCodePlusInfo();
579 }
580 if (livery.getCombinedCode() == liveryNw.getCombinedCode())
581 {
582 return QStringLiteral("[=] ") + livery.getCombinedCodePlusInfo();
583 }
584 if (livery.isAirlineLivery() && liveryNw.isAirlineLivery())
585 {
587 }
588
589 static const QString diff("%1 -> %2");
590 return diff.arg(liveryNw.getCombinedCodePlusInfo(), livery.getCombinedCodePlusInfo());
591 }
592
594 {
595 Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
596
597 // sync the callsigns
598 m_models[CurrentModel] = model;
599 this->setCallsign(this->hasValidCallsign() ? this->getCallsign() : model.getCallsign());
601 }
602
604 {
605 Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
606 m_models[NetworkModel] = model;
607 }
608
610 {
611 Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
612 const CAircraftModel nwModel = m_models[NetworkModel];
613 m_models[CurrentModel] = nwModel;
614 return true;
615 }
616
618 {
619 if (cg.isNull())
620 {
621 return false;
622 }
623 // ???? set to both models, or only the matched model ????
624 const int c = m_models.setCG(cg);
625 return c > 0;
626 }
627
629 {
630 Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
631 m_models[CurrentModel].setModelString(modelString);
632 }
633
635 {
636 Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
637 m_callsign = callsign;
638 m_models[CurrentModel].setCallsign(callsign);
639 m_models[NetworkModel].setCallsign(callsign);
640 m_pilot.setCallsign(callsign);
641 }
642
644 {
645 return m_com1system.isActiveFrequencySameFrequency(comFrequency) ||
646 m_com2system.isActiveFrequencySameFrequency(comFrequency);
647 }
648
650 {
651 return (m_transponder.setTransponderMode(mode));
652 }
653
655 {
656 const QString s = m_callsign.toQString(i18n) % u' ' % m_pilot.toQString(i18n) % u' ' %
657 m_situation.toQString(i18n) % u' ' % m_com1system.toQString(i18n) % u' ' %
658 m_com2system.toQString(i18n) % u' ' % m_transponder.toQString(i18n) % u" enabled: " %
659 swift::misc::boolToYesNo(this->isEnabled()) % u" rendered: " %
660 swift::misc::boolToYesNo(this->isRendered()) % u' ' % this->getModel().toQString(i18n);
661 return s;
662 }
663} // namespace swift::misc::simulation
Non-owning reference to a CPropertyIndex with a subset of its features.
Q_REQUIRED_RESULT CPropertyIndexRef copyFrontRemoved() const
Copy with first element removed.
QString toQString(bool i18n=false) const
Cast as QString.
CastType frontCasted() const
First element casted to given type, usually the PropertIndex enum.
bool isMyself() const
Myself index, used with nesting.
size_type size() const
Returns number of elements in the sequence.
Definition sequence.h:273
Value object for ICAO classification.
bool hasDesignator() const
Aircraft designator?
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
int getEnginesCount() const
Engine count if any, -1 if no value is set.
QString getDesignatorDbKey() const
Designator and DB key.
const QString & getDesignator() const
Get ICAO designator, e.g. "B737".
const QString & getCombinedType() const
Get type, e.g. "L2J".
Value object encapsulating information about aircraft's lights.
Value object encapsulating information of aircraft's parts.
void setLights(const CAircraftLights &lights)
Set aircraft lights.
Value object encapsulating information of an aircraft's situation.
void setCallsign(const CCallsign &callsign)
Corresponding callsign.
bool hasInboundGroundDetails() const
Has inbound ground details.
Velocity and angular velocity for 6DOF bodies.
Value object for ICAO classification.
QString getDesignatorDbKey() const
Designator and DB key.
const QString & getDesignator() const
Get airline, e.g. "DLH".
Value object encapsulating information of a callsign.
Definition callsign.h:30
COM system (aka "radio").
Definition comsystem.h:37
static bool isValidComFrequency(const physical_quantities::CFrequency &f)
Valid COM frequency (either civil or military).
Value object encapsulating information about an airpot.
Definition livery.h:29
const QString & getCombinedCode() const
Combined code.
Definition livery.h:71
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
Definition livery.cpp:376
static QString getStandardCode(const aviation::CAirlineIcaoCode &airline)
Standard code for airline.
Definition livery.cpp:333
bool isAirlineLivery() const
Livery representing airline.
Definition livery.cpp:174
bool hasCombinedCode() const
Livery combined code available?
Definition livery.cpp:168
int comparePropertyByIndex(CPropertyIndexRef index, const CLivery &compareValue) const
Compare for index.
Definition livery.cpp:424
QString getCombinedCodePlusInfo() const
Combined code plus info.
Definition livery.cpp:58
int getTransponderCode() const
Transponder code.
@ StateStandby
not a real mode, more a state
Definition transponder.h:33
bool isDbEqual(const IDatastoreObjectWithIntegerKey &other) const
Same DB key and hence equal.
Definition datastore.h:105
const physical_quantities::CLength & getRelativeDistance() const
Get the distance.
physical_quantities::CLength m_relativeDistance
temporary stored value
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
Definition mixinindex.h:167
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
Definition mixinindex.h:180
QString toQString(bool i18n=false) const
Cast as QString.
Definition mixinstring.h:74
Value object encapsulating information of a user.
Definition user.h:28
bool setCallsign(const aviation::CCallsign &callsign)
Set associated callsign.
Definition user.cpp:71
Physical unit length (length).
Definition length.h:18
static const CFrequency & FrequencyUnicom()
Unicom frequency.
Definition constants.h:29
Aircraft model (used by another pilot, my models on disk).
bool hasAircraftAndAirlineDesignator() const
Designators.
const aviation::CCallsign & getCallsign() const
Corresponding callsign if applicable.
const QString & getAirlineIcaoCodeDesignator() const
Airline ICAO code designator.
const aviation::CLivery & getLivery() const
Get livery.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
void setCG(const physical_quantities::CLength &cg)
Get center of gravity.
const aviation::CAirlineIcaoCode & getAirlineIcaoCode() const
Airline ICAO code.
const QString & getAircraftIcaoCodeDesignator() const
Aircraft ICAO code designator.
bool isMilitary() const
Military model?
const aviation::CAircraftIcaoCode & getAircraftIcaoCode() const
Aircraft ICAO code.
void setCallsign(const aviation::CCallsign &callsign)
Set callsign.
const QString & getAirlineIcaoCodeDesignator() const
Airline ICAO code designator.
bool hasAirlineDesignator() const
Valid airline designator.
bool hasModelString() const
Has model string?
const simulation::CAircraftModel & getNetworkModelOrModel() const
Get network model or (if not existing) model.
const aviation::CSelcal getSelcal() const
SELCAL.
void setModel(const CAircraftModel &model)
Set model.
void setAllLightsOff()
Set aircraft lights off.
QString getNetworkModelAirlineIcaoDifference() const
Difference of network and (rendered) airline ICAO code.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
const aviation::CComSystem & getCom2System() const
Get COM2 system.
void initTransponder()
Meaningful default settings for Transponder.
bool isMilitary() const
Is military aircraft.
const aviation::CComSystem & getCom1System() const
Get COM1 system.
void setCockpit(const CSimulatedAircraft &aircraft)
Set COM unit (all values + transponder and SELCAL).
bool isPartsSynchronized() const
Have parts been synchronized with a remote client?
void initComSystems()
Meaningful default settings for COM Systems.
QString convertToQString(bool i18n=false) const
Cast as QString.
bool isSupportingGndFlag() const
Is supporting gnd.flag?
const aviation::CLivery & getLivery() const
Get livery.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
bool hasNetworkModel() const
Has a network model been set?
bool fastPositionUpdates() const
Support fast position updates.
bool setTransponderMode(aviation::CTransponder::TransponderMode mode)
Set transponder mode.
aviation::CAircraftLights getLights() const
Get aircraft parts.
const aviation::CCallsign & getCallsign() const
Get callsign.
bool setCG(const physical_quantities::CLength &cg)
Set the center of gravity.
void setModelString(const QString &modelString)
Set model string.
QString getCombinedIcaoLiveryString(bool networkModel=false) const
Combined ICAO / color string.
void setSelcal(const aviation::CSelcal &selcal)
Own SELCAL code.
void setSituation(const aviation::CAircraftSituation &situation)
Set situation. Won't overwrite the velocity unless it held the default value.
QString getNetworkModelAircraftIcaoDifference() const
Difference of network and (rendered) aircraft ICAO code.
void setCom1System(const aviation::CComSystem &comSystem)
Set COM1 system.
bool hasComActiveFrequency(const physical_quantities::CFrequency &comFrequency) const
Is comFrequency selected in COM1 or COM2 as active frequency (with 5 kHz spacing for ....
bool setComActiveFrequency(const physical_quantities::CFrequency &frequency, aviation::CComSystem::ComUnit unit)
Set COM frequency.
bool isValidForLogin() const
Is valid for login?
void setComSystem(const aviation::CComSystem &com, aviation::CComSystem::ComUnit unit)
Set COM unit.
bool hasAircraftDesignator() const
Valid designator?
void setLights(aviation::CAircraftLights &lights)
Set aircraft lights.
const aviation::CAircraftIcaoCode & getAircraftIcaoCode() const
Get aircraft ICAO info.
bool setCom1ActiveFrequency(const physical_quantities::CFrequency &frequency)
Set COM1 frequency.
QString getNetworkModelLiveryDifference() const
Difference of network and (rendered) livery code.
const aviation::CAircraftParts & getParts() const
Get aircraft parts.
const QString & getAircraftIcaoCombinedType() const
Aircraft ICAO combined code.
bool hasChangedCockpitData(const aviation::CComSystem &com1, const aviation::CComSystem &com2, const aviation::CTransponder &transponder) const
Changed cockpit data?
const QString & getAircraftIcaoCodeDesignator() const
Aircraft ICAO code designator.
bool toggleFastPositionUpdates()
Toggle fast position updates.
bool hasSameComData(const aviation::CComSystem &com1, const aviation::CComSystem &com2, const aviation::CTransponder &transponder)
Identical COM system?
void setSupportingGndFlag(bool supports)
Indicate gnd.flag is supported.
aviation::CComSystem getComSystem(aviation::CComSystem::ComUnit unit) const
Get COM unit.
const aviation::CTransponder & getTransponder() const
Get transponder.
void setParts(const aviation::CAircraftParts &parts)
Set aircraft parts.
bool hasAircraftAndAirlineDesignator() const
Valid designators?
void setNetworkModel(const CAircraftModel &model)
Set network model.
QString getAirlineAndAircraftIcaoCodeDesignators() const
Aircraft and Airline ICAO code designators.
bool setEnabled(bool enabled)
Enabled / disabled.
const network::CUser & getPilot() const
Get user.
bool setCom2ActiveFrequency(const physical_quantities::CFrequency &frequency)
Set COM2 frequency.
void setAircraftIcaoDesignator(const QString &designator)
Set aircraft ICAO designator.
int comparePropertyByIndex(CPropertyIndexRef index, const CSimulatedAircraft &compareValue) const
Compare for index.
void setTransponder(const aviation::CTransponder &transponder)
Set transponder.
void setCom2System(const aviation::CComSystem &comSystem)
Set COM2 system.
bool isEnabled() const
Enabled? Enable means it shall be displayed in the simulator.
const aviation::CAircraftSituation & getSituation() const
Get situation.
bool setIcaoCodes(const aviation::CAircraftIcaoCode &aircraftIcaoCode, const aviation::CAirlineIcaoCode &airlineIcaoCode)
Set ICAO info.
const simulation::CAircraftModel & getModel() const
Get model (model used for mapping).
const simulation::CAircraftModel & getNetworkModel() const
Get network model.
const aviation::CAirlineIcaoCode & getAirlineIcaoCode() const
Airline ICAO code if any.
bool resetToNetworkModel()
Reset to the newtork model.
void setPilot(const network::CUser &user)
Set pilot.
bool setFastPositionUpdates(bool useFastPositions)
Support fast position updates.
int compare(T a, T b)
Compare arithmetic values.
Free functions in swift::misc.
SWIFT_MISC_EXPORT const QString & boolToYesNo(bool v)
Bool to yes/no.
QString arg(Args &&... args) const const
int compare(QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs)
QVariant fromValue(T &&value)
bool toBool() const const
T value() const &const
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.
Definition valueobject.h:67
#define SWIFT_VERIFY_X(COND, WHERE, WHAT)
A weaker kind of assert.
Definition verify.h:26