swift
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 
11 #include "misc/comparefunctions.h"
12 #include "misc/pq/constants.h"
13 #include "misc/propertyindexref.h"
14 #include "misc/stringutils.h"
15 #include "misc/verify.h"
16 
17 using namespace swift::misc;
18 using namespace swift::misc::physical_quantities;
19 using namespace swift::misc::aviation;
20 using namespace swift::misc::network;
21 
22 SWIFT_DEFINE_VALUEOBJECT_MIXINS(swift::misc::simulation, CSimulatedAircraft)
23 
24 namespace swift::misc::simulation
25 {
26  CSimulatedAircraft::CSimulatedAircraft() { this->init(); }
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());
56  this->setIcaoCodes(this->getAircraftIcaoCode(), this->getAirlineIcaoCode());
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()) { return false; }
91  if (m_pilot.isNull()) { return false; }
92  return true;
93  }
94 
96  {
97  CAircraftVelocity velocity = m_situation.getVelocity();
98  m_situation = situation;
99  if (m_situation.getVelocity() == CAircraftVelocity {}) { m_situation.setVelocity(velocity); }
100 
101  m_situation.setCallsign(this->getCallsign());
103  }
104 
106  {
107  return m_models[CurrentModel].getAircraftIcaoCode();
108  }
109 
111  {
112  m_pilot = user;
113  m_pilot.setCallsign(m_callsign);
114  }
115 
117  {
118  if (!this->hasModelString()) { return false; }
119  return m_enabled;
120  }
121 
123  {
124  if (m_enabled == enabled) { return false; }
125  m_enabled = enabled;
126  return true;
127  }
128 
129  bool CSimulatedAircraft::setFastPositionUpdates(bool useFastPositions)
130  {
131  if (m_fastPositionUpdates == useFastPositions) { return false; }
132  m_fastPositionUpdates = useFastPositions;
133  return true;
134  }
135 
137  {
138  return this->setFastPositionUpdates(!this->fastPositionUpdates());
139  }
140 
142  {
143  if (m_rendered == rendered) { return false; }
144  m_rendered = rendered;
145  return true;
146  }
147 
149  {
151  }
152 
154  {
156  {
157  return this->getAircraftIcaoCodeDesignator() % u'/' % this->getAirlineIcaoCodeDesignator();
158  }
159  if (this->hasAirlineDesignator()) { return this->getAirlineIcaoCodeDesignator(); }
160  return this->getAircraftIcaoCodeDesignator();
161  }
162 
164  {
166  }
167 
169  const CAirlineIcaoCode &airlineIcaoCode)
170  {
171  if (this->getLivery().getAirlineIcaoCode() != airlineIcaoCode)
172  {
173  // create a dummy livery for given ICAO code
174  const CLivery newLivery(CLivery::getStandardCode(airlineIcaoCode), airlineIcaoCode,
175  "Standard auto generated");
176  m_models[CurrentModel].setLivery(newLivery);
177  }
178  return m_models[CurrentModel].setAircraftIcaoCode(aircraftIcaoCode);
179  }
180 
182  {
183  return m_models[CurrentModel].getAirlineIcaoCode();
184  }
185 
187  {
188  return this->getAirlineIcaoCode().getDesignator();
189  }
190 
191  void CSimulatedAircraft::setAircraftIcaoDesignator(const QString &designator)
192  {
193  m_models[CurrentModel].setAircraftIcaoDesignator(designator);
194  }
195 
197 
199  {
200  return this->getModel().hasAircraftAndAirlineDesignator();
201  }
202 
204  {
205  switch (unit)
206  {
207  case CComSystem::Com1: return this->getCom1System();
208  case CComSystem::Com2: return this->getCom2System();
209  default: break;
210  }
211  SWIFT_VERIFY_X(false, Q_FUNC_INFO, "Wrong unit");
212  return CComSystem(); // avoid warning
213  }
214 
216  {
217  this->setCockpit(aircraft.getCom1System(), aircraft.getCom2System(), aircraft.getTransponder());
218  this->setSelcal(aircraft.getSelcal());
219  }
220 
222  {
223  switch (unit)
224  {
225  case CComSystem::Com1: this->setCom1System(com); break;
226  case CComSystem::Com2: this->setCom2System(com); break;
227  default: SWIFT_VERIFY_X(false, Q_FUNC_INFO, "Wrong unit"); break;
228  }
229  }
230 
232  {
233  if (!CComSystem::isValidComFrequency(frequency)) { return false; }
234  m_com1system.setFrequencyActive(frequency);
235  return true;
236  }
237 
239  {
240  if (!CComSystem::isValidComFrequency(frequency)) { return false; }
241  m_com2system.setFrequencyActive(frequency);
242  return true;
243  }
244 
246  {
247  if (!CComSystem::isValidComFrequency(frequency)) { return false; }
248  switch (unit)
249  {
250  case CComSystem::Com1: return this->setCom1ActiveFrequency(frequency);
251  case CComSystem::Com2: return this->setCom2ActiveFrequency(frequency);
252  default: SWIFT_VERIFY_X(false, Q_FUNC_INFO, "Wrong unit"); break;
253  }
254  return false;
255  }
256 
258  {
259  CComSystem com1("COM1", CPhysicalQuantitiesConstants::FrequencyUnicom(),
260  CPhysicalQuantitiesConstants::FrequencyUnicom());
261  CComSystem com2("COM2", CPhysicalQuantitiesConstants::FrequencyUnicom(),
262  CPhysicalQuantitiesConstants::FrequencyUnicom());
263  this->setCom1System(com1);
264  this->setCom2System(com2);
265  }
266 
268  {
269  const CTransponder xpdr(7000, CTransponder::StateStandby);
270  this->setTransponder(xpdr);
271  }
272 
274  {
275  const int engines = this->getModel().getAircraftIcaoCode().getEnginesCount();
276  return engines >= 0 ? engines : m_parts.getEnginesCount();
277  }
278 
280 
281  void CSimulatedAircraft::setParts(const CAircraftParts &parts) { m_parts = parts; }
282 
283  void CSimulatedAircraft::setLights(CAircraftLights &lights) { m_parts.setLights(lights); }
284 
286 
288 
289  bool CSimulatedAircraft::isVtol() const { return this->getModel().isVtol(); }
290 
291  bool CSimulatedAircraft::isMilitary() const { return this->getModel().isMilitary(); }
292 
293  QString CSimulatedAircraft::getCombinedIcaoLiveryString(bool networkModel) const
294  {
295  const CAircraftModel model(networkModel ? this->getNetworkModel() : this->getModel());
297  {
298  if (model.getLivery().hasCombinedCode())
299  {
300  static const QString s("%1 (%2 %3)");
301  return s.arg(model.getAircraftIcaoCodeDesignator(), model.getAirlineIcaoCodeDesignator(),
302  model.getLivery().getCombinedCode());
303  }
304  else
305  {
306  static const QString s("%1 (%2)");
307  return s.arg(model.getAircraftIcaoCodeDesignator(), model.getAirlineIcaoCodeDesignator());
308  }
309  }
310 
311  if (!this->hasAircraftDesignator()) { return model.getLivery().getCombinedCode(); }
312  else if (model.getLivery().hasCombinedCode())
313  {
314  static const QString s("%1 (%2)");
315  return s.arg(model.getAircraftIcaoCodeDesignator(), model.getLivery().getCombinedCode());
316  }
317 
318  return model.getAircraftIcaoCode().getDesignator();
319  }
320 
322  {
323  if (index.isMyself()) { return QVariant::fromValue(*this); }
324  const ColumnIndex i = index.frontCasted<ColumnIndex>();
325  switch (i)
326  {
327  case IndexModel: return this->getModel().propertyByIndex(index.copyFrontRemoved());
328  case IndexNetworkModel: return this->getNetworkModel().propertyByIndex(index.copyFrontRemoved());
329  case IndexNetworkModelAircraftIcaoDifference: return this->getNetworkModelAircraftIcaoDifference();
330  case IndexNetworkModelAirlineIcaoDifference: return this->getNetworkModelAirlineIcaoDifference();
331  case IndexNetworkModelLiveryDifference: return this->getNetworkModelLiveryDifference();
332  case IndexEnabled: return QVariant::fromValue(this->isEnabled());
333  case IndexRendered: return QVariant::fromValue(this->isRendered());
334  case IndexPartsSynchronized: return QVariant::fromValue(this->isPartsSynchronized());
335  case IndexFastPositionUpdates: return QVariant::fromValue(this->fastPositionUpdates());
336  case IndexSupportsGndFlag: return QVariant::fromValue(this->isSupportingGndFlag());
337  case IndexCallsign: return m_callsign.propertyByIndex(index.copyFrontRemoved());
338  case IndexPilot: return m_pilot.propertyByIndex(index.copyFrontRemoved());
339  case IndexRelativeDistance: return m_relativeDistance.propertyByIndex(index.copyFrontRemoved());
340  case IndexCom1System: return m_com1system.propertyByIndex(index.copyFrontRemoved());
341  case IndexCom2System: return m_com2system.propertyByIndex(index.copyFrontRemoved());
342  case IndexTransponder: return m_transponder.propertyByIndex(index.copyFrontRemoved());
343  case IndexSituation: return m_situation.propertyByIndex(index.copyFrontRemoved());
344  case IndexAircraftIcaoCode: return this->getAircraftIcaoCode().propertyByIndex(index.copyFrontRemoved());
345  case IndexLivery: return this->getLivery().propertyByIndex(index.copyFrontRemoved());
346  case IndexParts: return m_parts.propertyByIndex(index.copyFrontRemoved());
347  case IndexIsVtol: return QVariant::fromValue(this->isVtol());
348  case IndexCombinedIcaoLiveryString: return QVariant::fromValue(this->getCombinedIcaoLiveryString(false));
349  case IndexCombinedIcaoLiveryStringNetworkModel:
350  return QVariant::fromValue(this->getCombinedIcaoLiveryString(true));
351  default:
352  return (ICoordinateWithRelativePosition::canHandleIndex(index)) ?
353  ICoordinateWithRelativePosition::propertyByIndex(index) :
355  }
356  }
357 
358  void CSimulatedAircraft::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
359  {
360  if (index.isMyself())
361  {
362  (*this) = variant.value<CSimulatedAircraft>();
363  return;
364  }
365  const ColumnIndex i = index.frontCasted<ColumnIndex>();
366  switch (i)
367  {
368  case IndexCallsign: m_callsign.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
369  case IndexPilot: m_pilot.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
370  case IndexRelativeDistance: m_relativeDistance.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
371  case IndexCom1System: m_com1system.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
372  case IndexCom2System: m_com2system.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
373  case IndexTransponder: m_transponder.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
374  case IndexSituation: m_situation.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
375  case IndexParts: m_parts.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
376  case IndexNetworkModel: m_models[NetworkModel].setPropertyByIndex(index.copyFrontRemoved(), variant); break;
377  case IndexEnabled: m_enabled = variant.toBool(); break;
378  case IndexRendered: m_rendered = variant.toBool(); break;
379  case IndexPartsSynchronized: m_partsSynchronized = variant.toBool(); break;
380  case IndexFastPositionUpdates: m_fastPositionUpdates = variant.toBool(); break;
381  case IndexSupportsGndFlag: m_supportsGndFlag = variant.toBool(); break;
382  case IndexLivery: Q_ASSERT_X(false, Q_FUNC_INFO, "Unsupported"); break;
383  case IndexModel:
384  m_models[CurrentModel].setPropertyByIndex(index.copyFrontRemoved(), variant);
385  this->setModel(m_models[CurrentModel]); // sync some values such as callsign
386  break;
387  default:
388  if (ICoordinateWithRelativePosition::canHandleIndex(index))
389  {
390  ICoordinateWithRelativePosition::setPropertyByIndex(index, variant);
391  }
392  else { CValueObject::setPropertyByIndex(index, variant); }
393  break;
394  }
395  }
396 
398  const CSimulatedAircraft &compareValue) const
399  {
400  if (index.isMyself())
401  {
402  return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
403  }
404  const ColumnIndex i = index.frontCasted<ColumnIndex>();
405  switch (i)
406  {
407  case IndexCallsign:
408  return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
409  case IndexPilot: return m_pilot.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPilot());
410  case IndexSituation:
411  return m_situation.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getSituation());
412  case IndexRelativeDistance:
414  compareValue.getRelativeDistance());
415  case IndexCom1System:
416  return m_com1system.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCom1System());
417  case IndexCom2System:
418  return m_com2system.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCom2System());
419  case IndexTransponder:
420  return Compare::compare(m_transponder.getTransponderCode(),
421  compareValue.getTransponder().getTransponderCode());
422  case IndexLivery:
423  return this->getLivery().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getLivery());
424  case IndexParts: return m_parts.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getParts());
425  case IndexModel:
426  return m_models[CurrentModel].comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getModel());
427  case IndexNetworkModel:
428  return m_models[NetworkModel].comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getModel());
429  case IndexNetworkModelAircraftIcaoDifference:
430  return this->getNetworkModelAircraftIcaoDifference().compare(
432  case IndexNetworkModelAirlineIcaoDifference:
433  return this->getNetworkModelAirlineIcaoDifference().compare(
434  compareValue.getNetworkModelAirlineIcaoDifference());
435  case IndexNetworkModelLiveryDifference:
436  return this->getNetworkModelLiveryDifference().compare(compareValue.getNetworkModelLiveryDifference());
437  case IndexEnabled: return Compare::compare(this->isEnabled(), compareValue.isEnabled());
438  case IndexRendered: return Compare::compare(this->isRendered(), compareValue.isRendered());
439  case IndexPartsSynchronized:
440  return Compare::compare(this->isPartsSynchronized(), compareValue.isPartsSynchronized());
441  case IndexFastPositionUpdates:
442  return Compare::compare(this->fastPositionUpdates(), compareValue.fastPositionUpdates());
443  case IndexSupportsGndFlag:
444  return Compare::compare(this->isSupportingGndFlag(), compareValue.isSupportingGndFlag());
445  case IndexCombinedIcaoLiveryString:
446  return this->getCombinedIcaoLiveryString(false).compare(compareValue.getCombinedIcaoLiveryString(false));
447  case IndexCombinedIcaoLiveryStringNetworkModel:
448  return this->getCombinedIcaoLiveryString(true).compare(compareValue.getCombinedIcaoLiveryString(true));
449  default:
450  if (ICoordinateWithRelativePosition::canHandleIndex(index))
451  {
452  return ICoordinateWithRelativePosition::comparePropertyByIndex(index, compareValue);
453  }
454  break;
455  }
456  SWIFT_VERIFY_X(false, Q_FUNC_INFO, qUtf8Printable("No comparison for index " + index.toQString()));
457  return 0;
458  }
459 
461  {
462  Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
463  return this->hasNetworkModel() ? m_models[NetworkModel] : m_models[CurrentModel];
464  }
465 
467  {
468  Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
469  return m_models[NetworkModel].hasModelString() || !m_models[NetworkModel].getCallsign().isEmpty();
470  }
471 
473  {
474  const CAircraftIcaoCode icaoNw(this->getNetworkModel().getAircraftIcaoCode());
475  if (!icaoNw.hasDesignator()) { return QStringLiteral("[x] no nw. ICAO"); }
476 
477  const CAircraftIcaoCode icaoModel(this->getModel().getAircraftIcaoCode());
478  if (!icaoModel.hasDesignator()) { return QStringLiteral("[x] no sim. ICAO"); }
479 
480  if (icaoModel.isDbEqual(icaoNw) || icaoModel == icaoNw) { return u"[==] " % icaoModel.getDesignatorDbKey(); }
481  if (icaoModel.getDesignator() == icaoNw.getDesignator()) { return u"[=] " % icaoModel.getDesignator(); }
482  return QStringLiteral("%1 -> %2").arg(icaoNw.getDesignator(), icaoModel.getDesignator());
483  }
484 
486  {
487  static const QString diff("%1 -> %2");
488 
489  if (this->getModel().getLivery().isColorLivery() || this->getNetworkModel().getLivery().isColorLivery())
490  {
491  if (this->getModel().getLivery().isColorLivery() && this->getNetworkModel().getLivery().isColorLivery())
492  {
493  return ("col/col");
494  }
495 
496  if (this->getModel().getLivery().isColorLivery())
497  {
498  return diff.arg("col", this->getNetworkModel().getAirlineIcaoCode().getDesignator());
499  }
500  return diff.arg(this->getNetworkModel().getAirlineIcaoCode().getDesignator(), "col");
501  }
502 
503  const CAirlineIcaoCode icao(this->getModel().getAirlineIcaoCode());
504  const CAirlineIcaoCode icaoNw(this->getNetworkModel().getAirlineIcaoCode());
505  if (icao.isDbEqual(icaoNw) || icao == icaoNw) { return u"[==] " % icao.getDesignatorDbKey(); }
506  if (icao.getDesignator() == icaoNw.getDesignator()) { return u"[=] " % icao.getDesignatorDbKey(); }
507  return diff.arg(icaoNw.getDesignator(), icao.getDesignator());
508  }
509 
511  {
512  Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
513 
514  const CLivery livery(this->getModel().getLivery());
515  const CLivery liveryNw(this->getNetworkModel().getLivery());
516  if (livery.isDbEqual(liveryNw) || livery == liveryNw)
517  {
518  return QStringLiteral("[==] ") + livery.getCombinedCodePlusInfo();
519  }
520  if (livery.getCombinedCode() == liveryNw.getCombinedCode())
521  {
522  return QStringLiteral("[=] ") + livery.getCombinedCodePlusInfo();
523  }
524  if (livery.isAirlineLivery() && liveryNw.isAirlineLivery())
525  {
527  }
528 
529  static const QString diff("%1 -> %2");
530  return diff.arg(liveryNw.getCombinedCodePlusInfo(), livery.getCombinedCodePlusInfo());
531  }
532 
534  {
535  Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
536 
537  // sync the callsigns
538  m_models[CurrentModel] = model;
539  this->setCallsign(this->hasValidCallsign() ? this->getCallsign() : model.getCallsign());
540  this->setIcaoCodes(model.getAircraftIcaoCode(), model.getAirlineIcaoCode());
541  }
542 
544  {
545  Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
546  m_models[NetworkModel] = model;
547  }
548 
550  {
551  Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
552  const CAircraftModel nwModel = m_models[NetworkModel];
553  m_models[CurrentModel] = nwModel;
554  return true;
555  }
556 
558  {
559  if (cg.isNull()) { return false; }
560  // ???? set to both models, or only the matched model ????
561  const int c = m_models.setCG(cg);
562  return c > 0;
563  }
564 
565  void CSimulatedAircraft::setModelString(const QString &modelString)
566  {
567  Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
568  m_models[CurrentModel].setModelString(modelString);
569  }
570 
572  {
573  Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
574  m_callsign = callsign;
575  m_models[CurrentModel].setCallsign(callsign);
576  m_models[NetworkModel].setCallsign(callsign);
577  m_pilot.setCallsign(callsign);
578  }
579 
581  {
582  return m_com1system.isActiveFrequencySameFrequency(comFrequency) ||
583  m_com2system.isActiveFrequencySameFrequency(comFrequency);
584  }
585 
587  {
588  return (m_transponder.setTransponderMode(mode));
589  }
590 
591  QString CSimulatedAircraft::convertToQString(bool i18n) const
592  {
593  const QString s = m_callsign.toQString(i18n) % u' ' % m_pilot.toQString(i18n) % u' ' %
594  m_situation.toQString(i18n) % u' ' % m_com1system.toQString(i18n) % u' ' %
595  m_com2system.toQString(i18n) % u' ' % m_transponder.toQString(i18n) % u" enabled: " %
596  swift::misc::boolToYesNo(this->isEnabled()) % u" rendered: " %
597  swift::misc::boolToYesNo(this->isRendered()) % u' ' % this->getModel().toQString(i18n);
598  return s;
599  }
600 } // 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
bool isEmpty() const
Synonym for empty.
Definition: sequence.h:285
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.
const QString & getDesignator() const
Get ICAO designator, e.g. "B737".
QString getDesignatorDbKey() const
Designator and DB key.
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.
Definition: aircraftparts.h:26
CAircraftLights getLights() const
Get aircraft lights.
Definition: aircraftparts.h:72
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
void setLights(const CAircraftLights &lights)
Set aircraft lights.
Definition: aircraftparts.h:81
int comparePropertyByIndex(CPropertyIndexRef index, const CAircraftParts &compareValue) const
Compare for index.
void setAllLightsOn()
Set all lights on.
void setAllLightsOff()
Set all lights off.
int getEnginesCount() const
Number of engines.
Value object encapsulating information of an aircraft's situation.
void setCallsign(const CCallsign &callsign)
Corresponding callsign.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
const CAircraftVelocity & getVelocity() const
Get 6DOF velocity.
int comparePropertyByIndex(CPropertyIndexRef index, const CAircraftSituation &compareValue) const
Compare for index.
void setVelocity(const CAircraftVelocity &velocity)
Set 6DOF velocity.
bool hasInboundGroundDetails() const
Has inbound ground details.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
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
int comparePropertyByIndex(CPropertyIndexRef index, const CCallsign &compareValue) const
Compare for index.
Definition: callsign.cpp:341
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
Definition: callsign.cpp:310
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
Definition: callsign.cpp:324
bool isEmpty() const
Is empty?
Definition: callsign.h:63
COM system (aka "radio")
Definition: comsystem.h:37
bool isActiveFrequencySameFrequency(const physical_quantities::CFrequency &comFrequency) const
Is active frequency the same frequency.
Definition: comsystem.cpp:53
void setFrequencyActive(const physical_quantities::CFrequency &frequency)
Set active frequency.
Definition: comsystem.cpp:37
Value object encapsulating information about an airpot.
Definition: livery.h:29
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
Definition: livery.cpp:336
const QString & getCombinedCode() const
Combined code.
Definition: livery.h:71
bool isAirlineLivery() const
Livery representing airline.
Definition: livery.cpp:167
bool hasCombinedCode() const
Livery combined code available?
Definition: livery.cpp:161
int comparePropertyByIndex(CPropertyIndexRef index, const CLivery &compareValue) const
Compare for index.
Definition: livery.cpp:381
QString getCombinedCodePlusInfo() const
Combined code plus info.
Definition: livery.cpp:60
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
Definition: modulator.cpp:112
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
Definition: modulator.cpp:129
int comparePropertyByIndex(swift::misc::CPropertyIndexRef index, const AVIO &compareValue) const
Compare by property index.
Definition: modulator.cpp:150
void setTransponderCode(int transponderCode)
Set transponder code.
Definition: transponder.h:116
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
int getTransponderCode() const
Transponder code.
Definition: transponder.h:107
bool setTransponderMode(TransponderMode mode)
Set transponder mode.
Definition: transponder.cpp:97
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
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:160
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
Definition: mixinindex.h:167
QString toQString(bool i18n=false) const
Cast as QString.
Definition: mixinstring.h:76
Value object encapsulating information of a user.
Definition: user.h:28
int comparePropertyByIndex(CPropertyIndexRef index, const CUser &compareValue) const
Compare for index.
Definition: user.cpp:281
bool isNull() const
Null?
Definition: user.h:74
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
Definition: user.cpp:241
bool setCallsign(const aviation::CCallsign &callsign)
Set associated callsign.
Definition: user.cpp:62
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
Definition: user.cpp:259
Physical unit length (length)
Definition: length.h:18
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
int comparePropertyByIndex(CPropertyIndexRef index, const PQ &pq) const
Compare for index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
Aircraft model (used by another pilot, my models on disk)
Definition: aircraftmodel.h:71
const aviation::CCallsign & getCallsign() const
Corresponding callsign if applicable.
const aviation::CAirlineIcaoCode & getAirlineIcaoCode() const
Airline ICAO code.
const aviation::CLivery & getLivery() const
Get livery.
const QString & getAircraftIcaoCodeDesignator() const
Aircraft ICAO code designator.
bool hasAircraftAndAirlineDesignator() const
Designators.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
const aviation::CAircraftIcaoCode & getAircraftIcaoCode() const
Aircraft ICAO code.
const QString & getAirlineIcaoCodeDesignator() const
Airline ICAO code designator.
bool isMilitary() const
Military model?
int setCG(const physical_quantities::CLength &cg)
Set center of gravity.
Comprehensive information of an aircraft.
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.
void initTransponder()
Meaningful default settings for Transponder.
bool isMilitary() const
Is military aircraft.
const aviation::CAircraftSituation & getSituation() const
Get situation.
void setCockpit(const CSimulatedAircraft &aircraft)
Set COM unit (all values + transponder and SELCAL)
bool isPartsSynchronized() const
Have parts been synchronized with a remote client?
const aviation::CComSystem & getCom2System() const
Get COM2 system.
void initComSystems()
Meaningful default settings for COM Systems.
QString convertToQString(bool i18n=false) const
Cast as QString.
bool isSupportingGndFlag() const
Is supporting gnd.flag?
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
const aviation::CTransponder & getTransponder() const
Get transponder.
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.
void setAllLightsOn()
Set aircraft lights on.
aviation::CAircraftLights getLights() const
Get aircraft parts.
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?
const network::CUser & getPilot() const
Get user.
const simulation::CAircraftModel & getNetworkModel() const
Get network model.
const aviation::CCallsign & getCallsign() const
Get callsign.
const aviation::CLivery & getLivery() const
Get livery.
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 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?
bool hasValidCallsign() const
Valid callsign?
const simulation::CAircraftModel & getModel() const
Get model (model used for mapping)
void setSupportingGndFlag(bool supports)
Indicate gnd.flag is supported.
aviation::CComSystem getComSystem(aviation::CComSystem::ComUnit unit) const
Get COM unit.
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.
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.
bool setIcaoCodes(const aviation::CAircraftIcaoCode &aircraftIcaoCode, const aviation::CAirlineIcaoCode &airlineIcaoCode)
Set ICAO info.
const aviation::CComSystem & getCom1System() const
Get COM1 system.
const aviation::CAirlineIcaoCode & getAirlineIcaoCode() const
Airline ICAO code if any.
bool resetToNetworkModel()
Reset to the newtork model.
int getEnginesCount() const
Number of engines.
const aviation::CAircraftParts & getParts() const
Get aircraft parts.
void setPilot(const network::CUser &user)
Set pilot.
bool setFastPositionUpdates(bool useFastPositions)
Support fast position updates.
Free functions in swift::misc.
SWIFT_MISC_EXPORT const QString & boolToYesNo(bool v)
Bool to yes/no.
#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