13 #include <QElapsedTimer>
17 #include <QRegularExpression>
18 #include <QRegularExpressionMatch>
20 #include <QStringBuilder>
21 #include <QStringList>
22 #include <QTextStream>
46 using namespace swift::misc::aviation;
47 using namespace swift::misc::geo;
48 using namespace swift::misc::math;
49 using namespace swift::misc::network;
50 using namespace swift::misc::physical_quantities;
51 using namespace swift::misc::simulation;
55 namespace swift::sample
57 int CSamplesPerformance::samplesMisc(QTextStream &out)
61 CSamplesPerformance::copy10kStations(1);
67 out <<
"created (copy) " << atcs1.
size() <<
" ATC stations in " << ms <<
"ms" << Qt::endl;
72 out <<
"created (copy) " << atcs2.
size() <<
" ATC stations in " << ms <<
"ms" << Qt::endl;
78 out <<
"created (propertyIndex) " << atcs3.
size() <<
" ATC stations in " << ms <<
"ms" << Qt::endl;
83 out <<
"created (propertyIndex) " << atcs4.
size() <<
" ATC stations in " << ms <<
"ms" << Qt::endl;
89 out <<
"Sorted by callsign " << atcs1.
size() <<
" ATC stations in " << ms <<
"ms" << Qt::endl;
94 out <<
"Sorted by callsign " << atcs2.
size() <<
" ATC stations in " << ms <<
"ms" << Qt::endl;
98 CSamplesPerformance::accessStationsData(atcs1,
false);
100 out <<
"Read (getters) " << atcs1.
size() <<
" ATC stations in " << ms <<
"ms" << Qt::endl;
103 CSamplesPerformance::accessStationsData(atcs2,
false);
104 ms = timer.elapsed();
105 out <<
"Read (getters) " << atcs2.
size() <<
" ATC stations in " << ms <<
"ms" << Qt::endl;
108 CSamplesPerformance::accessStationsData(atcs1,
true);
109 ms = timer.elapsed();
110 out <<
"Read (propertyIndex) " << atcs1.
size() <<
" ATC stations in " << ms <<
"ms" << Qt::endl;
113 CSamplesPerformance::accessStationsData(atcs2,
true);
114 ms = timer.elapsed();
115 out <<
"Read (propertyIndex) " << atcs2.
size() <<
" ATC stations in " << ms <<
"ms" << Qt::endl;
120 CSamplesPerformance::calculateDistance(number);
121 ms = timer.elapsed();
122 out <<
"Calculated distances " << number <<
" in " << ms <<
"ms" << Qt::endl;
126 CSamplesPerformance::calculateDistance(number);
127 ms = timer.elapsed();
128 out <<
"Calculated distances " << number <<
"in " << ms <<
"ms" << Qt::endl;
133 CSamplesPerformance::parseWgs(number);
134 ms = timer.elapsed();
135 out <<
"Parse WGS coordinates " << number <<
" in " << ms <<
"ms" << Qt::endl;
140 CSamplesPerformance::copy10kStations(number);
141 ms = timer.elapsed();
142 out <<
"Copied 10k stations " << number <<
" times in " << ms <<
"ms" << Qt::endl;
146 CSamplesPerformance::copy10kStations(number);
147 ms = timer.elapsed();
148 out <<
"Copied 10k stations " << number <<
" times in " << ms <<
"ms" << Qt::endl;
151 auto generator = []() {
return QString::number(CMathUtils::randomGenerator().generate(), 16); };
152 QStringList strList1, strList2, strList3, strList4;
153 std::generate_n(std::back_inserter(strList1), 100000, generator);
154 std::generate_n(std::back_inserter(strList2), 100000, generator);
155 std::generate_n(std::back_inserter(strList3), 100000, generator);
156 std::generate_n(std::back_inserter(strList4), 100000, generator);
157 QRegularExpression newRegex(
"^.*aaa.*$", QRegularExpression::CaseInsensitiveOption);
158 QRegExp fullRegex(
".*aaa.*", Qt::CaseInsensitive);
159 QRegExp wildcardRegex(
"*aaa*", Qt::CaseInsensitive, QRegExp::Wildcard);
160 QString containsStr(
"aaa");
163 for (
const auto &str : std::as_const(strList1))
165 if (newRegex.match(str).hasMatch()) number++;
167 ms = timer.elapsed();
168 out <<
"new regex matched " << number <<
" of" << strList1.size() <<
" strings in " << ms <<
"ms" << Qt::endl;
171 for (
const auto &str : std::as_const(strList2))
173 if (fullRegex.exactMatch(str)) number++;
175 ms = timer.elapsed();
176 out <<
"full regex matched " << number <<
" of" << strList2.size() <<
" strings in " << ms <<
"ms" << Qt::endl;
179 for (
const auto &str : std::as_const(strList3))
181 if (wildcardRegex.exactMatch(str)) number++;
183 ms = timer.elapsed();
184 out <<
"wildcard matched " << number <<
" of " << strList3.size() <<
" strings in " << ms <<
"ms" << Qt::endl;
187 for (
const auto &str : std::as_const(strList4))
189 if (str.contains(containsStr)) number++;
191 ms = timer.elapsed();
192 out <<
"contains matched " << number <<
" of " << strList4.size() <<
" strings in " << ms <<
"ms" << Qt::endl;
194 out <<
"-----------------------------------------------" << Qt::endl;
198 int CSamplesPerformance::interpolatorScenario(QTextStream &out,
int numberOfCallsigns,
int numberOfTimes)
200 const qint64 baseTimeEpoch = QDateTime::currentMSecsSinceEpoch();
205 qint64 halfTime = baseTimeEpoch + DeltaTime * numberOfTimes / 2;
209 for (
int cs = 0; cs < numberOfCallsigns; cs++)
211 CCallsign callsign(
"CS" + QString::number(cs));
212 situationsBefore = situations.
findBefore(halfTime).findByCallsign(callsign);
213 situationsAfter = situations.
findAfter(halfTime - 1).findByCallsign(callsign);
215 out <<
"Reads by time, callsigns: " << timer.elapsed() <<
"ms" << Qt::endl;
218 situationsBefore = situations.
findBefore(halfTime);
219 situationsAfter = situations.
findAfter(halfTime - 1);
220 for (
int cs = 0; cs < numberOfCallsigns; cs++)
222 CCallsign callsign(
"CS" + QString::number(cs));
225 Q_UNUSED(csSituationsBefore);
226 Q_UNUSED(csSituationsAfter);
228 out <<
"Split by time upfront, then callsigns: " << timer.elapsed() <<
"ms" << Qt::endl;
229 int b = situationsBefore.
size();
230 int a = situationsAfter.
size();
231 Q_ASSERT(a + b == numberOfTimes * numberOfCallsigns);
237 out <<
"Split by " << csSituations.size() <<
" callsigns, " << timer.elapsed() <<
"ms" << Qt::endl;
244 a = csSituationsBefore.
size();
245 b = csSituationsAfter.
size();
246 Q_ASSERT(a + b == numberOfTimes);
247 Q_UNUSED(csSituationsBefore);
248 Q_UNUSED(csSituationsAfter);
250 out <<
"Split by callsign, by time: " << timer.elapsed() <<
"ms" << Qt::endl;
256 int CSamplesPerformance::samplesJson(QTextStream &out)
259 auto situations = createSituations(0, 10000, 10);
260 auto models = createModels(10000, 100);
263 QJsonObject json = situations.toJson();
264 out <<
"Convert 100,000 aircraft situations to JSON: " << timer.elapsed() <<
"ms" << Qt::endl;
267 situations.convertFromJson(json);
268 out <<
"Convert 100,000 aircraft situations from JSON: " << timer.elapsed() <<
"ms" << Qt::endl
272 json = models.toJson();
273 out <<
"Convert 10,000 aircraft models to JSON (naive): " << timer.elapsed() <<
"ms" << Qt::endl;
276 models.convertFromJson(json);
277 out <<
"Convert 10,000 aircraft models from JSON (naive): " << timer.elapsed() <<
"ms" << Qt::endl
281 json = models.toMemoizedJson();
282 out <<
"Convert 10,000 aircraft models to JSON (memoize): " << timer.elapsed() <<
"ms" << Qt::endl;
285 models.convertFromMemoizedJson(json);
286 out <<
"Convert 10,000 aircraft models from JSON (memoize): " << timer.elapsed() <<
"ms" << Qt::endl
292 int CSamplesPerformance::samplesJsonModelAndLivery(QTextStream &out)
295 const QString modelFileName = QDir(dir).filePath(
"models.json");
296 const QString liveriesFileName = QDir(dir).filePath(
"liveries.json");
298 QFile modelFile(modelFileName);
299 Q_ASSERT_X(modelFile.exists(), Q_FUNC_INFO,
"Model file does not exist");
300 QFile liveryFile(liveriesFileName);
301 Q_ASSERT_X(liveryFile.exists(), Q_FUNC_INFO,
"Liveries file does not exist");
303 out <<
"Loaded DB JSON model file " << modelFile.fileName() << Qt::endl;
305 Q_ASSERT_X(!modelData.isEmpty(), Q_FUNC_INFO,
"Model file empty");
307 out <<
"Loaded DB JSON livery file " << liveryFile.fileName() << Qt::endl;
309 Q_ASSERT_X(!liveryData.isEmpty(), Q_FUNC_INFO,
"Livery file empty");
315 CDatabaseReader::stringToDatastoreResponse(liveryData, response);
318 int ms = timer.elapsed();
319 out <<
"Read via DB JSON format: " << dbLiveries.
size() <<
" liveries in " << ms <<
"ms" << Qt::endl;
325 ms = timer.elapsed();
326 out <<
"Read via DB JSON format (new): " << dbLiveries2.
size() <<
" liveries in " << ms <<
"ms" << Qt::endl;
331 ms = timer.elapsed();
332 out <<
"Read via DB JSON format (new, passing airlines): " << dbLiveries3.
size() <<
" liveries in " << ms
335 CDatabaseReader::stringToDatastoreResponse(modelData, response);
338 ms = timer.elapsed();
339 out <<
"Read via DB JSON format: " << dbModels.
size() <<
" models in " << ms <<
"ms" << Qt::endl;
342 const CAircraftModelList dbModels2 = CAircraftModelList::fromDatabaseJsonCaching(response);
343 ms = timer.elapsed();
344 out <<
"Read via DB JSON format (new): " << dbModels2.
size() <<
" models in " << ms <<
"ms" << Qt::endl;
347 const QJsonObject swiftJsonObject = dbModels.
toJson();
348 out <<
"Converted to swift JSON" << Qt::endl;
353 ms = timer.elapsed();
354 out <<
"Read via swift JSON format: " << swiftModels.
size() <<
" models in " << ms <<
"ms" << Qt::endl;
356 Q_ASSERT_X(swiftModels.
size() == dbModels.
size(), Q_FUNC_INFO,
"Mismatching container size");
360 int CSamplesPerformance::samplesStringUtilsVsRegEx(QTextStream &out)
363 static const QString chars =
364 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~_-=+!\"@#$%^&*()[]{} \t;:\\/?,.<>";
366 std::generate_n(std::back_inserter(strings), 100000, [] {
368 std::generate_n(std::back_inserter(s), 10,
369 [] {
return chars[CMathUtils::randomInteger(0, chars.size() - 1)]; });
372 QString bigString = strings.join(
"\n");
374 QRegularExpression upperRegex(
"[A-Z]");
375 upperRegex.optimize();
378 for (
const QString &s : std::as_const(strings))
380 auto c =
containsChar(s, [](QChar c) {
return c.isUpper(); });
383 out <<
"Check 100,000 strings for containing uppercase letter: (utility) " << timer.elapsed() <<
"ms"
387 for (
const QString &s : std::as_const(strings))
389 auto c = s.contains(upperRegex);
392 out <<
"Check 100,000 strings for containing uppercase letter: (regex) " << timer.elapsed() <<
"ms"
397 for (
const QString &s : std::as_const(strings))
399 auto i =
indexOfChar(s, [](QChar c) {
return c.isUpper(); });
402 out <<
"Check 100,000 strings for index of first uppercase letter: (utility) " << timer.elapsed() <<
"ms"
406 for (
const QString &s : std::as_const(strings))
408 auto i = s.indexOf(upperRegex);
411 out <<
"Check 100,000 strings for index of first uppercase letter: (regex) " << timer.elapsed() <<
"ms"
417 for (QString &s : strings)
419 removeChars(s, [](QChar c) {
return c.isUpper(); });
421 out <<
"Remove from 100,000 strings all uppercase letters: (utility) " << timer.elapsed() <<
"ms"
426 for (QString &s : strings) { s.remove(upperRegex); }
427 out <<
"Remove from 100,000 strings all uppercase letters: (regex) " << timer.elapsed() <<
"ms"
436 out <<
"Split 100,000 line string into list of lines: (QStringList) " << timer.elapsed() <<
"ms"
444 out <<
"Split 100,000 line string into list of lines: (QList<QStringRef>) " << timer.elapsed() <<
"ms"
450 int CSamplesPerformance::samplesStringConcat(QTextStream &out)
452 const int loop = 250000;
454 const QString x1 =
"11-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
455 const QString x2 =
"22-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
456 const QString x3 =
"33-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
457 const QString x4 =
"44-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
458 const QString x5 =
"55-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
459 const QString x6 =
"66-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
460 const QString x7 =
"77-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
461 const QString x8 =
"88-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
462 const QString x9 =
"99-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
466 for (
int i = 0; i < loop; i++) { x +=
"12-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; }
467 out <<
"+= String " << time.elapsed() <<
"ms" << Qt::endl;
471 for (
int i = 0; i < loop; i++)
473 x += QLatin1String(
"12-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
475 out <<
"+= QLatin1String " << time.elapsed() <<
"ms" << Qt::endl;
479 for (
int i = 0; i < loop; i++)
481 x += QStringLiteral(
"12-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
483 out <<
"+= QStringLiteral " << time.elapsed() <<
"ms" << Qt::endl;
487 for (
int i = 0; i < loop; i++) { x = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9; }
488 out <<
"+ String multiple " << time.elapsed() <<
"ms" << Qt::endl;
492 for (
int i = 0; i < loop; i++) { x = x1 % x2 % x3 % x4 % x5 % x6 % x7 % x8 % x9; }
493 out <<
"% String multiple " << time.elapsed() <<
"ms" << Qt::endl;
497 for (
int i = 0; i < loop; i++)
499 x = x.append(x1).append(x2).append(x3).append(x4).append(x5).append(x6).append(x7).append(x8).append(x9);
501 out <<
"append String multiple " << time.elapsed() <<
"ms" << Qt::endl;
504 static const QString xArgString(
"%1 %2 %3 %4 %5 %6 %7 %8 %9");
506 for (
int i = 0; i < loop; i++) { x = xArgString.arg(x1, x2, x3, x4, x5, x6, x7, x8, x9); }
507 out <<
"arg String multiple " << time.elapsed() <<
"ms" << Qt::endl;
511 for (
int i = 0; i < loop; i++)
513 x = QStringLiteral(
"%1 %2 %3 %4 %5 %6 %7 %8 %9").arg(x1, x2, x3, x4, x5, x6, x7, x8, x9);
515 out <<
"arg QStringLiteral multiple " << time.elapsed() <<
"ms" << Qt::endl;
521 int CSamplesPerformance::samplesStringLiteralVsConstQString(QTextStream &out)
523 const int loop = 1e7;
527 for (
int i = 0; i < loop; i++) { x = fooString(); }
528 out <<
"by constQString " << time.elapsed() <<
"ms" << Qt::endl;
532 for (
int i = 0; i < loop; i++) { x = fooStringLiteral(); }
533 out <<
"by QStringLiteral " << time.elapsed() <<
"ms" << Qt::endl;
537 for (
int i = 0; i < loop; i++)
539 x = QString(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. "
540 "Sed cursus ante dapibus diam. Sed nisi.");
542 out <<
"by QString(\"...\") " << time.elapsed() <<
"ms" << Qt::endl;
546 for (
int i = 0; i < loop; i++)
548 x = QStringLiteral(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent "
549 "libero. Sed cursus ante dapibus diam. Sed nisi.");
551 out <<
"by QStringLiteral(\"...\") " << time.elapsed() <<
"ms" << Qt::endl;
555 for (
int i = 0; i < loop; i++)
557 QStringList foo = generateList();
558 Q_UNUSED(foo.size());
560 out <<
"generated list " << time.elapsed() <<
"ms" << Qt::endl;
563 for (
int i = 0; i < loop; i++)
565 QStringList foo = replacedList();
566 Q_UNUSED(foo.size());
568 out <<
"replaced list " << time.elapsed() <<
"ms" << Qt::endl;
573 int CSamplesPerformance::sampleQMapVsQHashByCallsign(QTextStream &out)
575 const CCallsignSet cs10 = CSamplesPerformance::callsigns(10);
576 const CCallsignSet cs25 = CSamplesPerformance::callsigns(25);
577 const CCallsignSet cs50 = CSamplesPerformance::callsigns(50);
587 Q_ASSERT(m10.size() == 10 && h10.size() == 10);
588 Q_ASSERT(m25.size() == 25 && h25.size() == 25);
589 Q_ASSERT(m50.size() == 50 && h50.size() == 50);
592 QList<CCallsign> cs_10_100_rnd;
593 QList<CCallsign> cs_25_100_rnd;
594 QList<CCallsign> cs_50_100_rnd;
596 for (
int i = 0; i < 20; ++i)
603 Q_ASSERT(cs_10_100_rnd.size() == 100);
604 Q_ASSERT(cs_25_100_rnd.size() == 100);
605 Q_ASSERT(cs_50_100_rnd.size() == 100);
609 for (
int i = 1; i < 10000; ++i)
611 for (
const CCallsign &cs : cs_10_100_rnd)
614 Q_ASSERT_X(s.
getCallsign() == cs, Q_FUNC_INFO,
"Wromg callsign");
617 out <<
"map 100 out of 10: " << time.elapsed() <<
"ms" << Qt::endl;
620 for (
int i = 1; i < 10000; ++i)
622 for (
const CCallsign &cs : cs_10_100_rnd)
625 Q_ASSERT_X(s.
getCallsign() == cs, Q_FUNC_INFO,
"Wromg callsign");
628 out <<
"hash 100 out of 10: " << time.elapsed() <<
"ms" << Qt::endl;
631 for (
int i = 1; i < 10000; ++i)
633 for (
const CCallsign &cs : cs_25_100_rnd)
636 Q_ASSERT_X(s.
getCallsign() == cs, Q_FUNC_INFO,
"Wromg callsign");
639 out <<
"map 100 out of 25: " << time.elapsed() <<
"ms" << Qt::endl;
642 for (
int i = 1; i < 10000; ++i)
644 for (
const CCallsign &cs : cs_25_100_rnd)
647 Q_ASSERT_X(s.
getCallsign() == cs, Q_FUNC_INFO,
"Wromg callsign");
650 out <<
"hash 100 out of 25: " << time.elapsed() <<
"ms" << Qt::endl;
653 for (
int i = 1; i < 10000; ++i)
655 for (
const CCallsign &cs : cs_50_100_rnd)
658 Q_ASSERT_X(s.
getCallsign() == cs, Q_FUNC_INFO,
"Wromg callsign");
661 out <<
"map 100 out of 50: " << time.elapsed() <<
"ms" << Qt::endl;
664 for (
int i = 1; i < 10000; ++i)
666 for (
const CCallsign &cs : cs_50_100_rnd)
669 Q_ASSERT_X(s.
getCallsign() == cs, Q_FUNC_INFO,
"Wromg callsign");
672 out <<
"hash 100 out of 50: " << time.elapsed() <<
"ms" << Qt::endl;
681 for (
int cs = 0; cs < numberOfCallsigns; cs++)
683 CCallsign callsign(
"CS" + QString::number(cs));
685 for (
int t = 0; t < numberOfTimes; t++)
688 s.setMSecsSinceEpoch(baseTimeEpoch + DeltaTime * t);
695 CAircraftModelList CSamplesPerformance::createModels(
int numberOfModels,
int numberOfMemoParts)
700 for (
int i = 0; i < numberOfMemoParts; ++i)
705 "A" + QString::number(i),
707 "Foo",
"red",
"blue",
false));
712 for (
int i = 0; i < numberOfModels; ++i)
714 const auto &aircraftIcao = aircraftIcaos[CMathUtils::randomInteger(0, numberOfMemoParts - 1)];
715 const auto &livery = liveries[CMathUtils::randomInteger(0, numberOfMemoParts - 1)];
716 const auto &distributor = distributors[CMathUtils::randomInteger(0, numberOfMemoParts - 1)];
718 QString::number(i), QString::number(i), aircraftIcao, livery));
724 void CSamplesPerformance::calculateDistance(
int n)
726 if (n < 1) {
return; }
728 const QList<CCoordinateGeodetic> pos(
733 const int s = pos.size();
734 for (
int i = 0; i < n; i++)
741 void CSamplesPerformance::copy10kStations(
int times)
744 for (
int i = 0; i < times; i++)
746 stations = stations10k();
751 void CSamplesPerformance::parseWgs(
int times)
753 static QStringList wgsLatLng({
"12° 11′ 10″ N",
"11° 22′ 33″ W",
"48° 21′ 13″ N",
"11° 47′ 09″ E",
754 " 8° 21′ 13″ N",
"11° 47′ 09″ W",
"18° 21′ 13″ S",
"11° 47′ 09″ E",
755 "09° 12′ 13″ S",
"11° 47′ 09″ W" });
758 const CAltitude a(333, CLengthUnit::m());
759 for (
int i = 0; i < times; i++)
761 int idx = (i % 5) * 2;
762 c = CCoordinateGeodetic::fromWgs84(wgsLatLng.at(idx), wgsLatLng.at(idx + 1), a);
766 const QString &CSamplesPerformance::fooString()
768 static const QString s(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent "
769 "libero. Sed cursus ante dapibus diam. Sed nisi.");
773 QString CSamplesPerformance::fooStringLiteral()
775 return QStringLiteral(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent "
776 "libero. Sed cursus ante dapibus diam. Sed nisi.");
779 QStringList CSamplesPerformance::generateList() {
return QStringList({
"1",
"2",
"3",
"4" }); }
781 QStringList CSamplesPerformance::replacedList()
783 static const QStringList l({
"1",
"2",
"3",
"4" });
785 lc[1] = QStringLiteral(
"6");
786 lc[3] = QStringLiteral(
"7");
793 static const QString cs(
"FOO%1");
804 situations.insert(cs, s);
815 situations.insert(cs, s);
822 static const CAtcStationList s = CTesting::createAtcStations(10000,
false);
826 void CSamplesPerformance::accessStationsData(
const CAtcStationList &stations,
bool byPropertyIndex)
830 const QString s = CSamplesPerformance::accessStationData(station, byPropertyIndex);
835 QString CSamplesPerformance::accessStationData(
const CAtcStation &station,
bool byPropertyIndex)
846 CPropertyIndex { CAtcStation::IndexPosition, CCoordinateGeodetic::IndexLatitudeAsString })
850 CPropertyIndex { CAtcStation::IndexPosition, CCoordinateGeodetic::IndexLongitudeAsString })
853 .propertyByIndex(
CPropertyIndex { CAtcStation::IndexRelativeDistance,
854 CLength::IndexValueRounded2DigitsWithUnit })
858 .toString(
"yyyy-MM-dd hh:mm"));
iterator insert(const_iterator hint, const T &value)
For compatibility with std::inserter.
QJsonObject toJson() const
Cast to JSON object.
void convertFromJson(const QJsonObject &json)
Assign from JSON object.
static QString readFileToString(const QString &fileNameAndPath)
Read file into string.
Derived randomElements(int n) const
Copy n elements from the container at random.
size_type size() const
Returns number of elements in the sequence.
void sortBy(K1 key1, Keys... keys)
In-place sort by some particular key(s).
void pop_back()
Removes an element at the end of the sequence.
void push_back(const T &value)
Appends an element at the end of the sequence.
reference back()
Access the last element.
static const QString & staticDbFilesDirectory()
Where static DB files are located.
CONTAINER findAfter(const QDateTime &dateTime) const
List of objects after dateTime (newer)
CONTAINER findBefore(const QDateTime &dateTime) const
List of objects before dateTime (older)
Value object for ICAO classification.
Value object encapsulating a list of ICAO codes.
Value object encapsulating information of an aircraft's situation.
const CCallsign & getCallsign() const
Corresponding callsign.
List of aircraft situations.
Value object for ICAO classification.
Value object encapsulating a list of ICAO codes.
Altitude as used in aviation, can be AGL or MSL altitude.
Value object encapsulating information about an ATC station.
const CCallsign & getCallsign() const
Get callsign.
const geo::CCoordinateGeodetic & getPosition() const
Get the position of the center of the controller's area of visibility.
QString getCallsignAsString() const
Get callsign as string.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
const swift::misc::network::CUser & getController() const
Get controller.
const QDateTime & getLogoffTimeUtc() const
Return the expected logoff time (UTC). This data comes from the controller through its ATIS line.
Value object for a list of ATC stations.
Value object encapsulating information of a callsign.
Value object for a set of callsigns.
Value object encapsulating information about an airpot.
Value object for a list of airports.
CAirlineIcaoCodeList getAirlines() const
All aircraft codes.
static CLiveryList fromDatabaseJsonCaching(const QJsonArray &array, const CAirlineIcaoCodeList &relatedAirlines={})
Caching version from DB data.
CONTAINER findByCallsign(const CCallsign &callsign) const
Find 0..n stations by callsign.
QHash< CCallsign, CONTAINER > splitPerCallsign() const
Split into 0..n containers as per callsign.
static CLiveryList fromDatabaseJson(const QJsonArray &array)
From DB JSON with default prefixes.
QString longitudeAsString() const
Longitude as string.
QString latitudeAsString() const
Latitude as string.
const physical_quantities::CLength & getRelativeDistance() const
Get the distance.
physical_quantities::CLength calculcateAndUpdateRelativeDistance(const geo::ICoordinateGeodetic &position)
Calculcate distance, set it, and return distance.
QString toQString(bool i18n=false) const
Cast as QString.
const QString & getRealName() const
Get full name.
Aircraft model (used by another pilot, my models on disk)
void setDistributor(const CDistributor &distributor)
Set distributor.
Value object encapsulating a list of aircraft models.
Value object encapsulating information of software distributor.
Value object encapsulating a list of distributors.
Classes interacting with the swift database (aka "datastore").
Generate data for testing purposes.
Free functions in swift::misc.
QString removeChars(const QString &s, F predicate)
Return a string with characters removed that match the given predicate.
int indexOfChar(const QString &s, F predicate)
Index of first character in the string matching the given predicate, or -1 if not found.
SWIFT_MISC_EXPORT QStringList splitLines(const QString &s)
Split a string into multiple lines. Blank lines are skipped.
bool containsChar(const QString &s, F predicate)
True if any character in the string matches the given predicate.
SWIFT_MISC_EXPORT QList< QStringRef > splitLinesRefs(const QString &s)
Split a string into multiple lines. Blank lines are skipped.
Response from our database (depending on JSON DB backend generates)