13 #include <QElapsedTimer>
16 #include <QRegularExpression>
17 #include <QRegularExpressionMatch>
19 #include <QStringBuilder>
20 #include <QStringList>
21 #include <QTextStream>
45 using namespace swift::misc::aviation;
46 using namespace swift::misc::geo;
47 using namespace swift::misc::math;
48 using namespace swift::misc::network;
49 using namespace swift::misc::physical_quantities;
50 using namespace swift::misc::simulation;
54 namespace swift::sample
56 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;
153 QStringList strList2;
154 QStringList strList3;
155 QStringList strList4;
156 std::generate_n(std::back_inserter(strList1), 100000, generator);
157 std::generate_n(std::back_inserter(strList2), 100000, generator);
158 std::generate_n(std::back_inserter(strList3), 100000, generator);
159 std::generate_n(std::back_inserter(strList4), 100000, generator);
160 QRegularExpression newRegex(
"^.*aaa.*$", QRegularExpression::CaseInsensitiveOption);
161 QRegularExpression fullRegex(
".*aaa.*", QRegularExpression::CaseInsensitiveOption);
162 QString containsStr(
"aaa");
165 for (
const auto &str : std::as_const(strList1))
167 if (newRegex.match(str).hasMatch()) number++;
169 ms = timer.elapsed();
170 out <<
"new regex matched " << number <<
" of" << strList1.size() <<
" strings in " << ms <<
"ms" << Qt::endl;
173 for (
const auto &str : std::as_const(strList2))
175 if (fullRegex.match(str).hasMatch()) number++;
177 ms = timer.elapsed();
178 out <<
"full regex matched " << number <<
" of" << strList2.size() <<
" strings in " << ms <<
"ms" << Qt::endl;
181 for (
const auto &str : std::as_const(strList4))
183 if (str.contains(containsStr)) number++;
185 ms = timer.elapsed();
186 out <<
"contains matched " << number <<
" of " << strList4.size() <<
" strings in " << ms <<
"ms" << Qt::endl;
188 out <<
"-----------------------------------------------" << Qt::endl;
192 int CSamplesPerformance::interpolatorScenario(QTextStream &out,
int numberOfCallsigns,
int numberOfTimes)
194 const qint64 baseTimeEpoch = QDateTime::currentMSecsSinceEpoch();
199 qint64 halfTime = baseTimeEpoch + DeltaTime * numberOfTimes / 2;
203 for (
int cs = 0; cs < numberOfCallsigns; cs++)
205 CCallsign callsign(
"CS" + QString::number(cs));
206 situationsBefore = situations.
findBefore(halfTime).findByCallsign(callsign);
207 situationsAfter = situations.
findAfter(halfTime - 1).findByCallsign(callsign);
209 out <<
"Reads by time, callsigns: " << timer.elapsed() <<
"ms" << Qt::endl;
212 situationsBefore = situations.
findBefore(halfTime);
213 situationsAfter = situations.
findAfter(halfTime - 1);
214 for (
int cs = 0; cs < numberOfCallsigns; cs++)
216 CCallsign callsign(
"CS" + QString::number(cs));
219 Q_UNUSED(csSituationsBefore);
220 Q_UNUSED(csSituationsAfter);
222 out <<
"Split by time upfront, then callsigns: " << timer.elapsed() <<
"ms" << Qt::endl;
223 int b = situationsBefore.
size();
224 int a = situationsAfter.
size();
225 Q_ASSERT(a + b == numberOfTimes * numberOfCallsigns);
231 out <<
"Split by " << csSituations.size() <<
" callsigns, " << timer.elapsed() <<
"ms" << Qt::endl;
238 a = csSituationsBefore.
size();
239 b = csSituationsAfter.
size();
240 Q_ASSERT(a + b == numberOfTimes);
241 Q_UNUSED(csSituationsBefore);
242 Q_UNUSED(csSituationsAfter);
244 out <<
"Split by callsign, by time: " << timer.elapsed() <<
"ms" << Qt::endl;
250 int CSamplesPerformance::samplesJson(QTextStream &out)
253 auto situations = createSituations(0, 10000, 10);
254 auto models = createModels(10000, 100);
257 QJsonObject json = situations.toJson();
258 out <<
"Convert 100,000 aircraft situations to JSON: " << timer.elapsed() <<
"ms" << Qt::endl;
261 situations.convertFromJson(json);
262 out <<
"Convert 100,000 aircraft situations from JSON: " << timer.elapsed() <<
"ms" << Qt::endl
266 json = models.toJson();
267 out <<
"Convert 10,000 aircraft models to JSON (naive): " << timer.elapsed() <<
"ms" << Qt::endl;
270 models.convertFromJson(json);
271 out <<
"Convert 10,000 aircraft models from JSON (naive): " << timer.elapsed() <<
"ms" << Qt::endl
275 json = models.toMemoizedJson();
276 out <<
"Convert 10,000 aircraft models to JSON (memoize): " << timer.elapsed() <<
"ms" << Qt::endl;
279 models.convertFromMemoizedJson(json);
280 out <<
"Convert 10,000 aircraft models from JSON (memoize): " << timer.elapsed() <<
"ms" << Qt::endl
286 int CSamplesPerformance::samplesJsonModelAndLivery(QTextStream &out)
289 const QString modelFileName = QDir(dir).filePath(
"models.json");
290 const QString liveriesFileName = QDir(dir).filePath(
"liveries.json");
292 QFile modelFile(modelFileName);
293 Q_ASSERT_X(modelFile.exists(), Q_FUNC_INFO,
"Model file does not exist");
294 QFile liveryFile(liveriesFileName);
295 Q_ASSERT_X(liveryFile.exists(), Q_FUNC_INFO,
"Liveries file does not exist");
297 out <<
"Loaded DB JSON model file " << modelFile.fileName() << Qt::endl;
299 Q_ASSERT_X(!modelData.isEmpty(), Q_FUNC_INFO,
"Model file empty");
301 out <<
"Loaded DB JSON livery file " << liveryFile.fileName() << Qt::endl;
303 Q_ASSERT_X(!liveryData.isEmpty(), Q_FUNC_INFO,
"Livery file empty");
309 CDatabaseReader::stringToDatastoreResponse(liveryData, response);
312 qint64 ms = timer.elapsed();
313 out <<
"Read via DB JSON format: " << dbLiveries.
size() <<
" liveries in " << ms <<
"ms" << Qt::endl;
319 ms = timer.elapsed();
320 out <<
"Read via DB JSON format (new): " << dbLiveries2.
size() <<
" liveries in " << ms <<
"ms" << Qt::endl;
325 ms = timer.elapsed();
326 out <<
"Read via DB JSON format (new, passing airlines): " << dbLiveries3.
size() <<
" liveries in " << ms
329 CDatabaseReader::stringToDatastoreResponse(modelData, response);
332 ms = timer.elapsed();
333 out <<
"Read via DB JSON format: " << dbModels.
size() <<
" models in " << ms <<
"ms" << Qt::endl;
336 const CAircraftModelList dbModels2 = CAircraftModelList::fromDatabaseJsonCaching(response);
337 ms = timer.elapsed();
338 out <<
"Read via DB JSON format (new): " << dbModels2.
size() <<
" models in " << ms <<
"ms" << Qt::endl;
341 const QJsonObject swiftJsonObject = dbModels.
toJson();
342 out <<
"Converted to swift JSON" << Qt::endl;
347 ms = timer.elapsed();
348 out <<
"Read via swift JSON format: " << swiftModels.
size() <<
" models in " << ms <<
"ms" << Qt::endl;
350 Q_ASSERT_X(swiftModels.
size() == dbModels.
size(), Q_FUNC_INFO,
"Mismatching container size");
354 int CSamplesPerformance::samplesStringUtilsVsRegEx(QTextStream &out)
357 static const QString chars =
358 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~_-=+!\"@#$%^&*()[]{} \t;:\\/?,.<>";
360 std::generate_n(std::back_inserter(strings), 100000, [] {
362 std::generate_n(std::back_inserter(s), 10,
363 [] {
return chars[CMathUtils::randomInteger(0,
static_cast<int>(chars.size() - 1))]; });
366 QString bigString = strings.join(
"\n");
368 QRegularExpression upperRegex(
"[A-Z]");
369 upperRegex.optimize();
372 for (
const QString &s : std::as_const(strings))
374 auto c =
containsChar(s, [](QChar c) {
return c.isUpper(); });
377 out <<
"Check 100,000 strings for containing uppercase letter: (utility) " << timer.elapsed() <<
"ms"
381 for (
const QString &s : std::as_const(strings))
383 auto c = s.contains(upperRegex);
386 out <<
"Check 100,000 strings for containing uppercase letter: (regex) " << timer.elapsed() <<
"ms"
391 for (
const QString &s : std::as_const(strings))
393 auto i =
indexOfChar(s, [](QChar c) {
return c.isUpper(); });
396 out <<
"Check 100,000 strings for index of first uppercase letter: (utility) " << timer.elapsed() <<
"ms"
400 for (
const QString &s : std::as_const(strings))
402 auto i = s.indexOf(upperRegex);
405 out <<
"Check 100,000 strings for index of first uppercase letter: (regex) " << timer.elapsed() <<
"ms"
411 for (QString &s : strings)
413 removeChars(s, [](QChar c) {
return c.isUpper(); });
415 out <<
"Remove from 100,000 strings all uppercase letters: (utility) " << timer.elapsed() <<
"ms"
420 for (QString &s : strings) { s.remove(upperRegex); }
421 out <<
"Remove from 100,000 strings all uppercase letters: (regex) " << timer.elapsed() <<
"ms"
430 out <<
"Split 100,000 line string into list of lines: (QStringList) " << timer.elapsed() <<
"ms"
438 out <<
"Split 100,000 line string into list of lines: (QList<QStringView>) " << timer.elapsed() <<
"ms"
444 int CSamplesPerformance::samplesStringConcat(QTextStream &out)
446 const int loop = 250000;
448 const QString x1 =
"11-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
449 const QString x2 =
"22-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
450 const QString x3 =
"33-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
451 const QString x4 =
"44-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
452 const QString x5 =
"55-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
453 const QString x6 =
"66-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
454 const QString x7 =
"77-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
455 const QString x8 =
"88-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
456 const QString x9 =
"99-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
460 for (
int i = 0; i < loop; i++) { x +=
"12-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; }
461 out <<
"+= String " << time.elapsed() <<
"ms" << Qt::endl;
465 for (
int i = 0; i < loop; i++)
467 x += QLatin1String(
"12-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
469 out <<
"+= QLatin1String " << time.elapsed() <<
"ms" << Qt::endl;
473 for (
int i = 0; i < loop; i++)
475 x += QStringLiteral(
"12-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
477 out <<
"+= QStringLiteral " << time.elapsed() <<
"ms" << Qt::endl;
481 for (
int i = 0; i < loop; i++) { x = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9; }
482 out <<
"+ String multiple " << time.elapsed() <<
"ms" << Qt::endl;
486 for (
int i = 0; i < loop; i++) { x = x1 % x2 % x3 % x4 % x5 % x6 % x7 % x8 % x9; }
487 out <<
"% String multiple " << time.elapsed() <<
"ms" << Qt::endl;
491 for (
int i = 0; i < loop; i++)
493 x = x.append(x1).append(x2).append(x3).append(x4).append(x5).append(x6).append(x7).append(x8).append(x9);
495 out <<
"append String multiple " << time.elapsed() <<
"ms" << Qt::endl;
498 static const QString xArgString(
"%1 %2 %3 %4 %5 %6 %7 %8 %9");
500 for (
int i = 0; i < loop; i++) { x = xArgString.arg(x1, x2, x3, x4, x5, x6, x7, x8, x9); }
501 out <<
"arg String multiple " << time.elapsed() <<
"ms" << Qt::endl;
505 for (
int i = 0; i < loop; i++)
507 x = QStringLiteral(
"%1 %2 %3 %4 %5 %6 %7 %8 %9").arg(x1, x2, x3, x4, x5, x6, x7, x8, x9);
509 out <<
"arg QStringLiteral multiple " << time.elapsed() <<
"ms" << Qt::endl;
515 int CSamplesPerformance::samplesStringLiteralVsConstQString(QTextStream &out)
517 const int loop = 1e7;
521 for (
int i = 0; i < loop; i++) { x = fooString(); }
522 out <<
"by constQString " << time.elapsed() <<
"ms" << Qt::endl;
526 for (
int i = 0; i < loop; i++) { x = fooStringLiteral(); }
527 out <<
"by QStringLiteral " << time.elapsed() <<
"ms" << Qt::endl;
531 for (
int i = 0; i < loop; i++)
533 x = QString(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. "
534 "Sed cursus ante dapibus diam. Sed nisi.");
536 out <<
"by QString(\"...\") " << time.elapsed() <<
"ms" << Qt::endl;
540 for (
int i = 0; i < loop; i++)
542 x = QStringLiteral(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent "
543 "libero. Sed cursus ante dapibus diam. Sed nisi.");
545 out <<
"by QStringLiteral(\"...\") " << time.elapsed() <<
"ms" << Qt::endl;
549 for (
int i = 0; i < loop; i++)
551 QStringList foo = generateList();
552 Q_UNUSED(foo.size());
554 out <<
"generated list " << time.elapsed() <<
"ms" << Qt::endl;
557 for (
int i = 0; i < loop; i++)
559 QStringList foo = replacedList();
560 Q_UNUSED(foo.size());
562 out <<
"replaced list " << time.elapsed() <<
"ms" << Qt::endl;
567 int CSamplesPerformance::sampleQMapVsQHashByCallsign(QTextStream &out)
569 const CCallsignSet cs10 = CSamplesPerformance::callsigns(10);
570 const CCallsignSet cs25 = CSamplesPerformance::callsigns(25);
571 const CCallsignSet cs50 = CSamplesPerformance::callsigns(50);
581 Q_ASSERT(m10.size() == 10 && h10.size() == 10);
582 Q_ASSERT(m25.size() == 25 && h25.size() == 25);
583 Q_ASSERT(m50.size() == 50 && h50.size() == 50);
586 QList<CCallsign> cs_10_100_rnd;
587 QList<CCallsign> cs_25_100_rnd;
588 QList<CCallsign> cs_50_100_rnd;
590 for (
int i = 0; i < 20; ++i)
597 Q_ASSERT(cs_10_100_rnd.size() == 100);
598 Q_ASSERT(cs_25_100_rnd.size() == 100);
599 Q_ASSERT(cs_50_100_rnd.size() == 100);
603 for (
int i = 1; i < 10000; ++i)
605 for (
const CCallsign &cs : cs_10_100_rnd)
608 Q_ASSERT_X(s.
getCallsign() == cs, Q_FUNC_INFO,
"Wromg callsign");
611 out <<
"map 100 out of 10: " << time.elapsed() <<
"ms" << Qt::endl;
614 for (
int i = 1; i < 10000; ++i)
616 for (
const CCallsign &cs : cs_10_100_rnd)
619 Q_ASSERT_X(s.
getCallsign() == cs, Q_FUNC_INFO,
"Wromg callsign");
622 out <<
"hash 100 out of 10: " << time.elapsed() <<
"ms" << Qt::endl;
625 for (
int i = 1; i < 10000; ++i)
627 for (
const CCallsign &cs : cs_25_100_rnd)
630 Q_ASSERT_X(s.
getCallsign() == cs, Q_FUNC_INFO,
"Wromg callsign");
633 out <<
"map 100 out of 25: " << time.elapsed() <<
"ms" << Qt::endl;
636 for (
int i = 1; i < 10000; ++i)
638 for (
const CCallsign &cs : cs_25_100_rnd)
641 Q_ASSERT_X(s.
getCallsign() == cs, Q_FUNC_INFO,
"Wromg callsign");
644 out <<
"hash 100 out of 25: " << time.elapsed() <<
"ms" << Qt::endl;
647 for (
int i = 1; i < 10000; ++i)
649 for (
const CCallsign &cs : cs_50_100_rnd)
652 Q_ASSERT_X(s.
getCallsign() == cs, Q_FUNC_INFO,
"Wromg callsign");
655 out <<
"map 100 out of 50: " << time.elapsed() <<
"ms" << Qt::endl;
658 for (
int i = 1; i < 10000; ++i)
660 for (
const CCallsign &cs : cs_50_100_rnd)
663 Q_ASSERT_X(s.
getCallsign() == cs, Q_FUNC_INFO,
"Wromg callsign");
666 out <<
"hash 100 out of 50: " << time.elapsed() <<
"ms" << Qt::endl;
675 for (
int cs = 0; cs < numberOfCallsigns; cs++)
677 CCallsign callsign(
"CS" + QString::number(cs));
679 for (
int t = 0; t < numberOfTimes; t++)
682 s.setMSecsSinceEpoch(baseTimeEpoch + DeltaTime * t);
689 CAircraftModelList CSamplesPerformance::createModels(
int numberOfModels,
int numberOfMemoParts)
694 for (
int i = 0; i < numberOfMemoParts; ++i)
699 "A" + QString::number(i),
701 "Foo",
"red",
"blue",
false));
706 for (
int i = 0; i < numberOfModels; ++i)
708 const auto &aircraftIcao = aircraftIcaos[CMathUtils::randomInteger(0, numberOfMemoParts - 1)];
709 const auto &livery = liveries[CMathUtils::randomInteger(0, numberOfMemoParts - 1)];
710 const auto &distributor = distributors[CMathUtils::randomInteger(0, numberOfMemoParts - 1)];
712 QString::number(i), QString::number(i), aircraftIcao, livery));
718 void CSamplesPerformance::calculateDistance(
int n)
720 if (n < 1) {
return; }
722 const QList<CCoordinateGeodetic> pos(
727 const qsizetype s = pos.size();
728 for (
int i = 0; i < n; i++)
730 const qsizetype p = i % s;
735 void CSamplesPerformance::copy10kStations(
int times)
738 for (
int i = 0; i < times; i++)
740 stations = stations10k();
745 void CSamplesPerformance::parseWgs(
int times)
747 static QStringList wgsLatLng({
"12° 11′ 10″ N",
"11° 22′ 33″ W",
"48° 21′ 13″ N",
"11° 47′ 09″ E",
748 " 8° 21′ 13″ N",
"11° 47′ 09″ W",
"18° 21′ 13″ S",
"11° 47′ 09″ E",
749 "09° 12′ 13″ S",
"11° 47′ 09″ W" });
752 const CAltitude a(333, CLengthUnit::m());
753 for (
int i = 0; i < times; i++)
755 int idx = (i % 5) * 2;
756 c = CCoordinateGeodetic::fromWgs84(wgsLatLng.at(idx), wgsLatLng.at(idx + 1), a);
760 const QString &CSamplesPerformance::fooString()
762 static const QString s(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent "
763 "libero. Sed cursus ante dapibus diam. Sed nisi.");
767 QString CSamplesPerformance::fooStringLiteral()
769 return QStringLiteral(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent "
770 "libero. Sed cursus ante dapibus diam. Sed nisi.");
773 QStringList CSamplesPerformance::generateList() {
return QStringList({
"1",
"2",
"3",
"4" }); }
775 QStringList CSamplesPerformance::replacedList()
777 static const QStringList l({
"1",
"2",
"3",
"4" });
779 lc[1] = QStringLiteral(
"6");
780 lc[3] = QStringLiteral(
"7");
787 static const QString cs(
"FOO%1");
798 situations.insert(cs, s);
809 situations.insert(cs, s);
816 static const CAtcStationList s = CTesting::createAtcStations(10000,
false);
820 void CSamplesPerformance::accessStationsData(
const CAtcStationList &stations,
bool byPropertyIndex)
824 const QString s = CSamplesPerformance::accessStationData(station, byPropertyIndex);
829 QString CSamplesPerformance::accessStationData(
const CAtcStation &station,
bool byPropertyIndex)
840 CPropertyIndex { CAtcStation::IndexPosition, CCoordinateGeodetic::IndexLatitudeAsString })
844 CPropertyIndex { CAtcStation::IndexPosition, CCoordinateGeodetic::IndexLongitudeAsString })
847 .propertyByIndex(
CPropertyIndex { CAtcStation::IndexRelativeDistance,
848 CLength::IndexValueRounded2DigitsWithUnit })
852 .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.
SWIFT_MISC_EXPORT QList< QStringView > splitLinesRefs(const QString &s)
Split a string into multiple lines. Blank lines are skipped.
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.
Response from our database (depending on JSON DB backend generates)