diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7fd418bde..1b52fae1d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,16 @@
# Changelog
+## 0.13.0
+
+### Bug Fixes
+- The various tabs in the Flight information dialog (Description, Aircraft, Conditions and Flight Plan) are now properly updated when importing a flight or loading a flight from the logbook
+
+### Under The Hood
+- Rule of Zero, copy-and-swap [[Back to Basics: RAII and the Rule of Zero - Arthur O'Dwyer - CppCon 2019](https://www.youtube.com/watch?v=7Qgd9B1KuMQ)]
+- Thread-safe access to singletons [[Back to Basics: Concurrency - Arthur O'Dwyer - CppCon 2020](https://www.youtube.com/watch?v=F6Ipn7gCOsY)]
+- Value-based aircraft list (CPU cache optimisation)
+- Small performance optimisations (e.g. return value optimisation)
+
## 0.12.0
### New Features
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fdc8848ff..07d282f76 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,7 +9,7 @@ set(APP_NAME "SkyDolly")
project(
${APP_NAME}
- VERSION 0.12.0
+ VERSION 0.13.0
DESCRIPTION "Sky Dolly - The Black Sheep for Your Flight Recordings"
HOMEPAGE_URL "https://github.com/till213/SkyDolly"
LANGUAGES CXX
diff --git a/i18n/SkyDolly_de_DE.ts b/i18n/SkyDolly_de_DE.ts
index 9cd0e0a21..00cca34de 100644
--- a/i18n/SkyDolly_de_DE.ts
+++ b/i18n/SkyDolly_de_DE.ts
@@ -29,12 +29,12 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -271,33 +271,33 @@ MIT License
BackupPeriodComboBox
-
+
-
+
-
+
-
+
-
+
-
-
+
+
@@ -345,47 +345,47 @@ MIT License
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -393,7 +393,7 @@ MIT License
-
+
@@ -401,7 +401,7 @@ MIT License
-
+
@@ -409,22 +409,22 @@ MIT License
-
+
-
+
-
+
-
+
@@ -472,37 +472,37 @@ MIT License
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -531,22 +531,22 @@ MIT License
DatabaseService
-
+
-
+
-
+
-
+
@@ -638,41 +638,41 @@ MIT License
ExportPluginBase
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
@@ -786,27 +786,27 @@ MIT License
-
+
-
+
-
+
-
+
-
+
Window|Flight...
@@ -866,13 +866,13 @@ MIT License
-
-
+
+
-
-
+
+
@@ -885,6 +885,18 @@ MIT License
+
+
+
+
+
+
+
+
+
+
+
+
@@ -915,6 +927,11 @@ MIT License
+
+
+
+
+
@@ -928,13 +945,13 @@ MIT License
-
-
+
+
-
-
+
+
@@ -943,23 +960,6 @@ MIT License
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1205,22 +1205,22 @@ or choose another reference aircraft (marked in green) in the formation.
-
+
-
+
-
+
-
+
@@ -1268,40 +1268,40 @@ or choose another reference aircraft (marked in green) in the formation.
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
@@ -1352,22 +1352,22 @@ or choose another reference aircraft (marked in green) in the formation.
-
+
-
+
-
+
-
+
@@ -1375,48 +1375,48 @@ or choose another reference aircraft (marked in green) in the formation.
ImportPluginBase
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -1463,22 +1463,22 @@ or choose another reference aircraft (marked in green) in the formation.
-
+
-
+
-
+
-
+
@@ -1491,7 +1491,7 @@ or choose another reference aircraft (marked in green) in the formation.
-
+
@@ -1585,23 +1585,23 @@ or choose another reference aircraft (marked in green) in the formation.
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -1611,29 +1611,29 @@ or choose another reference aircraft (marked in green) in the formation.
-
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
-
-
+
+
@@ -1673,7 +1673,7 @@ or choose another reference aircraft (marked in green) in the formation.
-
+
@@ -1684,81 +1684,81 @@ or choose another reference aircraft (marked in green) in the formation.
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
@@ -1768,68 +1768,68 @@ or choose another reference aircraft (marked in green) in the formation.
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -1882,39 +1882,6 @@ or choose another reference aircraft (marked in green) in the formation.
-
- LogbookManager
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
LogbookPlugin
@@ -2177,11 +2144,6 @@ or choose another reference aircraft (marked in green) in the formation.
-
-
-
-
-
@@ -2213,6 +2175,11 @@ or choose another reference aircraft (marked in green) in the formation.Simulation duration.
+
+
+
+
+
@@ -2509,7 +2476,7 @@ or choose another reference aircraft (marked in green) in the formation.
-
+
@@ -2560,8 +2527,8 @@ or choose another reference aircraft (marked in green) in the formation.
-
-
+
+
@@ -2571,126 +2538,159 @@ or choose another reference aircraft (marked in green) in the formation.
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+ PersistenceManager
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
PrimaryFlightControlWidget
@@ -2722,214 +2722,214 @@ or choose another reference aircraft (marked in green) in the formation.
QObject
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -3420,73 +3420,73 @@ or choose another reference aircraft (marked in green) in the formation.SimulationVariablesDialog
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
Window|Simulation Variables...
-
+
-
+
-
+
-
+
-
+
-
+
@@ -3529,13 +3529,13 @@ or choose another reference aircraft (marked in green) in the formation.
-
+
Window|Statistics...
-
+
@@ -3564,52 +3564,52 @@ or choose another reference aircraft (marked in green) in the formation.
Unit
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
diff --git a/src/Flight/include/Flight/Analytics.h b/src/Flight/include/Flight/Analytics.h
index 4bd355e59..cf8e9af25 100644
--- a/src/Flight/include/Flight/Analytics.h
+++ b/src/Flight/include/Flight/Analytics.h
@@ -1,4 +1,4 @@
-/**
+ /**
* Sky Dolly - The Black Sheep for Your Flight Recordings
*
* Copyright (c) Oliver Knoll
@@ -36,7 +36,7 @@
class Aircraft;
struct PositionData;
-class AnalyticsPrivate;
+struct AnalyticsPrivate;
/*!
* Provides basic flight path & events analytics.
@@ -46,6 +46,10 @@ class FLIGHT_API Analytics
public:
Analytics(const Aircraft &aircraft);
+ Analytics(const Analytics &rhs) = delete;
+ Analytics(Analytics &&rhs);
+ Analytics &operator=(const Analytics &rhs) = delete;
+ Analytics &operator=(Analytics &&rhs);
~Analytics();
/*!
@@ -54,12 +58,11 @@ class FLIGHT_API Analytics
* still on the ground). The movement is purely calculated based on the distance
* between the positions.
*
- * \return the heading of the first aircraft movement; PositionData::NullData if
- * no positions exist
+ * \return the heading of the first aircraft movement
*/
- const std::pair firstMovementHeading() const noexcept;
+ std::pair firstMovementHeading() const noexcept;
- const PositionData &closestPosition(double latitude, double longitude) const noexcept;
+ PositionData closestPosition(double latitude, double longitude) const noexcept;
private:
std::unique_ptr d;
diff --git a/src/Flight/include/Flight/FlightAugmentation.h b/src/Flight/include/Flight/FlightAugmentation.h
index 8660e1ea1..429199801 100644
--- a/src/Flight/include/Flight/FlightAugmentation.h
+++ b/src/Flight/include/Flight/FlightAugmentation.h
@@ -33,7 +33,7 @@
#include "FlightLib.h"
class Aircraft;
-class FlightAugmentationPrivate;
+struct FlightAugmentationPrivate;
/*!
* Augments flight data with attitude and velocity, for instance.
@@ -69,7 +69,11 @@ class FLIGHT_API FlightAugmentation
Q_DECLARE_FLAGS(Aspects, Aspect)
FlightAugmentation(Procedures procedures = Procedure::All, Aspects aspects = Aspect::All) noexcept;
- ~FlightAugmentation() noexcept;
+ FlightAugmentation(const FlightAugmentation &rhs) = delete;
+ FlightAugmentation(FlightAugmentation &&rhs);
+ FlightAugmentation &operator=(const FlightAugmentation &rhs) = delete;
+ FlightAugmentation &operator=(FlightAugmentation &&rhs);
+ ~FlightAugmentation();
void setProcedures(Procedures procedures) noexcept;
Procedures getProcedures() const noexcept;
diff --git a/src/Flight/src/Analytics.cpp b/src/Flight/src/Analytics.cpp
index f79fa3a77..3eb9474cd 100644
--- a/src/Flight/src/Analytics.cpp
+++ b/src/Flight/src/Analytics.cpp
@@ -27,6 +27,9 @@
#include
#include
+#ifdef DEBUG
+#include
+#endif
#include
#include
@@ -50,9 +53,8 @@ namespace {
};
}
-class AnalyticsPrivate
+struct AnalyticsPrivate
{
-public:
AnalyticsPrivate(const Aircraft &theAircraft)
: aircraft(theAircraft)
{}
@@ -64,20 +66,13 @@ class AnalyticsPrivate
Analytics::Analytics(const Aircraft &aircraft)
: d(std::make_unique(aircraft))
-{
-#ifdef DEBUG
- qDebug("Analytics::~Analytics: CREATED");
-#endif
-}
+{}
-Analytics::~Analytics()
-{
-#ifdef DEBUG
- qDebug("Analytics::~Analytics: DELETED");
-#endif
-}
+Analytics::Analytics(Analytics &&rhs) = default;
+Analytics &Analytics::operator=(Analytics &&rhs) = default;
+Analytics::~Analytics() = default;
-const std::pair Analytics::firstMovementHeading() const noexcept
+std::pair Analytics::firstMovementHeading() const noexcept
{
std::pair result;
Position &position = d->aircraft.getPosition();
@@ -101,23 +96,19 @@ const std::pair Analytics::firstMovementHeading() const no
return result;
}
-const PositionData &Analytics::closestPosition(double latitude, double longitude) const noexcept
+PositionData Analytics::closestPosition(double latitude, double longitude) const noexcept
{
+ PositionData positionData;
double minimumDistance = std::numeric_limits::max();
- const PositionData *closestPositionData {nullptr};
Position &position = d->aircraft.getPosition();
for (const PositionData &pos : position) {
const double distance = SkyMath::geodesicDistance(SkyMath::Coordinate(latitude, longitude),
SkyMath::Coordinate(pos.latitude, pos.longitude));
if (minimumDistance > distance) {
- closestPositionData = &pos;
+ positionData = pos;
minimumDistance = distance;
}
}
- if (closestPositionData != nullptr) {
- return *closestPositionData;
- } else {
- return PositionData::NullData;
- }
+ return positionData;
}
diff --git a/src/Flight/src/FlightAugmentation.cpp b/src/Flight/src/FlightAugmentation.cpp
index 621d78c5b..bd3914205 100644
--- a/src/Flight/src/FlightAugmentation.cpp
+++ b/src/Flight/src/FlightAugmentation.cpp
@@ -58,9 +58,8 @@ namespace {
constexpr double MaxBankAngle = 25;
}
-class FlightAugmentationPrivate
+struct FlightAugmentationPrivate
{
-public:
FlightAugmentationPrivate(FlightAugmentation::Procedures theProcedures, FlightAugmentation::Aspects theAspects)
: procedures(theProcedures),
aspects(theAspects)
@@ -74,18 +73,11 @@ class FlightAugmentationPrivate
FlightAugmentation::FlightAugmentation(Procedures procedures, Aspects aspects) noexcept
: d(std::make_unique(procedures, aspects))
-{
-#ifdef DEBUG
- qDebug("FlightAugmentation::~FlightAugmentation: CREATED");
-#endif
-}
+{}
-FlightAugmentation::~FlightAugmentation() noexcept
-{
-#ifdef DEBUG
- qDebug("FlightAugmentation::~FlightAugmentation: DELETED");
-#endif
-}
+FlightAugmentation::FlightAugmentation(FlightAugmentation &&rhs) = default;
+FlightAugmentation &FlightAugmentation::operator=(FlightAugmentation &&rhs) = default;
+FlightAugmentation::~FlightAugmentation() = default;
void FlightAugmentation::setProcedures(Procedures procedures) noexcept
{
diff --git a/src/Kernel/CMakeLists.txt b/src/Kernel/CMakeLists.txt
index ad458a903..760751431 100644
--- a/src/Kernel/CMakeLists.txt
+++ b/src/Kernel/CMakeLists.txt
@@ -21,7 +21,7 @@ target_sources(${LIBRARY_NAME}
include/Kernel/Convert.h src/Convert.cpp
include/Kernel/Enum.h
include/Kernel/File.h src/File.cpp
- include/Kernel/FlightSimulator.h src/FlightSimulator.cpp
+ include/Kernel/FlightSimulator.h
include/Kernel/Name.h
include/Kernel/PositionParser.h src/PositionParser.cpp
include/Kernel/Replay.h
diff --git a/src/Kernel/include/Kernel/Const.h b/src/Kernel/include/Kernel/Const.h
index f68c069e6..7f807299a 100644
--- a/src/Kernel/include/Kernel/Const.h
+++ b/src/Kernel/include/Kernel/Const.h
@@ -1,15 +1,23 @@
#ifndef CONST_H
#define CONST_H
+#include
+
namespace Const {
- constexpr char LogbookExtension[] = ".sdlog";
-
- constexpr char BackupNeverSymId[] = "NEVER";
- constexpr char BackupNowSymId[] = "NOW";
- constexpr char BackupMonthlySymId[] = "MONTH";
- constexpr char BackupWeeklySymId[] = "WEEK";
- constexpr char BackupDailySymId[] = "DAY";
- constexpr char BackupAlwaysSymId[] = "ALWAYS";
+
+ /*!
+ * An invalid ID indicates that the object has not yet been (successfully) persisted.
+ */
+ constexpr std::int64_t InvalidId {-1};
+
+ constexpr const char *LogbookExtension {".sdlog"};
+
+ constexpr const char *BackupNeverSymId = "NEVER";
+ constexpr const char *BackupNowSymId = "NOW";
+ constexpr const char *BackupMonthlySymId = "MONTH";
+ constexpr const char *BackupWeeklySymId = "WEEK";
+ constexpr const char *BackupDailySymId = "DAY";
+ constexpr const char *BackupAlwaysSymId = "ALWAYS";
}
#endif // CONST_H
diff --git a/src/Kernel/include/Kernel/Convert.h b/src/Kernel/include/Kernel/Convert.h
index f851b929b..6b72566ee 100644
--- a/src/Kernel/include/Kernel/Convert.h
+++ b/src/Kernel/include/Kernel/Convert.h
@@ -28,6 +28,10 @@
#include
#include
+#ifdef DEBUG
+#include
+#endif
+
#include
#include "KernelLib.h"
@@ -45,7 +49,11 @@ class KERNEL_API Convert final
public:
Convert() noexcept;
- ~Convert() noexcept;
+ Convert(const Convert &rhs) = delete;
+ Convert(Convert &&rhs);
+ Convert &operator=(const Convert &rhs) = delete;
+ Convert &operator=(Convert &&rhs);
+ ~Convert();
/*!
* Converts the \c height height above WGS84 reference ellipsoid to height above the earth
@@ -79,7 +87,7 @@ class KERNEL_API Convert final
catch (const std::exception &ex) {
heightAboveGeoid = height;
#ifdef DEBUG
- qDebug("Convert::wgs84ToEgmGeoid: caught exception: %s", ex.what());
+ qDebug() << "Convert::wgs84ToEgmGeoid: caught exception: %s", ex.what();
#endif
}
} else {
@@ -120,7 +128,7 @@ class KERNEL_API Convert final
catch (const std::exception &ex) {
heightAboveEllipsoid = height;
#ifdef DEBUG
- qDebug("Convert::egmToWgs84Ellipsoid: caught exception: %s", ex.what());
+ qDebug() << "Convert::egmToWgs84Ellipsoid: caught exception:" << ex.what();
#endif
}
} else {
diff --git a/src/Kernel/include/Kernel/Enum.h b/src/Kernel/include/Kernel/Enum.h
index eccae2785..e05810918 100644
--- a/src/Kernel/include/Kernel/Enum.h
+++ b/src/Kernel/include/Kernel/Enum.h
@@ -38,7 +38,7 @@ namespace Enum
template
constexpr auto toUnderlyingType(E e) noexcept
{
- return static_cast::type>(e);
+ return static_cast>(e);
}
}
diff --git a/src/Kernel/include/Kernel/FlightSimulator.h b/src/Kernel/include/Kernel/FlightSimulator.h
index c203500c8..e51a742e9 100644
--- a/src/Kernel/include/Kernel/FlightSimulator.h
+++ b/src/Kernel/include/Kernel/FlightSimulator.h
@@ -33,7 +33,6 @@
class KERNEL_API FlightSimulator final
{
public:
- FlightSimulator() noexcept;
enum struct Id {
None,
@@ -49,15 +48,13 @@ class KERNEL_API FlightSimulator final
static inline const QString FlightSimulatorNamePrepar3Dv5 {QStringLiteral("Prepar3Dv5")};
static inline Id nameToId(QStringView name) noexcept {
- Id id;
+ Id id {Id::None};
if (name == FlightSimulatorNameAll) {
id = Id::All;
} else if (name == FlightSimulatorNameMSFS) {
id = Id::FS2020;
} else if (name == FlightSimulatorNamePrepar3Dv5) {
id = Id::Prepar3Dv5;
- } else {
- id = Id::None;
}
return id;
}
diff --git a/src/Kernel/include/Kernel/PositionParser.h b/src/Kernel/include/Kernel/PositionParser.h
index 8cd377c3a..84a8e03e2 100644
--- a/src/Kernel/include/Kernel/PositionParser.h
+++ b/src/Kernel/include/Kernel/PositionParser.h
@@ -1,5 +1,5 @@
/**
- * Sky Dolly - The Black Sheep for your Flight Recordings
+ * Sky Dolly - The Black Sheep for Your Flight Recordings
*
* Copyright (c) Oliver Knoll
* All rights reserved.
diff --git a/src/Kernel/include/Kernel/Settings.h b/src/Kernel/include/Kernel/Settings.h
index 6ebbabc92..ce84b80b7 100644
--- a/src/Kernel/include/Kernel/Settings.h
+++ b/src/Kernel/include/Kernel/Settings.h
@@ -42,8 +42,8 @@
#include "SampleRate.h"
#include "KernelLib.h"
-class SettingsPrivate;
class Version;
+struct SettingsPrivate;
/*!
* The application settings. These settings are persisted to user configuration
@@ -54,6 +54,11 @@ class KERNEL_API Settings final : public QObject
Q_OBJECT
public:
+ Settings(const Settings &rhs) = delete;
+ Settings(Settings &&rhs) = delete;
+ Settings &operator=(const Settings &rhs) = delete;
+ Settings &operator=(Settings &&rhs) = delete;
+
/*!
* Returns the singleton Settings instance.
*
@@ -798,13 +803,11 @@ public slots:
*/
void changed();
-protected:
- ~Settings() noexcept override;
-
private:
- std::unique_ptr d;
+ const std::unique_ptr d;
Settings() noexcept;
+ ~Settings() final;
void frenchConnection() noexcept;
diff --git a/src/Kernel/include/Kernel/Sort.h b/src/Kernel/include/Kernel/Sort.h
index b46d4d8a6..c26b133eb 100644
--- a/src/Kernel/include/Kernel/Sort.h
+++ b/src/Kernel/include/Kernel/Sort.h
@@ -55,19 +55,26 @@ template > class Sort
struct Vertex
{
- explicit Vertex()
- : id(T())
+ explicit Vertex(T theId) noexcept
+ : id(theId)
{};
- explicit Vertex(T theId)
- : id(theId)
+ Vertex() noexcept
+ : id(T())
{};
+ Vertex(const Vertex &rhs) = delete;
+ Vertex(Vertex &&rhs) = default;
+ Vertex &operator=(const Vertex &rhs) = delete;
+ Vertex &operator=(Vertex &&rhs) = default;
+ ~Vertex() = default;
+
T id;
+
/*!
- * The edges are defined by this and their end vertices given in the \c edges list.
+ * The edges are defined by the non-owning \c edges list.
*/
- std::vector> edges;
+ std::vector edges;
State state {State::NotVisited};
};
@@ -87,16 +94,16 @@ template > class Sort
* \return the nodes sorted in topological order, with the first node at beginning of the deque;
* an empty deque if the \c graph is either empty or not a directed acyclic graph (DAG)
*/
- static std::deque> topologicalSort(Graph &graph, Sorting sorting = Sorting::Normal) noexcept
+ static std::deque topologicalSort(Graph &graph, Sorting sorting = Sorting::Normal) noexcept
{
- std::deque> sorted;
+ std::deque sorted;
for (auto &it : graph) {
it.second->state = State::NotVisited;
}
bool ok {true};
for (auto &it : graph) {
if (it.second->state != State::Done) {
- ok = visit(it.second, sorting, sorted);
+ ok = visit(*(it.second), sorting, sorted);
if (!ok) {
// Not a DAG -> clear sorted vertices
sorted.clear();
@@ -113,29 +120,29 @@ template > class Sort
// vertices have completely been recursively visited.
// Returns true if the visit was successful or false in case a cycle was detected (in which case the 'sorted' result
// is left as is, without cycle)
- static bool visit(std::shared_ptr vertex, Sorting sorting, std::deque> &sorted) noexcept
+ static bool visit(Vertex &vertex, Sorting sorting, std::deque &sorted) noexcept
{
- if (vertex->state == State::Done) {
+ if (vertex.state == State::Done) {
// Already visited
return true;
- } else if (vertex->state == State::Visiting) {
+ } else if (vertex.state == State::Visiting) {
// Not a DAG (cycle detected)
return false;
}
- vertex->state = State::Visiting;
+ vertex.state = State::Visiting;
bool ok {true};
- for (std::shared_ptr n : vertex->edges) {
- ok = visit(n, sorting, sorted);
+ for (Vertex *v : vertex.edges) {
+ ok = visit(*v, sorting, sorted);
if (!ok) {
break;
}
}
- vertex->state = State::Done;
+ vertex.state = State::Done;
if (sorting == Sorting::Normal) {
- sorted.push_front(vertex);
+ sorted.push_front(&vertex);
} else {
- sorted.push_back(vertex);
+ sorted.push_back(&vertex);
}
return ok;
}
diff --git a/src/Kernel/include/Kernel/Unit.h b/src/Kernel/include/Kernel/Unit.h
index 1d4504a53..54561ad78 100644
--- a/src/Kernel/include/Kernel/Unit.h
+++ b/src/Kernel/include/Kernel/Unit.h
@@ -37,7 +37,7 @@ class QTime;
#include "KernelLib.h"
-class UnitPrivate;
+struct UnitPrivate;
class KERNEL_API Unit final
{
@@ -51,6 +51,10 @@ class KERNEL_API Unit final
};
Unit();
+ Unit(const Unit &rhs) = delete;
+ Unit(Unit &&rhs);
+ Unit &operator=(const Unit &rhs) = delete;
+ Unit &operator=(Unit &&rhs);
~Unit();
/*!
diff --git a/src/Kernel/include/Kernel/Version.h b/src/Kernel/include/Kernel/Version.h
index 72949bdec..cc900cfe2 100644
--- a/src/Kernel/include/Kernel/Version.h
+++ b/src/Kernel/include/Kernel/Version.h
@@ -45,10 +45,6 @@ struct VersionPrivate;
class KERNEL_API Version final
{
public:
- /*!
- * Creates this Version with the current values of the application version.
- */
- Version() noexcept;
/*!
* Creates this Version with \p majorNo, \p minorNo and \p patchNo values. This
@@ -72,9 +68,13 @@ class KERNEL_API Version final
* \sa #operator<()
*/
Version(QStringView version) noexcept;
- Version(const Version &other) noexcept;
- Version(Version &&other) noexcept;
- ~Version() noexcept;
+
+ Version() noexcept;
+ Version(const Version &rhs) = delete;
+ Version(Version &&rhs);
+ Version &operator=(const Version &rhs) = delete;
+ Version &operator=(Version &&rhs);
+ ~Version();
void fromString(QStringView version) noexcept;
@@ -115,14 +115,6 @@ class KERNEL_API Version final
*/
bool isNull() const noexcept;
- /*!
- * Assignmnent operator.
- *
- * \param rhs
- * the other Version to assign from
- */
- void operator=(const Version &rhs) noexcept;
-
/*!
* Compares this Version against \c rhs for equality.
*
diff --git a/src/Kernel/src/Convert.cpp b/src/Kernel/src/Convert.cpp
index 280cbf388..bf8b99c82 100644
--- a/src/Kernel/src/Convert.cpp
+++ b/src/Kernel/src/Convert.cpp
@@ -39,7 +39,7 @@
// PUBLIC
Convert::Convert() noexcept
-{
+{
const QFileInfo earthGravityModelFileInfo = Settings::getInstance().getEarthGravityModelFileInfo();
if (earthGravityModelFileInfo.exists()) {
try {
@@ -57,5 +57,6 @@ Convert::Convert() noexcept
}
}
-Convert::~Convert() noexcept
-{}
+Convert::Convert(Convert &&rhs) = default;
+Convert &Convert::operator=(Convert &&rhs) = default;
+Convert::~Convert() = default;
diff --git a/src/Kernel/src/FlightSimulator.cpp b/src/Kernel/src/FlightSimulator.cpp
deleted file mode 100644
index 1f81bee6e..000000000
--- a/src/Kernel/src/FlightSimulator.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Sky Dolly - The Black Sheep for Your Flight Recordings
- *
- * Copyright (c) Oliver Knoll
- * All rights reserved.
- *
- * MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this
- * software and associated documentation files (the "Software"), to deal in the Software
- * without restriction, including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
- * to whom the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
- * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
- * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-#include
-
-#include "FlightSimulator.h"
-
-// PUBLIC
-
-FlightSimulator::FlightSimulator() noexcept
-{}
diff --git a/src/Kernel/src/PositionParser.cpp b/src/Kernel/src/PositionParser.cpp
index 63fdaf5fc..3b7e4a401 100644
--- a/src/Kernel/src/PositionParser.cpp
+++ b/src/Kernel/src/PositionParser.cpp
@@ -1,5 +1,5 @@
/**
- * Sky Dolly - The Black Sheep for your Flight Recordings
+ * Sky Dolly - The Black Sheep for Your Flight Recordings
*
* Copyright (c) Oliver Knoll
* All rights reserved.
diff --git a/src/Kernel/src/Settings.cpp b/src/Kernel/src/Settings.cpp
index 645184e14..658a8e488 100644
--- a/src/Kernel/src/Settings.cpp
+++ b/src/Kernel/src/Settings.cpp
@@ -22,10 +22,13 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
+#include
+
#include
#include
#include
#include
+#include
#include
#include
#include
@@ -45,18 +48,33 @@
namespace
{
- constexpr bool DefaultBackupBeforeMigration {true};
-
- constexpr char ResourceDirectoryName[] = "Resources";
+ constexpr const char *ResourceDirectoryName {"Resources"};
// This happens to be the same directory name as when unzipping the downloaded EGM data
// from https://geographiclib.sourceforge.io/html/geoid.html#geoidinst
- constexpr char EgmDirectoryName[] = "geoids";
- constexpr char DefaultEgmFileName[] = "egm2008-5.pgm";
+ constexpr const char *EgmDirectoryName {"geoids"};
+ constexpr const char *DefaultEgmFileName {"egm2008-5.pgm"};
}
-class SettingsPrivate
+struct SettingsPrivate
{
-public:
+ SettingsPrivate() noexcept
+ : version(QCoreApplication::instance()->applicationVersion()),
+ backupBeforeMigration(DefaultBackupBeforeMigration),
+ recordingSampleRateValue(DefaultRecordingSampleRate),
+ windowStayOnTop(DefaultWindowStayOnTop),
+ minimalUi(DefaultMinimalUi),
+ moduleSelectorVisible(DefaultModuleSelectorVisible),
+ replaySpeedVisible(DefaultReplaySpeedVisible)
+ {
+ QStringList standardLocations = QStandardPaths::standardLocations(QStandardPaths::StandardLocation::DocumentsLocation);
+ if (standardLocations.count() > 0) {
+ defaultExportPath = standardLocations.first();
+ defaultLogbookPath = standardLocations.first() % "/" % Version::getApplicationName() % "/" % Version::getApplicationName() % Const::LogbookExtension;
+ } else {
+ defaultExportPath = ".";
+ }
+ }
+
QSettings settings;
Version version;
@@ -101,15 +119,17 @@ class SettingsPrivate
int previewInfoDialogCount;
- static Settings *instance;
+ static inline std::once_flag onceFlag;
+ static inline Settings *instance {nullptr};
static constexpr QUuid DefaultSkyConnectPluginUuid {};
+ static constexpr bool DefaultBackupBeforeMigration {true};
static constexpr double DefaultRecordingSampleRate {SampleRate::toValue(SampleRate::SampleRate::Auto)};
static constexpr bool DefaultWindowStayOnTop {false};
static constexpr bool DefaultMinimalUi {false};
- static constexpr bool DefaultModuleSelectorVisible {true};
- static constexpr bool DefaultReplaySpeedVisible {true};
- static constexpr bool DefaultAbsoluteSeek {true};
+ static constexpr bool DefaultModuleSelectorVisible {true};
+ static constexpr bool DefaultReplaySpeedVisible {true};
+ static constexpr bool DefaultAbsoluteSeek {true};
static constexpr double DefaultSeekIntervalSeconds {1.0};
static constexpr double DefaultSeekIntervalPercent {0.5};
static constexpr bool DefaultReplayLoop {false};
@@ -117,12 +137,12 @@ class SettingsPrivate
static constexpr double DefaultRepeatFlapsHandleIndex {false};
// For now the default value is true, as no known aircraft exists where the canopy values would not
// have to be repeated
- static constexpr bool DefaultRepeatCanopyOpen {true};
+ static constexpr bool DefaultRepeatCanopyOpen {true};
static constexpr bool DefaultRelativePositionPlacement {true};
- static constexpr bool DefaultDeleteFlightConfirmation {true};
- static constexpr bool DefaultDeleteAircraftConfirmation {true};
- static constexpr bool DefaultDeleteLocationConfirmation {true};
- static constexpr bool DefaultResetTimeOffsetConfirmation {true};
+ static constexpr bool DefaultDeleteFlightConfirmation {true};
+ static constexpr bool DefaultDeleteAircraftConfirmation {true};
+ static constexpr bool DefaultDeleteLocationConfirmation {true};
+ static constexpr bool DefaultResetTimeOffsetConfirmation {true};
static constexpr bool DefaultMinimalUiButtonTextVisible {false};
static constexpr bool DefaultMinimalUiNonEssentialButtonVisible {false};
@@ -132,32 +152,16 @@ class SettingsPrivate
static constexpr int DefaultPreviewInfoDialogCount {3};
static constexpr int PreviewInfoDialogBase {100};
-
- SettingsPrivate() noexcept
- : version(QCoreApplication::instance()->applicationVersion())
- {
- QStringList standardLocations = QStandardPaths::standardLocations(QStandardPaths::StandardLocation::DocumentsLocation);
- if (standardLocations.count() > 0) {
- defaultExportPath = standardLocations.first();
- defaultLogbookPath = standardLocations.first() + "/" + Version::getApplicationName() + "/" + Version::getApplicationName() + Const::LogbookExtension;
- } else {
- defaultExportPath = ".";
- }
- }
-
- ~SettingsPrivate() noexcept
- {}
};
-Settings *SettingsPrivate::instance = nullptr;
// PUBLIC
Settings &Settings::getInstance() noexcept
{
- if (SettingsPrivate::instance == nullptr) {
+ std::call_once(SettingsPrivate::onceFlag, []() {
SettingsPrivate::instance = new Settings();
- }
+ });
return *SettingsPrivate::instance;
}
@@ -712,7 +716,7 @@ void Settings::restore() noexcept
d->settings.beginGroup("Logbook");
{
d->logbookPath = d->settings.value("Path", d->defaultLogbookPath).toString();
- d->backupBeforeMigration = d->settings.value("BackupBeforeMigration", ::DefaultBackupBeforeMigration).toBool();
+ d->backupBeforeMigration = d->settings.value("BackupBeforeMigration", SettingsPrivate::DefaultBackupBeforeMigration).toBool();
}
d->settings.endGroup();
d->settings.beginGroup("Plugins");
@@ -824,16 +828,6 @@ void Settings::restore() noexcept
d->settings.endGroup();
}
-// PROTECTED
-
-Settings::~Settings() noexcept
-{
-#ifdef DEBUG
- qDebug() << "Settings::~Settings: DELETED";
-#endif
- store();
-}
-
// PRIVATE
Settings::Settings() noexcept
@@ -847,6 +841,14 @@ Settings::Settings() noexcept
updateEgmFilePath();
}
+Settings::~Settings()
+{
+#ifdef DEBUG
+ qDebug() << "Settings::~Settings: DELETED";
+#endif
+ store();
+}
+
void Settings::frenchConnection() noexcept
{
connect(this, &Settings::logbookPathChanged,
diff --git a/src/Kernel/src/SettingsConverter.cpp b/src/Kernel/src/SettingsConverter.cpp
index ba48ae87d..07af70db2 100644
--- a/src/Kernel/src/SettingsConverter.cpp
+++ b/src/Kernel/src/SettingsConverter.cpp
@@ -30,7 +30,7 @@
namespace
{
- void convertToV12(Version settingsVersion, QSettings &settings)
+ void convertToV13(const Version &settingsVersion, QSettings &settings) noexcept
{
// Nothing to convert yet
}
@@ -38,10 +38,10 @@ namespace
// PUBLIC
-void SettingsConverter::convertToCurrent(Version settingsVersion, QSettings &settings)
+void SettingsConverter::convertToCurrent(const Version &settingsVersion, QSettings &settings) noexcept
{
const Version currentVersion;
if (settingsVersion < currentVersion) {
- ::convertToV12(settingsVersion, settings);
+ ::convertToV13(settingsVersion, settings);
}
}
diff --git a/src/Kernel/src/SettingsConverter.h b/src/Kernel/src/SettingsConverter.h
index b15e520cb..cd13e78c5 100644
--- a/src/Kernel/src/SettingsConverter.h
+++ b/src/Kernel/src/SettingsConverter.h
@@ -31,7 +31,7 @@
namespace SettingsConverter
{
- void convertToCurrent(Version settingsVersion, QSettings &settings);
+ void convertToCurrent(const Version &settingsVersion, QSettings &settings) noexcept;
};
#endif // SETTINGSCONVERTER_H
diff --git a/src/Kernel/src/Unit.cpp b/src/Kernel/src/Unit.cpp
index a4aec3688..81825031d 100644
--- a/src/Kernel/src/Unit.cpp
+++ b/src/Kernel/src/Unit.cpp
@@ -39,7 +39,6 @@
#include
#include
-#include "Convert.h"
#include "Unit.h"
namespace {
@@ -59,14 +58,14 @@ namespace {
constexpr int CoordinatePrecision = 6;
}
-class UnitPrivate {
+struct UnitPrivate {
public:
UnitPrivate()
{}
QLocale locale;
- static inline QLatin1Char NumberPadding {QLatin1Char('0')};
+ static constexpr QLatin1Char NumberPadding {'0'};
};
// PUBLIC
@@ -75,8 +74,9 @@ Unit::Unit()
: d(std::make_unique())
{}
-Unit::~Unit()
-{}
+Unit::Unit(Unit &&rhs) = default;
+Unit &Unit::operator=(Unit &&rhs) = default;
+Unit::~Unit() = default;
QString Unit::formatLatitudeDMS(double latitude) const noexcept
{
@@ -261,13 +261,13 @@ QString Unit::formatElapsedTime(std::int64_t milliSeconds) const noexcept
if (qAbs(milliSeconds) < ::MillisecondsPerSecond) {
elapsedTime = QCoreApplication::translate("Unit", "%1 milliseconds", nullptr, static_cast(milliSeconds)).arg(milliSeconds);
} else if (qAbs(milliSeconds) < ::MillisecondsPerSecond * ::SecondsPerMinute) {
- const double seconds = static_cast(milliSeconds) / ::MillisecondsPerSecond;
+ const double seconds = static_cast(milliSeconds) / static_cast(::MillisecondsPerSecond);
elapsedTime = QCoreApplication::translate("Unit", "%1 seconds", nullptr, static_cast(seconds)).arg(QString::number(seconds, 'f', 1));
} else if (qAbs(milliSeconds) < ::MillisecondsPerSecond * ::SecondsPerMinute * ::MinutesPerHour) {
- const double minutes = static_cast(milliSeconds) / (::MillisecondsPerSecond * ::SecondsPerMinute);
+ const double minutes = static_cast(milliSeconds) / static_cast(::MillisecondsPerSecond * ::SecondsPerMinute);
elapsedTime = QCoreApplication::translate("Unit", "%1 minutes", nullptr, static_cast(minutes)).arg(QString::number(minutes, 'f', 1));
} else {
- const double hours = static_cast(milliSeconds) / (::MillisecondsPerSecond * ::SecondsPerMinute * ::MinutesPerHour);
+ const double hours = static_cast(milliSeconds) / static_cast(::MillisecondsPerSecond * ::SecondsPerMinute * ::MinutesPerHour);
elapsedTime = QCoreApplication::translate("Unit", "%1 hours", nullptr, static_cast(hours)).arg(QString::number(hours, 'f', 1));
}
diff --git a/src/Kernel/src/Version.cpp b/src/Kernel/src/Version.cpp
index 6edf6e368..7eb7fa218 100644
--- a/src/Kernel/src/Version.cpp
+++ b/src/Kernel/src/Version.cpp
@@ -38,23 +38,23 @@
struct VersionPrivate
{
- VersionPrivate() noexcept
- {}
-
VersionPrivate(int theMajor, int theMinor, int thePatch) noexcept
: major(theMajor), minor(theMinor), patch(thePatch)
{}
- VersionPrivate(const VersionPrivate &other)
- : major(other.major), minor(other.minor), patch(other.patch)
- {}
+ VersionPrivate() = default;
+ ~VersionPrivate() = default;
+ VersionPrivate(const VersionPrivate &rhs) = default;
+ VersionPrivate(VersionPrivate &&rhs) = default;
+ VersionPrivate &operator=(const VersionPrivate &rhs) = default;
+ VersionPrivate &operator=(VersionPrivate &&rhs) = default;
int major {VersionConfig::Major};
int minor {VersionConfig::Minor};
int patch {VersionConfig::Patch};
- // https://grammar.yourdictionary.com/parts-of-speech/adjectives/adjectives-that-start-with-c.html
- static inline const QString CodeName {QStringLiteral("Celestial Cessna")};
+ // https://grammar.yourdictionary.com/parts-of-speech/adjectives/adjectives-that-start-with-d.html
+ static inline const QString CodeName {QStringLiteral("Dapper Daher")};
};
// PUBLIC
@@ -73,13 +73,9 @@ Version::Version(QStringView version) noexcept
fromString(version);
}
-Version::Version(const Version &other) noexcept
- : d(std::make_unique(other.d->major, other.d->minor, other.d->patch))
-{}
-
-Version::Version(Version &&other) noexcept
- : d(std::move(other.d))
-{}
+Version::Version(Version &&rhs) = default;
+Version &Version::operator=(Version &&rhs) = default;
+Version::~Version() = default;
void Version::fromString(QStringView version) noexcept
{
@@ -92,9 +88,6 @@ void Version::fromString(QStringView version) noexcept
}
}
-Version::~Version() noexcept
-{}
-
int Version::getMajor() const noexcept
{
return d->major;
@@ -120,11 +113,6 @@ bool Version::isNull() const noexcept
return d->major == 0 && d->minor == 0 && d->patch == 0;
}
-void Version::operator=(const Version &rhs) noexcept
-{
- d = std::make_unique(rhs.d->major, rhs.d->minor, rhs.d->patch);
-}
-
bool Version::operator==(const Version &rhs) const noexcept
{
bool result;
diff --git a/src/KernelTest/src/PositionParserTest.cpp b/src/KernelTest/src/PositionParserTest.cpp
index f7cf41cf4..cdc280537 100644
--- a/src/KernelTest/src/PositionParserTest.cpp
+++ b/src/KernelTest/src/PositionParserTest.cpp
@@ -1,5 +1,5 @@
/**
- * Sky Dolly - The Black Sheep for your Flight Recordings
+ * Sky Dolly - The Black Sheep for Your Flight Recordings
*
* Copyright (c) Oliver Knoll
* All rights reserved.
diff --git a/src/KernelTest/src/PositionParserTest.h b/src/KernelTest/src/PositionParserTest.h
index 21debafc8..eabda8575 100644
--- a/src/KernelTest/src/PositionParserTest.h
+++ b/src/KernelTest/src/PositionParserTest.h
@@ -1,5 +1,5 @@
/**
- * Sky Dolly - The Black Sheep for your Flight Recordings
+ * Sky Dolly - The Black Sheep for Your Flight Recordings
*
* Copyright (c) Oliver Knoll
* All rights reserved.
diff --git a/src/KernelTest/src/SortTest.cpp b/src/KernelTest/src/SortTest.cpp
index 2f875418d..4901a5885 100644
--- a/src/KernelTest/src/SortTest.cpp
+++ b/src/KernelTest/src/SortTest.cpp
@@ -122,12 +122,12 @@ void SortTest::topologicalSort()
std::shared_ptr sourceVertex = graph.at(nodeId);
sourceVertex->edges.reserve(edgeList.size());
for (const int id : edgeList) {
- sourceVertex->edges.push_back(graph.at(id));
+ sourceVertex->edges.push_back(graph.at(id).get());
}
}
// Exercise
- std::deque> sorted = Sort::topologicalSort(graph, sorting);
+ std::deque sorted = Sort::topologicalSort(graph, sorting);
// Verify
int i {0};
diff --git a/src/Model/CMakeLists.txt b/src/Model/CMakeLists.txt
index 56e009565..e0f3efdcc 100644
--- a/src/Model/CMakeLists.txt
+++ b/src/Model/CMakeLists.txt
@@ -14,28 +14,28 @@ target_compile_definitions(${LIBRARY_NAME}
target_sources(${LIBRARY_NAME}
PRIVATE
include/Model/ModelLib.h
- include/Model/Data.h src/Data.cpp
+ include/Model/Data.h
include/Model/Logbook.h src/Logbook.cpp
include/Model/AbstractComponent.h
include/Model/Flight.h src/Flight.cpp
- include/Model/FlightSummary.h src/FlightSummary.cpp
+ include/Model/FlightSummary.h
include/Model/FlightDate.h src/FlightDate.cpp
include/Model/FlightCondition.h src/FlightCondition.cpp
include/Model/Aircraft.h src/Aircraft.cpp
- include/Model/TimeVariableData.h src/TimeVariableData.cpp
+ include/Model/TimeVariableData.h
include/Model/Position.h src/Position.cpp
include/Model/PositionData.h src/PositionData.cpp
include/Model/InitialPosition.h src/InitialPosition.cpp
include/Model/Engine.h src/Engine.cpp
include/Model/EngineData.h src/EngineData.cpp
include/Model/PrimaryFlightControl.h src/PrimaryFlightControl.cpp
- include/Model/PrimaryFlightControlData.h src/PrimaryFlightControlData.cpp
+ include/Model/PrimaryFlightControlData.h
include/Model/SecondaryFlightControl.h src/SecondaryFlightControl.cpp
- include/Model/SecondaryFlightControlData.h src/SecondaryFlightControlData.cpp
+ include/Model/SecondaryFlightControlData.h
include/Model/AircraftHandle.h src/AircraftHandle.cpp
- include/Model/AircraftHandleData.h src/AircraftHandleData.cpp
+ include/Model/AircraftHandleData.h
include/Model/Light.h src/Light.cpp
- include/Model/LightData.h src/LightData.cpp
+ include/Model/LightData.h
include/Model/AircraftType.h src/AircraftType.cpp
include/Model/AircraftInfo.h src/AircraftInfo.cpp
include/Model/Waypoint.h src/Waypoint.cpp
diff --git a/src/Model/include/Model/AbstractComponent.h b/src/Model/include/Model/AbstractComponent.h
index f4b8eb1f9..7f9136a61 100644
--- a/src/Model/include/Model/AbstractComponent.h
+++ b/src/Model/include/Model/AbstractComponent.h
@@ -44,43 +44,25 @@ class MODEL_API AbstractComponent
using Data = typename std::vector;
using Iterator = typename Data::iterator;
using ConstIterator = typename Data::const_iterator;
- using BackInsertIterator = typename std::back_insert_iterator;
explicit AbstractComponent(const AircraftInfo &aircraftInfo) noexcept
: m_aircraftInfo(aircraftInfo)
{}
+ AbstractComponent() noexcept;
+ AbstractComponent(const AbstractComponent &rhs) = default;
+ AbstractComponent(AbstractComponent &&rhs) = default;
+ AbstractComponent &operator=(const AbstractComponent &rhs) = default;
+ AbstractComponent &operator=(AbstractComponent &&rhs) = default;
virtual ~AbstractComponent() = default;
- AbstractComponent(const AbstractComponent &) = default;
- AbstractComponent(AbstractComponent &&other)
- : m_data (std::move(other.m_data)),
- m_aircraftInfo(std::move(other.m_aircraftInfo)),
- m_currentTimestamp(other.m_currentTimestamp),
- m_currentIndex(other.m_currentIndex),
- m_currentAccess(other.m_currentAccess)
- {}
- AbstractComponent &operator=(const AbstractComponent &rhs)
+ void setData(const Data &data) noexcept
{
- if (this != &rhs) {
- // Don't copy the reference member
- m_data = rhs.m_data;
- m_currentTimestamp = rhs.m_currentTimestamp;
- m_currentIndex = rhs.m_currentIndex;
- m_currentAccess = rhs.m_currentAccess;
- }
- return *this;
+ m_data = data;
}
- AbstractComponent &operator=(AbstractComponent &&rhs)
+ void setData(Data &&data) noexcept
{
- if (this != &rhs) {
- // Don't copy the reference member
- m_data = std::move(rhs.m_data);
- m_currentTimestamp = rhs.m_currentTimestamp;
- m_currentIndex = rhs.m_currentIndex;
- m_currentAccess = rhs.m_currentAccess;
- }
- return *this;
+ m_data = std::move(data);
}
/*!
@@ -94,11 +76,11 @@ class MODEL_API AbstractComponent
* the data to be upserted
* \sa upsert
*/
- void upsertLast(const T data) noexcept
+ void upsertLast(const T &data) noexcept
{
if (m_data.size() > 0 && m_data.back() == data) {
// Same timestamp -> replace
- m_data[m_data.size() - 1] = std::move(data);
+ m_data.back() = data;
} else {
m_data.push_back(std::move(data));
}
@@ -115,7 +97,7 @@ class MODEL_API AbstractComponent
* the data to be upserted
* \sa upsertLast
*/
- void upsert(const T data) noexcept
+ void upsert(const T &data) noexcept
{
auto result = std::find_if(m_data.begin(), m_data.end(),
[&data] (const TimeVariableData &d) { return d.timestamp == data.timestamp; });
@@ -127,22 +109,26 @@ class MODEL_API AbstractComponent
}
}
+ /*!
+ * Returns the first data element. The collection must have at least one element,
+ * otherwise the behaviour is undefined.
+ *
+ * \return the first element T of the collection
+ */
const T &getFirst() const noexcept
{
- if (!m_data.empty()) {
- return m_data.front();
- } else {
- return T::NullData;
- }
+ return m_data.front();
}
+ /*!
+ * Returns the last data element. The collection must have at least one element,
+ * otherwise the behaviour is undefined.
+ *
+ * \return the last element T of the collection
+ */
const T &getLast() const noexcept
{
- if (!m_data.empty()) {
- return m_data.back();
- } else {
- return T::NullData;
- }
+ return m_data.back();
}
[[nodiscard]]
@@ -178,11 +164,6 @@ class MODEL_API AbstractComponent
return m_data.cend();
}
- BackInsertIterator backInsertIterator() noexcept
- {
- return std::back_inserter(m_data);
- }
-
T &operator[](std::size_t index) noexcept
{
return m_data[index];
@@ -193,7 +174,7 @@ class MODEL_API AbstractComponent
return m_data[index];
}
- virtual const T &interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept = 0;
+ virtual T interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept = 0;
protected:
[[nodiscard]]
@@ -209,7 +190,7 @@ class MODEL_API AbstractComponent
}
[[nodiscard]]
- inline const std::int64_t getCurrentTimestamp() const noexcept
+ inline std::int64_t getCurrentTimestamp() const noexcept
{
return m_currentTimestamp;
}
@@ -219,7 +200,7 @@ class MODEL_API AbstractComponent
}
[[nodiscard]]
- inline const int getCurrentIndex() const noexcept
+ inline int getCurrentIndex() const noexcept
{
return m_currentIndex;
}
@@ -229,7 +210,7 @@ class MODEL_API AbstractComponent
}
[[nodiscard]]
- inline const TimeVariableData::Access getCurrentAccess() const noexcept
+ inline TimeVariableData::Access getCurrentAccess() const noexcept
{
return m_currentAccess;
}
diff --git a/src/Model/include/Model/Aircraft.h b/src/Model/include/Model/Aircraft.h
index ade0a40a1..39875c667 100644
--- a/src/Model/include/Model/Aircraft.h
+++ b/src/Model/include/Model/Aircraft.h
@@ -28,8 +28,6 @@
#include
#include
-#include
-
class QDateTime;
#include "ModelLib.h"
@@ -42,14 +40,18 @@ class SecondaryFlightControl;
class AircraftHandle;
class Light;
class FlightPlan;
-class AircraftPrivate;
+struct AircraftPrivate;
-class MODEL_API Aircraft : public QObject
+class MODEL_API Aircraft final
{
- Q_OBJECT
public:
- explicit Aircraft(QObject *parent = nullptr) noexcept;
- ~Aircraft() noexcept override;
+
+ Aircraft() noexcept;
+ Aircraft(const Aircraft &rhs) = delete;
+ Aircraft(Aircraft &&rhs);
+ Aircraft &operator=(const Aircraft &rhs) = delete;
+ Aircraft &operator=(Aircraft &&rhs);
+ ~Aircraft();
std::int64_t getId() const noexcept;
void setId(std::int64_t id) noexcept;
@@ -88,9 +90,6 @@ class MODEL_API Aircraft : public QObject
bool operator==(const Aircraft &rhs) const noexcept;
bool operator!=(const Aircraft &rhs) const noexcept;
- static constexpr std::int64_t InvalidId {-1};
-
-public slots:
/*!
* Invalidates the duration, such that it gets updated the next time
* #getDurationMSec is called.
@@ -102,32 +101,8 @@ public slots:
*/
void invalidateDuration() noexcept;
-signals:
- /*!
- * Emitted whenever the aircraft info has changed.
- */
- void infoChanged(const Aircraft &aircraft);
-
- /*!
- * Emitted whenever the tail number has changed.
- *
- * \param aircraft
- * the aircraft whose tail number has changed
- */
- void tailNumberChanged(const Aircraft &aircraft);
-
- /*!
- * Emitted whenever the aircraft's time offset has changed.
- *
- * \param aircraft
- * the aircraft whose time offset has changed
- */
- void timeOffsetChanged(const Aircraft &aircraft);
-
private:
std::unique_ptr d;
-
- void frenchConnection();
};
#endif // AIRCRAFT_H
diff --git a/src/Model/include/Model/AircraftHandle.h b/src/Model/include/Model/AircraftHandle.h
index b010baec0..22b4aeedd 100644
--- a/src/Model/include/Model/AircraftHandle.h
+++ b/src/Model/include/Model/AircraftHandle.h
@@ -34,20 +34,14 @@
#include "AbstractComponent.h"
#include "ModelLib.h"
-class MODEL_API AircraftHandle : public AbstractComponent
+class MODEL_API AircraftHandle final : public AbstractComponent
{
public:
explicit AircraftHandle(const AircraftInfo &aircraftInfo) noexcept;
- AircraftHandle(AircraftHandle &other) = default;
- AircraftHandle(AircraftHandle &&other) = default;
- ~AircraftHandle() noexcept override;
- AircraftHandle &operator=(const AircraftHandle &rhs) = default;
- AircraftHandle &operator=(AircraftHandle &&rhs) = default;
- const AircraftHandleData &interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept override;
+ AircraftHandleData interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept override;
private:
- AircraftHandleData m_currentAircraftHandleData;
AircraftHandleData m_previousAircraftHandleData;
};
diff --git a/src/Model/include/Model/AircraftHandleData.h b/src/Model/include/Model/AircraftHandleData.h
index f02f8d577..a894e6ee0 100644
--- a/src/Model/include/Model/AircraftHandleData.h
+++ b/src/Model/include/Model/AircraftHandleData.h
@@ -32,28 +32,19 @@
#include "TimeVariableData.h"
#include "ModelLib.h"
-struct MODEL_API AircraftHandleData : public TimeVariableData
+struct MODEL_API AircraftHandleData final : public TimeVariableData
{
- std::int16_t brakeLeftPosition;
- std::int16_t brakeRightPosition;
+ std::int16_t brakeLeftPosition {0};
+ std::int16_t brakeRightPosition {0};
// Implementation note: the water rudder can also have negative (-100.0) values,
// hence hence the type std::int16_t (position) which also supports negative values
- std::int16_t waterRudderHandlePosition;
- std::uint8_t tailhookPosition;
- std::uint8_t canopyOpen;
- std::uint8_t leftWingFolding;
- std::uint8_t rightWingFolding;
- bool gearHandlePosition;
- bool smokeEnabled;
-
- AircraftHandleData() noexcept;
- AircraftHandleData(const AircraftHandleData &other) = default;
- AircraftHandleData(AircraftHandleData &&other) = default;
- ~AircraftHandleData() override = default;
- AircraftHandleData &operator=(const AircraftHandleData &rhs) = default;
- AircraftHandleData &operator=(AircraftHandleData &&rhs) = default;
-
- static const AircraftHandleData NullData;
+ std::int16_t waterRudderHandlePosition {0};
+ std::uint8_t tailhookPosition {0};
+ std::uint8_t canopyOpen {0};
+ std::uint8_t leftWingFolding {0};
+ std::uint8_t rightWingFolding {0};
+ bool gearHandlePosition {false};
+ bool smokeEnabled {false};
};
#endif // AIRCRAFTHANDLEDATA_H
diff --git a/src/Model/include/Model/AircraftInfo.h b/src/Model/include/Model/AircraftInfo.h
index 6482721ce..82534ee66 100644
--- a/src/Model/include/Model/AircraftInfo.h
+++ b/src/Model/include/Model/AircraftInfo.h
@@ -32,27 +32,29 @@
#include "AircraftType.h"
#include "ModelLib.h"
-struct MODEL_API AircraftInfo
+struct MODEL_API AircraftInfo final
{
- std::int64_t aircraftId;
+ std::int64_t aircraftId {0};
AircraftType aircraftType;
// Milliseconds
- std::int64_t timeOffset;
+ std::int64_t timeOffset {0};
QString tailNumber;
QString airline;
QString flightNumber;
// Feet
- float altitudeAboveGround;
- bool startOnGround;
+ float altitudeAboveGround {0.0f};
+ bool startOnGround {false};
// Knots (TAS)
- int initialAirspeed;
+ int initialAirspeed {0};
AircraftInfo(std::int64_t aircraftId) noexcept;
- AircraftInfo(const AircraftInfo &other) = default;
- AircraftInfo(AircraftInfo &&other) noexcept;
+ AircraftInfo() noexcept;
+ AircraftInfo(const AircraftInfo &rhs) = default;
+ AircraftInfo(AircraftInfo &&rhs) = default;
AircraftInfo &operator=(const AircraftInfo &rhs) = default;
- AircraftInfo &operator=(AircraftInfo &&rhs) noexcept;
+ AircraftInfo &operator=(AircraftInfo &&rhs) = default;
+ ~AircraftInfo() = default;
void clear() noexcept;
};
diff --git a/src/Model/include/Model/AircraftType.h b/src/Model/include/Model/AircraftType.h
index 2e8f21c9f..b63cd243b 100644
--- a/src/Model/include/Model/AircraftType.h
+++ b/src/Model/include/Model/AircraftType.h
@@ -31,7 +31,7 @@
#include "SimType.h"
#include "ModelLib.h"
-struct MODEL_API AircraftType
+struct MODEL_API AircraftType final
{
/*!
* The aircraft type, e.g. "Pitts Special". This is really the SimConnect "container title"
@@ -49,16 +49,17 @@ struct MODEL_API AircraftType
*/
QString category;
// Feet
- int wingSpan;
- SimType::EngineType engineType;
- int numberOfEngines;
+ int wingSpan {0};
+ SimType::EngineType engineType {SimType::EngineType::Unknown};
+ int numberOfEngines {0};
- AircraftType() noexcept;
- ~AircraftType() = default;
- AircraftType(const AircraftType &other) = default;
- AircraftType(AircraftType &&other) noexcept;
+ AircraftType(QString type, QString category, int wingSpan, SimType::EngineType engineType, int numberOfEngines) noexcept;
+ AircraftType() = default;
+ AircraftType(const AircraftType &rhs) = default;
+ AircraftType(AircraftType &&rhs) = default;
AircraftType &operator=(const AircraftType &rhs) = default;
- AircraftType &operator=(AircraftType &&rhs) noexcept;
+ AircraftType &operator=(AircraftType &&rhs) = default;
+ ~AircraftType() = default;
void clear() noexcept;
};
diff --git a/src/Model/include/Model/Data.h b/src/Model/include/Model/Data.h
index 52644f10c..68ea0a9e4 100644
--- a/src/Model/include/Model/Data.h
+++ b/src/Model/include/Model/Data.h
@@ -27,6 +27,7 @@
#include
+#include
/*!
* The base data object for all non-time variant data objects which are persisted,
* identified by their \c id.
@@ -35,14 +36,16 @@
*/
struct Data
{
- explicit Data(std::int64_t id = InvalidId)
+ explicit Data(std::int64_t id = Const::InvalidId)
: id(id)
{}
+ Data(const Data &rhs) = default;
+ Data(Data &&rhs) = default;
+ Data &operator=(const Data &rhs) = default;
+ Data &operator=(Data &&rhs) = default;
virtual ~Data() = default;
- std::int64_t id {InvalidId};
-
- static constexpr std::int64_t InvalidId {-1};
+ std::int64_t id {Const::InvalidId};
};
#endif // DATA_H
diff --git a/src/Model/include/Model/Engine.h b/src/Model/include/Model/Engine.h
index d35e409ec..e204f7350 100644
--- a/src/Model/include/Model/Engine.h
+++ b/src/Model/include/Model/Engine.h
@@ -30,20 +30,12 @@
#include "AbstractComponent.h"
#include "ModelLib.h"
-class MODEL_API Engine : public AbstractComponent
+class MODEL_API Engine final : public AbstractComponent
{
public:
explicit Engine(const AircraftInfo &aircraftInfo) noexcept;
- Engine(Engine &other) = default;
- Engine(Engine &&other) = default;
- ~Engine() noexcept override;
- Engine &operator=(const Engine &rhs) = default;
- Engine &operator=(Engine &&rhs) = default;
- const EngineData &interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept override;
-
-private:
- EngineData m_currentEngineData;
+ EngineData interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept override;
};
#endif // ENGINE_H
diff --git a/src/Model/include/Model/EngineData.h b/src/Model/include/Model/EngineData.h
index 43f7a5763..667bd98d6 100644
--- a/src/Model/include/Model/EngineData.h
+++ b/src/Model/include/Model/EngineData.h
@@ -30,50 +30,44 @@
#include
#include
-#include "SimType.h"
#include "TimeVariableData.h"
#include "ModelLib.h"
-struct MODEL_API EngineData : public TimeVariableData
+struct MODEL_API EngineData final : public TimeVariableData
{
// Implementation note: the throttle and propeller levers can also yield
// negative thrust, hence the type std::int16_t (position) which also supports negative values
- std::int16_t throttleLeverPosition1;
- std::int16_t throttleLeverPosition2;
- std::int16_t throttleLeverPosition3;
- std::int16_t throttleLeverPosition4;
- std::int16_t propellerLeverPosition1;
- std::int16_t propellerLeverPosition2;
- std::int16_t propellerLeverPosition3;
- std::int16_t propellerLeverPosition4;
- std::uint8_t mixtureLeverPosition1;
- std::uint8_t mixtureLeverPosition2;
- std::uint8_t mixtureLeverPosition3;
- std::uint8_t mixtureLeverPosition4;
- std::uint8_t cowlFlapPosition1;
- std::uint8_t cowlFlapPosition2;
- std::uint8_t cowlFlapPosition3;
- std::uint8_t cowlFlapPosition4;
+ std::int16_t throttleLeverPosition1 {0};
+ std::int16_t throttleLeverPosition2 {0};
+ std::int16_t throttleLeverPosition3 {0};
+ std::int16_t throttleLeverPosition4 {0};
+ std::int16_t propellerLeverPosition1 {0};
+ std::int16_t propellerLeverPosition2 {0};
+ std::int16_t propellerLeverPosition3 {0};
+ std::int16_t propellerLeverPosition4 {0};
+ std::uint8_t mixtureLeverPosition1 {0};
+ std::uint8_t mixtureLeverPosition2 {0};
+ std::uint8_t mixtureLeverPosition3 {0};
+ std::uint8_t mixtureLeverPosition4 {0};
+ std::uint8_t cowlFlapPosition1 {0};
+ std::uint8_t cowlFlapPosition2 {0};
+ std::uint8_t cowlFlapPosition3 {0};
+ std::uint8_t cowlFlapPosition4 {0};
- bool electricalMasterBattery1;
- bool electricalMasterBattery2;
- bool electricalMasterBattery3;
- bool electricalMasterBattery4;
- bool generalEngineStarter1;
- bool generalEngineStarter2;
- bool generalEngineStarter3;
- bool generalEngineStarter4;
- bool generalEngineCombustion1;
- bool generalEngineCombustion2;
- bool generalEngineCombustion3;
- bool generalEngineCombustion4;
+ bool electricalMasterBattery1 {false};
+ bool electricalMasterBattery2 {false};
+ bool electricalMasterBattery3 {false};
+ bool electricalMasterBattery4 {false};
+ bool generalEngineStarter1 {false};
+ bool generalEngineStarter2 {false};
+ bool generalEngineStarter3 {false};
+ bool generalEngineStarter4 {false};
+ bool generalEngineCombustion1 {false};
+ bool generalEngineCombustion2 {false};
+ bool generalEngineCombustion3 {false};
+ bool generalEngineCombustion4 {false};
explicit EngineData(std::int16_t throttleLeverPosition1 = 0, std::int16_t propellerLeverPosition1 = 0, std::uint8_t mixtureLeverPosition1 = 0, std::uint8_t cowlFlapPosition1 = 0) noexcept;
- EngineData(const EngineData &other) = default;
- EngineData(EngineData &&other) = default;
- ~EngineData() override = default;
- EngineData &operator=(const EngineData &rhs) = default;
- EngineData &operator=(EngineData &&rhs) = default;
inline bool hasEngineStarterEnabled() const noexcept
{
@@ -84,8 +78,6 @@ struct MODEL_API EngineData : public TimeVariableData
{
return (generalEngineCombustion1 || generalEngineCombustion2 || generalEngineCombustion3 || generalEngineCombustion4);
}
-
- static const EngineData NullData;
};
#endif // ENGINEDATA_H
diff --git a/src/Model/include/Model/Enumeration.h b/src/Model/include/Model/Enumeration.h
index da2cd2c7b..56c3efd36 100644
--- a/src/Model/include/Model/Enumeration.h
+++ b/src/Model/include/Model/Enumeration.h
@@ -27,11 +27,9 @@
#include
#include
-#include
#include
-#include "InitialPosition.h"
#include "Data.h"
#include "ModelLib.h"
@@ -44,14 +42,16 @@ struct EnumerationPrivate;
*
* \sa Enum#toUnderlyingType
*/
-class MODEL_API Enumeration
+class MODEL_API Enumeration final
{
public:
-
- Enumeration(QString name) noexcept;
- Enumeration(Enumeration &&other) noexcept = default;
- ~Enumeration() noexcept;
- Enumeration &operator=(Enumeration &&rhs) noexcept = default;
+ Enumeration(const QString &name) noexcept;
+ Enumeration() noexcept;
+ Enumeration(const Enumeration &rhs) = delete;
+ Enumeration(Enumeration &&rhs);
+ Enumeration &operator=(const Enumeration &rhs) = delete;
+ Enumeration &operator=(Enumeration &&rhs);
+ ~Enumeration();
using Item = struct Item_ : public Data
{
diff --git a/src/Model/include/Model/Flight.h b/src/Model/include/Model/Flight.h
index c7a35e9cd..44b557d63 100644
--- a/src/Model/include/Model/Flight.h
+++ b/src/Model/include/Model/Flight.h
@@ -40,14 +40,19 @@ class QString;
#include "FlightCondition.h"
#include "ModelLib.h"
+struct Waypoint;
struct FlightPrivate;
-class MODEL_API Flight : public QObject
+class MODEL_API Flight final : public QObject
{
Q_OBJECT
public:
explicit Flight(QObject *parent = nullptr) noexcept;
- ~Flight() noexcept override;
+ Flight(const Flight &rhs) = delete;
+ Flight(Flight &&rhs) = delete;
+ Flight &operator=(const Flight &rhs) = delete;
+ Flight &operator=(Flight &&rhs) = delete;
+ ~Flight() override;
std::int64_t getId() const noexcept;
void setId(std::int64_t id) noexcept;
@@ -61,7 +66,7 @@ class MODEL_API Flight : public QObject
const QString &getDescription() const noexcept;
void setDescription(const QString &description) noexcept;
- void setAircraft(std::vector> aircraft) noexcept;
+ void setAircraft(std::vector &&aircraft) noexcept;
Aircraft &addUserAircraft() noexcept;
Aircraft &getUserAircraft() const noexcept;
@@ -116,6 +121,33 @@ class MODEL_API Flight : public QObject
std::int64_t deleteAircraftByIndex(int index) noexcept;
std::size_t count() const noexcept;
+ /*!
+ * Adds the \c waypoint to the flight plan of the user aircraft.
+ *
+ * \param waypoint
+ * the waypoint to be added to the flight plan of the user aircraft
+ * \sa waypointAdded
+ */
+ void addWaypoint(const Waypoint &waypoint) noexcept;
+
+ /*!
+ * Updates the waypoint at \c index with the given \c waypoint.
+ *
+ * \param index
+ * the index of the waypoint to be updated
+ * \param waypoint
+ * the waypoint data to update with
+ * \sa waypointUpdated
+ */
+ void updateWaypoint(int index, const Waypoint &waypoint) noexcept;
+
+ /*!
+ * Clears all waypoints of the flight plan of the user aircraft.
+ *
+ * \sa waypointsCleared
+ */
+ void clearWaypoints() noexcept;
+
const FlightCondition &getFlightCondition() const noexcept;
void setFlightCondition(FlightCondition flightCondition) noexcept;
@@ -145,7 +177,7 @@ class MODEL_API Flight : public QObject
void clear(bool withOneAircraft) noexcept;
- using Iterator = std::vector>::iterator;
+ using Iterator = std::vector::iterator;
Iterator begin() noexcept;
Iterator end() noexcept;
@@ -155,11 +187,6 @@ class MODEL_API Flight : public QObject
Aircraft &operator[](std::size_t index) noexcept;
const Aircraft &operator[](std::size_t index) const noexcept;
- /*!
- * The initial ID for every newly created flight. An invalid ID indicates that this
- * flight has not yet been (successfully) persisted.
- */
- static constexpr std::int64_t InvalidId {-1};
static constexpr int InvalidAircraftIndex {-1};
signals:
@@ -172,6 +199,30 @@ class MODEL_API Flight : public QObject
void aircraftAdded(const Aircraft &newAircraft);
void aircraftRemoved(std::int64_t removedAircraftId);
+ void infoChanged(const Aircraft &aircraft);
+
+ /*!
+ * Emitted whenever a new \c waypoint has been added to the user aircraft.
+ *
+ * \param waypoint
+ * the newly added waypoint
+ */
+ void waypointAdded(const Waypoint &waypoint);
+
+ /*!
+ * Emitted whenever the \c waypoint of the user aircraft at \c index has been udpated.
+ *
+ * \param index
+ * the index of the updated waypoint
+ * \param waypoint
+ * the updated waypoint
+ */
+ void waypointUpdated(int index, const Waypoint &waypoint);
+
+ /*!
+ * Emitted whenever all waypoints of the user aircraft have been cleared.
+ */
+ void waypointsCleared();
/*!
* Emitted whenever the user aircraft index is changed to \c newUserAircraftIndex. In case a previous user aircraft
@@ -209,8 +260,6 @@ class MODEL_API Flight : public QObject
private:
std::unique_ptr d;
- inline void connectWithAircraftSignals(Aircraft &aircraft);
-
/*
* Re-assigns the user aircraft \c index, but without emitting the \c userAircraftChanged signal.
* This is useful in case an aircraft with an index lower (<) than the current user aircraft
diff --git a/src/Model/include/Model/FlightCondition.h b/src/Model/include/Model/FlightCondition.h
index 4149647c3..2f37b5eb9 100644
--- a/src/Model/include/Model/FlightCondition.h
+++ b/src/Model/include/Model/FlightCondition.h
@@ -33,32 +33,25 @@
#include "SimType.h"
#include "ModelLib.h"
-struct MODEL_API FlightCondition
+struct MODEL_API FlightCondition final
{
- float groundAltitude;
- SimType::SurfaceType surfaceType;
- float ambientTemperature;
- float totalAirTemperature;
- float windSpeed;
- float windDirection;
- SimType::PrecipitationState precipitationState;
- float visibility;
- float seaLevelPressure;
- std::uint8_t pitotIcingPercent;
- std::uint8_t structuralIcingPercent;
- bool inClouds;
+ float groundAltitude {0.0f};
+ SimType::SurfaceType surfaceType {SimType::SurfaceType::Unknown};
+ float ambientTemperature {0.0f};
+ float totalAirTemperature {0.0f};
+ float windSpeed {0.0f};
+ float windDirection {0.0f};
+ SimType::PrecipitationState precipitationState {SimType::PrecipitationState::None};
+ float visibility {0.0f};
+ float seaLevelPressure {0.0f};
+ std::uint8_t pitotIcingPercent {0};
+ std::uint8_t structuralIcingPercent {0};
+ bool inClouds {false};
QDateTime startLocalTime;
QDateTime startZuluTime;
QDateTime endLocalTime;
QDateTime endZuluTime;
- FlightCondition() noexcept;
- FlightCondition(const FlightCondition &other) = default;
- FlightCondition(FlightCondition &&other) noexcept;
- ~FlightCondition() = default;
- FlightCondition &operator=(const FlightCondition &rhs) = default;
- FlightCondition &operator=(FlightCondition &&rhs) noexcept;
-
void clear() noexcept;
};
diff --git a/src/Model/include/Model/FlightDate.h b/src/Model/include/Model/FlightDate.h
index 0939f2476..124279daa 100644
--- a/src/Model/include/Model/FlightDate.h
+++ b/src/Model/include/Model/FlightDate.h
@@ -9,15 +9,9 @@
* Represents a date on which flights have been recorded, including
* the number of recorded flights on that date.
*/
-struct MODEL_API FlightDate
+struct MODEL_API FlightDate final
{
- FlightDate() noexcept = default;
FlightDate(int year, int month, int dayOfMonth, int nofFlights) noexcept;
- FlightDate(const FlightDate &other) = default;
- FlightDate(FlightDate &&other) = default;
- ~FlightDate() = default;
- FlightDate &operator=(const FlightDate &rhs) = default;
- FlightDate &operator=(FlightDate &&rhs) = default;
/*!
* The year of the flight: [1 - 9999]
diff --git a/src/Model/include/Model/FlightPlan.h b/src/Model/include/Model/FlightPlan.h
index 468f22bb1..8447919b6 100644
--- a/src/Model/include/Model/FlightPlan.h
+++ b/src/Model/include/Model/FlightPlan.h
@@ -30,21 +30,21 @@
#include
#include
-#include
-#include
-
#include "Waypoint.h"
#include "ModelLib.h"
-class Waypoint;
-class FlightPlanPrivate;
+struct Waypoint;
+struct FlightPlanPrivate;
-class MODEL_API FlightPlan : public QObject
+class MODEL_API FlightPlan final
{
- Q_OBJECT
public:
- explicit FlightPlan(QObject *parent = nullptr) noexcept;
- ~FlightPlan() noexcept override;
+ FlightPlan() noexcept;
+ FlightPlan(const FlightPlan &rhs) = delete;
+ FlightPlan(FlightPlan &&rhs);
+ FlightPlan &operator=(const FlightPlan &rhs) = delete;
+ FlightPlan &operator=(FlightPlan &&rhs);
+ ~FlightPlan();
void add(const Waypoint &waypoint) noexcept;
void update(int index, const Waypoint &waypoint) noexcept;
@@ -52,24 +52,16 @@ class MODEL_API FlightPlan : public QObject
void clear() noexcept;
using Iterator = std::vector::iterator;
- using BackInsertIterator = std::back_insert_iterator>;
Iterator begin() noexcept;
Iterator end() noexcept;
const Iterator begin() const noexcept;
const Iterator end() const noexcept;
- BackInsertIterator backInsertIterator() noexcept;
Waypoint &operator[](std::size_t index) noexcept;
const Waypoint &operator[](std::size_t index) const noexcept;
-signals:
- void waypointAdded(const Waypoint &waypoint);
- void waypointUpdated(int index, const Waypoint &waypoint);
- void waypointsCleared();
-
private:
- Q_DISABLE_COPY(FlightPlan)
std::unique_ptr d;
};
diff --git a/src/Model/include/Model/FlightSummary.h b/src/Model/include/Model/FlightSummary.h
index b3ef29dc9..933bb1607 100644
--- a/src/Model/include/Model/FlightSummary.h
+++ b/src/Model/include/Model/FlightSummary.h
@@ -25,26 +25,21 @@
#ifndef FLIGHTSUMMARY_H
#define FLIGHTSUMMARY_H
+#include "Kernel/Const.h"
#include
#include
#include
+#include
#include "ModelLib.h"
-struct MODEL_API FlightSummary
+struct MODEL_API FlightSummary final
{
- FlightSummary() noexcept;
- FlightSummary(const FlightSummary &other) = default;
- FlightSummary(FlightSummary &&other) noexcept;
- ~FlightSummary() noexcept;
- FlightSummary &operator=(const FlightSummary &rhs) = default;
- FlightSummary &operator=(FlightSummary &&rhs) noexcept;
-
- std::int64_t flightId;
+ std::int64_t flightId {Const::InvalidId};
QDateTime creationDate;
QString aircraftType;
- int aircraftCount;
+ std::size_t aircraftCount {0};
QDateTime startSimulationLocalTime;
QDateTime startSimulationZuluTime;
QDateTime endSimulationLocalTime;
diff --git a/src/Model/include/Model/InitialPosition.h b/src/Model/include/Model/InitialPosition.h
index aa6b44da5..790a5ab8f 100644
--- a/src/Model/include/Model/InitialPosition.h
+++ b/src/Model/include/Model/InitialPosition.h
@@ -37,25 +37,20 @@
struct AircraftInfo;
-struct MODEL_API InitialPosition
+struct MODEL_API InitialPosition final
{
- double latitude;
- double longitude;
- double altitude;
- double pitch;
- double bank;
- double trueHeading;
+ double latitude {0.0};
+ double longitude {0.0};
+ double altitude {0.0};
+ double pitch {0.0};
+ double bank {0.0};
+ double trueHeading {0.0};
// Indicated airspeed [knots]
- int indicatedAirspeed;
- bool onGround;
+ int indicatedAirspeed {InvalidIndicatedAirspeed};
+ bool onGround {false};
explicit InitialPosition(double latitude = 0.0, double longitude = 0.0, double altitude = 0.0) noexcept;
InitialPosition(const PositionData &positionData, const AircraftInfo &aircraftInfo) noexcept;
- InitialPosition(const InitialPosition &other) = default;
- InitialPosition(InitialPosition &&other) = default;
- ~InitialPosition() = default;
- InitialPosition &operator=(const InitialPosition &rhs) = default;
- InitialPosition &operator=(InitialPosition &&rhs) = default;
inline bool isNull() const noexcept {
return (indicatedAirspeed == InvalidIndicatedAirspeed);
@@ -73,7 +68,6 @@ struct MODEL_API InitialPosition
onGround = false;
}
- static const InitialPosition NullData;
static constexpr int InvalidIndicatedAirspeed = std::numeric_limits::min();
};
diff --git a/src/Model/include/Model/Light.h b/src/Model/include/Model/Light.h
index 2ba28ee2c..161f4e0aa 100644
--- a/src/Model/include/Model/Light.h
+++ b/src/Model/include/Model/Light.h
@@ -30,20 +30,12 @@
#include "AbstractComponent.h"
#include "ModelLib.h"
-class MODEL_API Light : public AbstractComponent
+class MODEL_API Light final : public AbstractComponent
{
public:
explicit Light(const AircraftInfo &aircraftInfo) noexcept;
- Light(Light &other) = default;
- Light(Light &&other) = default;
- ~Light() noexcept override;
- Light &operator=(const Light &rhs) = default;
- Light &operator=(Light &&rhs) = default;
- const LightData &interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept override;
-
-private:
- LightData m_currentLightData;
+ LightData interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept override;
};
#endif // LIGHT_H
diff --git a/src/Model/include/Model/LightData.h b/src/Model/include/Model/LightData.h
index 5e49bc265..ae4472c2d 100644
--- a/src/Model/include/Model/LightData.h
+++ b/src/Model/include/Model/LightData.h
@@ -32,18 +32,9 @@
#include "TimeVariableData.h"
#include "ModelLib.h"
-struct MODEL_API LightData : public TimeVariableData
+struct MODEL_API LightData final : public TimeVariableData
{
- SimType::LightStates lightStates;
-
- explicit LightData(SimType::LightStates lightStates = SimType::LightState::None) noexcept;
- LightData(const LightData &other) = default;
- LightData(LightData &&other) = default;
- ~LightData() override = default;
- LightData &operator=(const LightData &rhs) = default;
- LightData &operator=(LightData &&rhs) = default;
-
- static const LightData NullData;
+ SimType::LightStates lightStates {SimType::LightState::None};
};
#endif // LIGHTDATA_H
diff --git a/src/Model/include/Model/Location.h b/src/Model/include/Model/Location.h
index 9dfc3017b..ba747632f 100644
--- a/src/Model/include/Model/Location.h
+++ b/src/Model/include/Model/Location.h
@@ -27,17 +27,18 @@
#include
+#include
#include "InitialPosition.h"
#include "Data.h"
#include "ModelLib.h"
-struct MODEL_API Location : public Data
+struct MODEL_API Location final : public Data
{
QString title;
QString description;
- std::int64_t typeId {InvalidId};
- std::int64_t categoryId {InvalidId};
- std::int64_t countryId {InvalidId};
+ std::int64_t typeId {Const::InvalidId};
+ std::int64_t categoryId {Const::InvalidId};
+ std::int64_t countryId {Const::InvalidId};
/// \todo Use QFlags
std::int64_t attributes {0};
QString identifier;
@@ -52,11 +53,6 @@ struct MODEL_API Location : public Data
explicit Location(double latitude = 0.0, double longitude = 0.0, double altitude = 0.0) noexcept;
explicit Location(const InitialPosition &initialPosition) noexcept;
- Location(Location &other) = default;
- Location(Location &&other) = default;
- ~Location() noexcept override = default;
- Location &operator=(const Location &rhs) = default;
- Location &operator=(Location &&rhs) = default;
inline InitialPosition toInitialPosition() const noexcept {
InitialPosition initialPosition {latitude, longitude, altitude};
diff --git a/src/Model/include/Model/Logbook.h b/src/Model/include/Model/Logbook.h
index 1d1d19ca5..433737654 100644
--- a/src/Model/include/Model/Logbook.h
+++ b/src/Model/include/Model/Logbook.h
@@ -32,12 +32,17 @@
#include "Flight.h"
#include "ModelLib.h"
-class LogbookPrivate;
+struct LogbookPrivate;
-class MODEL_API Logbook : public QObject
+class MODEL_API Logbook final : public QObject
{
Q_OBJECT
public:
+ Logbook(const Logbook &rhs) = delete;
+ Logbook(Logbook &&rhs) = delete;
+ Logbook &operator=(const Logbook &rhs) = delete;
+ Logbook &operator=(Logbook &&rhs) = delete;
+
static Logbook &getInstance() noexcept;
static void destroyInstance() noexcept;
Flight &getCurrentFlight() const noexcept;
@@ -45,14 +50,11 @@ class MODEL_API Logbook : public QObject
signals:
void flightTitleOrDescriptionChanged(std::int64_t id);
-protected:
- ~Logbook() noexcept override;
-
private:
- Q_DISABLE_COPY(Logbook)
- std::unique_ptr d;
+ const std::unique_ptr d;
Logbook() noexcept;
+ ~Logbook() override;
};
#endif // LOGBOOK_H
diff --git a/src/Model/include/Model/Position.h b/src/Model/include/Model/Position.h
index d56d0ed05..e500616a9 100644
--- a/src/Model/include/Model/Position.h
+++ b/src/Model/include/Model/Position.h
@@ -30,20 +30,12 @@
#include "AbstractComponent.h"
#include "ModelLib.h"
-class MODEL_API Position : public AbstractComponent
+class MODEL_API Position final : public AbstractComponent
{
public:
explicit Position(const AircraftInfo &aircraftInfo) noexcept;
- Position(Position &other) = default;
- Position(Position &&other) = default;
- ~Position() noexcept override;
- Position &operator=(const Position &rhs) = default;
- Position &operator=(Position &&rhs) = default;
- const PositionData &interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept override;
-
-private:
- PositionData m_currentPositionData;
+ PositionData interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept override;
};
#endif // POSITION_H
diff --git a/src/Model/include/Model/PositionData.h b/src/Model/include/Model/PositionData.h
index e57fb084b..95e357c04 100644
--- a/src/Model/include/Model/PositionData.h
+++ b/src/Model/include/Model/PositionData.h
@@ -31,35 +31,28 @@
#include "TimeVariableData.h"
#include "ModelLib.h"
-struct MODEL_API PositionData : public TimeVariableData
+struct MODEL_API PositionData final : public TimeVariableData
{
// Position
- double latitude;
- double longitude;
+ double latitude {0.0};
+ double longitude {0.0};
// GPS altitude
- double altitude;
+ double altitude {0.0};
// Indicated pressure altitude (analytical purposes only)
- double indicatedAltitude;
- double pitch;
- double bank;
- double trueHeading;
+ double indicatedAltitude {0.0};
+ double pitch {0.0};
+ double bank {0.0};
+ double trueHeading {0.0};
// Velocity
- double velocityBodyX;
- double velocityBodyY;
- double velocityBodyZ;
- double rotationVelocityBodyX;
- double rotationVelocityBodyY;
- double rotationVelocityBodyZ;
+ double velocityBodyX {0.0};
+ double velocityBodyY {0.0};
+ double velocityBodyZ {0.0};
+ double rotationVelocityBodyX {0.0};
+ double rotationVelocityBodyY {0.0};
+ double rotationVelocityBodyZ {0.0};
explicit PositionData(double latitude = 0.0, double longitude = 0.0, double altitude = 0.0) noexcept;
- PositionData(const PositionData &other) = default;
- PositionData(PositionData &&other) = default;
- ~PositionData() override = default;
- PositionData &operator=(const PositionData &rhs) = default;
- PositionData &operator=(PositionData &&rhs) = default;
-
- static const PositionData NullData;
};
#endif // POSITIONDATA_H
diff --git a/src/Model/include/Model/PrimaryFlightControl.h b/src/Model/include/Model/PrimaryFlightControl.h
index 5a06e7d7b..5afbac972 100644
--- a/src/Model/include/Model/PrimaryFlightControl.h
+++ b/src/Model/include/Model/PrimaryFlightControl.h
@@ -30,20 +30,12 @@
#include "AbstractComponent.h"
#include "ModelLib.h"
-class MODEL_API PrimaryFlightControl : public AbstractComponent
+class MODEL_API PrimaryFlightControl final : public AbstractComponent
{
public:
explicit PrimaryFlightControl(const AircraftInfo &aircraftInfo) noexcept;
- PrimaryFlightControl(PrimaryFlightControl &other) = default;
- PrimaryFlightControl(PrimaryFlightControl &&other) = default;
- ~PrimaryFlightControl() noexcept override;
- PrimaryFlightControl &operator=(const PrimaryFlightControl &rhs) = default;
- PrimaryFlightControl &operator=(PrimaryFlightControl &&rhs) = default;
- const PrimaryFlightControlData &interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept override;
-
-private:
- PrimaryFlightControlData m_currentPrimaryFlightControlData;
+ PrimaryFlightControlData interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept override;
};
#endif // PRIMARYFLIGHTCONTROL_H
diff --git a/src/Model/include/Model/PrimaryFlightControlData.h b/src/Model/include/Model/PrimaryFlightControlData.h
index 669fdbabe..68759d5c9 100644
--- a/src/Model/include/Model/PrimaryFlightControlData.h
+++ b/src/Model/include/Model/PrimaryFlightControlData.h
@@ -30,24 +30,14 @@
#include
#include
-#include "SimType.h"
#include "TimeVariableData.h"
#include "ModelLib.h"
-struct MODEL_API PrimaryFlightControlData : public TimeVariableData
+struct MODEL_API PrimaryFlightControlData final : public TimeVariableData
{
- std::int16_t rudderPosition;
- std::int16_t elevatorPosition;
- std::int16_t aileronPosition;
-
- PrimaryFlightControlData() noexcept;
- PrimaryFlightControlData(const PrimaryFlightControlData &other) = default;
- PrimaryFlightControlData(PrimaryFlightControlData &&other) = default;
- ~PrimaryFlightControlData() override = default;
- PrimaryFlightControlData &operator=(const PrimaryFlightControlData &rhs) = default;
- PrimaryFlightControlData &operator=(PrimaryFlightControlData &&rhs) = default;
-
- static const PrimaryFlightControlData NullData;
+ std::int16_t rudderPosition {0};
+ std::int16_t elevatorPosition {0};
+ std::int16_t aileronPosition {0};
};
#endif // PRIMARYFLIGHTCONTROLDATA_H
diff --git a/src/Model/include/Model/SecondaryFlightControl.h b/src/Model/include/Model/SecondaryFlightControl.h
index f2a5cd303..708893c8f 100644
--- a/src/Model/include/Model/SecondaryFlightControl.h
+++ b/src/Model/include/Model/SecondaryFlightControl.h
@@ -30,20 +30,14 @@
#include "AbstractComponent.h"
#include "ModelLib.h"
-class MODEL_API SecondaryFlightControl : public AbstractComponent
+class MODEL_API SecondaryFlightControl final : public AbstractComponent
{
public:
explicit SecondaryFlightControl(const AircraftInfo &aircraftInfo) noexcept;
- SecondaryFlightControl(SecondaryFlightControl &other) = default;
- SecondaryFlightControl(SecondaryFlightControl &&other) = default;
- ~SecondaryFlightControl() noexcept override;
- SecondaryFlightControl &operator=(const SecondaryFlightControl &rhs) = default;
- SecondaryFlightControl &operator=(SecondaryFlightControl &&rhs) = default;
- const SecondaryFlightControlData &interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept override;
+ SecondaryFlightControlData interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept override;
private:
- SecondaryFlightControlData m_currentSecondaryFlightControlData;
SecondaryFlightControlData m_previousSecondaryFlightControlData;
};
diff --git a/src/Model/include/Model/SecondaryFlightControlData.h b/src/Model/include/Model/SecondaryFlightControlData.h
index 042716be8..4e2b663af 100644
--- a/src/Model/include/Model/SecondaryFlightControlData.h
+++ b/src/Model/include/Model/SecondaryFlightControlData.h
@@ -30,26 +30,18 @@
#include
#include
-#include "SimType.h"
#include "TimeVariableData.h"
#include "ModelLib.h"
-struct MODEL_API SecondaryFlightControlData : public TimeVariableData
+struct MODEL_API SecondaryFlightControlData final : public TimeVariableData
{
// Flaps & speed brakes
- std::int16_t leadingEdgeFlapsLeftPosition;
- std::int16_t leadingEdgeFlapsRightPosition;
- std::int16_t trailingEdgeFlapsLeftPosition;
- std::int16_t trailingEdgeFlapsRightPosition;
- std::int16_t spoilersHandlePosition;
- std::int8_t flapsHandleIndex;
-
- SecondaryFlightControlData() noexcept;
- SecondaryFlightControlData(const SecondaryFlightControlData &other) = default;
- SecondaryFlightControlData(SecondaryFlightControlData &&other) = default;
- SecondaryFlightControlData &operator=(const SecondaryFlightControlData &) = default;
-
- static const SecondaryFlightControlData NullData;
+ std::int16_t leadingEdgeFlapsLeftPosition {0};
+ std::int16_t leadingEdgeFlapsRightPosition {0};
+ std::int16_t trailingEdgeFlapsLeftPosition {0};
+ std::int16_t trailingEdgeFlapsRightPosition {0};
+ std::int16_t spoilersHandlePosition {0};
+ std::int8_t flapsHandleIndex {0};
};
#endif // SECONDARYFLIGHTCONTROLDATA_H
diff --git a/src/Model/include/Model/SimVar.h b/src/Model/include/Model/SimVar.h
index 320fceeae..decea7ef4 100644
--- a/src/Model/include/Model/SimVar.h
+++ b/src/Model/include/Model/SimVar.h
@@ -25,128 +25,126 @@
#ifndef SIMVAR_H
#define SIMVAR_H
-#include "ModelLib.h"
-
/*!
* Constants related to simulation variable names.
*/
namespace SimVar
{
// Simulation variables (SimConnect)
- constexpr char Latitude[] = "Plane Latitude";
- constexpr char Longitude[] = "Plane Longitude";
- constexpr char Altitude[] = "Plane Altitude";
- constexpr char IndicatedAltitude[] = "Indicated Altitude";
- constexpr char Pitch[] = "Plane Pitch Degrees";
- constexpr char Bank[] = "Plane Bank Degrees";
- constexpr char TrueHeading[] = "Plane Heading Degrees True";
-
- constexpr char VelocityBodyX[] = "Velocity Body X";
- constexpr char VelocityBodyY[] = "Velocity Body Y";
- constexpr char VelocityBodyZ[] = "Velocity Body Z";
- constexpr char RotationVelocityBodyX[] = "Rotation Velocity Body X";
- constexpr char RotationVelocityBodyY[] = "Rotation Velocity Body Y";
- constexpr char RotationVelocityBodyZ[] = "Rotation Velocity Body Z";
-
- constexpr char RudderPosition[] = "Rudder Position";
- constexpr char ElevatorPosition[] = "Elevator Position";
- constexpr char AileronPosition[] = "Aileron Position";
-
- constexpr char ThrottleLeverPosition1[] = "General Eng Throttle Lever Position:1";
- constexpr char ThrottleLeverPosition2[] = "General Eng Throttle Lever Position:2";
- constexpr char ThrottleLeverPosition3[] = "General Eng Throttle Lever Position:3";
- constexpr char ThrottleLeverPosition4[] = "General Eng Throttle Lever Position:4";
- constexpr char PropellerLeverPosition1[] = "General Eng Propeller Lever Position:1";
- constexpr char PropellerLeverPosition2[] = "General Eng Propeller Lever Position:2";
- constexpr char PropellerLeverPosition3[] = "General Eng Propeller Lever Position:3";
- constexpr char PropellerLeverPosition4[] = "General Eng Propeller Lever Position:4";
- constexpr char MixtureLeverPosition1[] = "General Eng Mixture Lever Position:1";
- constexpr char MixtureLeverPosition2[] = "General Eng Mixture Lever Position:2";
- constexpr char MixtureLeverPosition3[] = "General Eng Mixture Lever Position:3";
- constexpr char MixtureLeverPosition4[] = "General Eng Mixture Lever Position:4";
- constexpr char RecipEngineCowlFlapPosition1[] = "Recip Eng Cowl Flap Position:1";
- constexpr char RecipEngineCowlFlapPosition2[] = "Recip Eng Cowl Flap Position:2";
- constexpr char RecipEngineCowlFlapPosition3[] = "Recip Eng Cowl Flap Position:3";
- constexpr char RecipEngineCowlFlapPosition4[] = "Recip Eng Cowl Flap Position:4";
- constexpr char ElectricalMasterBattery1[] = "Electrical Master Battery:1";
- constexpr char ElectricalMasterBattery2[] = "Electrical Master Battery:2";
- constexpr char ElectricalMasterBattery3[] = "Electrical Master Battery:3";
- constexpr char ElectricalMasterBattery4[] = "Electrical Master Battery:4";
- constexpr char GeneralEngineStarter1[] = "General Eng Starter:1";
- constexpr char GeneralEngineStarter2[] = "General Eng Starter:2";
- constexpr char GeneralEngineStarter3[] = "General Eng Starter:3";
- constexpr char GeneralEngineStarter4[] = "General Eng Starter:4";
- constexpr char GeneralEngineCombustion1[] = "General Eng Combustion:1";
- constexpr char GeneralEngineCombustion2[] = "General Eng Combustion:2";
- constexpr char GeneralEngineCombustion3[] = "General Eng Combustion:3";
- constexpr char GeneralEngineCombustion4[] = "General Eng Combustion:4";
-
- constexpr char LeadingEdgeFlapsLeftPercent[] = "Leading Edge Flaps Left Percent";
- constexpr char LeadingEdgeFlapsRightPercent[] = "Leading Edge Flaps Right Percent";
- constexpr char TrailingEdgeFlapsLeftPercent[] = "Trailing Edge Flaps Left Percent";
- constexpr char TrailingEdgeFlapsRightPercent[] = "Trailing Edge Flaps Right Percent";
- constexpr char SpoilersHandlePosition[] = "Spoilers Handle Position";
- constexpr char FlapsHandleIndex[] = "Flaps Handle Index";
-
- constexpr char BrakeLeftPosition[] = "Brake Left Position";
- constexpr char BrakeRightPosition[] = "Brake Right Position";
- constexpr char WaterRudderHandlePosition[] = "Water Rudder Handle Position";
- constexpr char TailhookPosition[] = "Tailhook Position";
- constexpr char CanopyOpen[] = "Canopy Open";
- constexpr char GearHandlePosition[] = "Gear Handle Position";
- constexpr char SmokeEnable[] = "Smoke Enable";
- constexpr char FoldingWingLeftPercent[] = "Folding Wing Left Percent";
- constexpr char FoldingWingRightPercent[] = "Folding Wing Right Percent";
-
- constexpr char LightStates[] = "Light States";
-
- constexpr char Title[] = "Title";
- constexpr char ATCId[] = "ATC Id";
- constexpr char ATCAirline[] = "ATC Airline";
- constexpr char ATCFlightNumber[] = "ATC Flight Number";
- constexpr char Category[] = "Category";
-
- constexpr char SimOnGround[] = "Sim On Ground";
- constexpr char PlaneAltAboveGround[] = "Plane Alt Above Ground";
- constexpr char AirspeedTrue[] = "Airspeed True";
- constexpr char AirspeedIndicated[] = "Airspeed Indicated";
- constexpr char SurfaceType[] = "Surface Type";
- constexpr char WingSpan[] = "Wing Span";
- constexpr char NumberOfEngines[] = "Number Of Engines";
- constexpr char EngineType[] = "Engine Type";
-
- constexpr char GroundAltitude[] = "Ground Altitude";
- constexpr char AmbientTemperature[] = "Ambient Temperature";
- constexpr char TotalAirTemperature[] = "Total Air Temperature";
- constexpr char AmbientWindVelocity[] = "Ambient Wind Velocity";
- constexpr char AmbientWindDirection[] = "Ambient Wind Direction";
- constexpr char AmbientPrecipState[] = "Ambient Precip State";
- constexpr char AmbientInCloud[] = "Ambient In Cloud";
- constexpr char AmbientVisibility[] = "Ambient Visibility";
- constexpr char SeaLevelPressure[] = "Sea Level Pressure";
- constexpr char PitotIcePct[] = "Pitot Ice Pct";
- constexpr char StructuralIcePct[] = "Structural Ice Pct";
-
- constexpr char GpsWPNextId[] = "GPS WP Next Id";
- constexpr char GpsWPNextLat[] = "GPS WP Next Lat";
- constexpr char GpsWPNextLon[] = "GPS WP Next Lon";
- constexpr char GpsWPNextAlt[] = "GPS WP Next Alt";
- constexpr char GpsWPPrevId[] = "GPS WP Prev Id";
- constexpr char GpsWPPrevLat[] = "GPS WP Prev Lat";
- constexpr char GpsWPPrevLon[] = "GPS WP Prev Lon";
- constexpr char GpsWPPrevAlt[] = "GPS WP Prev Alt";
-
- constexpr char LocalTime[] = "Local Time";
- constexpr char LocalYear[] = "Local Year";
- constexpr char LocalMonthOfYear[] = "Local Month of Year";
- constexpr char LocalDayOfMonth[] = "Local Day of Month";
-
- constexpr char ZuluTime[] = "Zulu Time";
- constexpr char ZuluYear[] = "Zulu Year";
- constexpr char ZuluMonthOfYear[] = "Zulu Month of Year";
- constexpr char ZuluDayOfMonth[] = "Zulu Day of Month";
-
- constexpr char Timestamp[] = "Timestamp";
+ constexpr const char *Latitude = "Plane Latitude";
+ constexpr const char *Longitude = "Plane Longitude";
+ constexpr const char *Altitude = "Plane Altitude";
+ constexpr const char *IndicatedAltitude = "Indicated Altitude";
+ constexpr const char *Pitch = "Plane Pitch Degrees";
+ constexpr const char *Bank = "Plane Bank Degrees";
+ constexpr const char *TrueHeading = "Plane Heading Degrees True";
+
+ constexpr const char *VelocityBodyX = "Velocity Body X";
+ constexpr const char *VelocityBodyY = "Velocity Body Y";
+ constexpr const char *VelocityBodyZ = "Velocity Body Z";
+ constexpr const char *RotationVelocityBodyX = "Rotation Velocity Body X";
+ constexpr const char *RotationVelocityBodyY = "Rotation Velocity Body Y";
+ constexpr const char *RotationVelocityBodyZ = "Rotation Velocity Body Z";
+
+ constexpr const char *RudderPosition = "Rudder Position";
+ constexpr const char *ElevatorPosition = "Elevator Position";
+ constexpr const char *AileronPosition = "Aileron Position";
+
+ constexpr const char *ThrottleLeverPosition1 = "General Eng Throttle Lever Position:1";
+ constexpr const char *ThrottleLeverPosition2 = "General Eng Throttle Lever Position:2";
+ constexpr const char *ThrottleLeverPosition3 = "General Eng Throttle Lever Position:3";
+ constexpr const char *ThrottleLeverPosition4 = "General Eng Throttle Lever Position:4";
+ constexpr const char *PropellerLeverPosition1 = "General Eng Propeller Lever Position:1";
+ constexpr const char *PropellerLeverPosition2 = "General Eng Propeller Lever Position:2";
+ constexpr const char *PropellerLeverPosition3 = "General Eng Propeller Lever Position:3";
+ constexpr const char *PropellerLeverPosition4 = "General Eng Propeller Lever Position:4";
+ constexpr const char *MixtureLeverPosition1 = "General Eng Mixture Lever Position:1";
+ constexpr const char *MixtureLeverPosition2 = "General Eng Mixture Lever Position:2";
+ constexpr const char *MixtureLeverPosition3 = "General Eng Mixture Lever Position:3";
+ constexpr const char *MixtureLeverPosition4 = "General Eng Mixture Lever Position:4";
+ constexpr const char *RecipEngineCowlFlapPosition1 = "Recip Eng Cowl Flap Position:1";
+ constexpr const char *RecipEngineCowlFlapPosition2 = "Recip Eng Cowl Flap Position:2";
+ constexpr const char *RecipEngineCowlFlapPosition3 = "Recip Eng Cowl Flap Position:3";
+ constexpr const char *RecipEngineCowlFlapPosition4 = "Recip Eng Cowl Flap Position:4";
+ constexpr const char *ElectricalMasterBattery1 = "Electrical Master Battery:1";
+ constexpr const char *ElectricalMasterBattery2 = "Electrical Master Battery:2";
+ constexpr const char *ElectricalMasterBattery3 = "Electrical Master Battery:3";
+ constexpr const char *ElectricalMasterBattery4 = "Electrical Master Battery:4";
+ constexpr const char *GeneralEngineStarter1 = "General Eng Starter:1";
+ constexpr const char *GeneralEngineStarter2 = "General Eng Starter:2";
+ constexpr const char *GeneralEngineStarter3 = "General Eng Starter:3";
+ constexpr const char *GeneralEngineStarter4 = "General Eng Starter:4";
+ constexpr const char *GeneralEngineCombustion1 = "General Eng Combustion:1";
+ constexpr const char *GeneralEngineCombustion2 = "General Eng Combustion:2";
+ constexpr const char *GeneralEngineCombustion3 = "General Eng Combustion:3";
+ constexpr const char *GeneralEngineCombustion4 = "General Eng Combustion:4";
+
+ constexpr const char *LeadingEdgeFlapsLeftPercent = "Leading Edge Flaps Left Percent";
+ constexpr const char *LeadingEdgeFlapsRightPercent = "Leading Edge Flaps Right Percent";
+ constexpr const char *TrailingEdgeFlapsLeftPercent = "Trailing Edge Flaps Left Percent";
+ constexpr const char *TrailingEdgeFlapsRightPercent = "Trailing Edge Flaps Right Percent";
+ constexpr const char *SpoilersHandlePosition = "Spoilers Handle Position";
+ constexpr const char *FlapsHandleIndex = "Flaps Handle Index";
+
+ constexpr const char *BrakeLeftPosition = "Brake Left Position";
+ constexpr const char *BrakeRightPosition = "Brake Right Position";
+ constexpr const char *WaterRudderHandlePosition = "Water Rudder Handle Position";
+ constexpr const char *TailhookPosition = "Tailhook Position";
+ constexpr const char *CanopyOpen = "Canopy Open";
+ constexpr const char *GearHandlePosition = "Gear Handle Position";
+ constexpr const char *SmokeEnable = "Smoke Enable";
+ constexpr const char *FoldingWingLeftPercent = "Folding Wing Left Percent";
+ constexpr const char *FoldingWingRightPercent = "Folding Wing Right Percent";
+
+ constexpr const char *LightStates = "Light States";
+
+ constexpr const char *Title = "Title";
+ constexpr const char *ATCId = "ATC Id";
+ constexpr const char *ATCAirline = "ATC Airline";
+ constexpr const char *ATCFlightNumber = "ATC Flight Number";
+ constexpr const char *Category = "Category";
+
+ constexpr const char *SimOnGround = "Sim On Ground";
+ constexpr const char *PlaneAltAboveGround = "Plane Alt Above Ground";
+ constexpr const char *AirspeedTrue = "Airspeed True";
+ constexpr const char *AirspeedIndicated = "Airspeed Indicated";
+ constexpr const char *SurfaceType = "Surface Type";
+ constexpr const char *WingSpan = "Wing Span";
+ constexpr const char *NumberOfEngines = "Number Of Engines";
+ constexpr const char *EngineType = "Engine Type";
+
+ constexpr const char *GroundAltitude = "Ground Altitude";
+ constexpr const char *AmbientTemperature = "Ambient Temperature";
+ constexpr const char *TotalAirTemperature = "Total Air Temperature";
+ constexpr const char *AmbientWindVelocity = "Ambient Wind Velocity";
+ constexpr const char *AmbientWindDirection = "Ambient Wind Direction";
+ constexpr const char *AmbientPrecipState = "Ambient Precip State";
+ constexpr const char *AmbientInCloud = "Ambient In Cloud";
+ constexpr const char *AmbientVisibility = "Ambient Visibility";
+ constexpr const char *SeaLevelPressure = "Sea Level Pressure";
+ constexpr const char *PitotIcePct = "Pitot Ice Pct";
+ constexpr const char *StructuralIcePct = "Structural Ice Pct";
+
+ constexpr const char *GpsWPNextId = "GPS WP Next Id";
+ constexpr const char *GpsWPNextLat = "GPS WP Next Lat";
+ constexpr const char *GpsWPNextLon = "GPS WP Next Lon";
+ constexpr const char *GpsWPNextAlt = "GPS WP Next Alt";
+ constexpr const char *GpsWPPrevId = "GPS WP Prev Id";
+ constexpr const char *GpsWPPrevLat = "GPS WP Prev Lat";
+ constexpr const char *GpsWPPrevLon = "GPS WP Prev Lon";
+ constexpr const char *GpsWPPrevAlt = "GPS WP Prev Alt";
+
+ constexpr const char *LocalTime = "Local Time";
+ constexpr const char *LocalYear = "Local Year";
+ constexpr const char *LocalMonthOfYear = "Local Month of Year";
+ constexpr const char *LocalDayOfMonth = "Local Day of Month";
+
+ constexpr const char *ZuluTime = "Zulu Time";
+ constexpr const char *ZuluYear = "Zulu Year";
+ constexpr const char *ZuluMonthOfYear = "Zulu Month of Year";
+ constexpr const char *ZuluDayOfMonth = "Zulu Day of Month";
+
+ constexpr const char *Timestamp = "Timestamp";
}
#endif // SIMVAR_H
diff --git a/src/Model/include/Model/SkySearch.h b/src/Model/include/Model/SkySearch.h
index 7a08ebc1b..0c84d03f0 100644
--- a/src/Model/include/Model/SkySearch.h
+++ b/src/Model/include/Model/SkySearch.h
@@ -31,7 +31,6 @@
#include
#include "TimeVariableData.h"
-#include "PositionData.h"
namespace SkySearch {
@@ -81,7 +80,7 @@ namespace SkySearch {
template
int binaryIntervalSearch(const std::vector &data, std::int64_t timestamp, int lowIndex, int highIndex) noexcept
{
- int index;
+ int index {InvalidIndex};
if (data.size() == 0) {
index = InvalidIndex;
} else if (data.at(lowIndex).timestamp > timestamp) {
@@ -93,8 +92,6 @@ namespace SkySearch {
} else if (data.back().timestamp == timestamp) {
index = data.size() - 1;
} else {
-
- index = InvalidIndex;
int low = lowIndex;
int high = highIndex;
while (low <= high)
@@ -126,7 +123,7 @@ namespace SkySearch {
template
int linearIntervalSearch(const std::vector &data, std::int64_t timestamp, int startIndex) noexcept
{
- int index;
+ int index {startIndex};
if (data.size() == 0) {
index = InvalidIndex;
} else if (data.at(startIndex).timestamp > timestamp) {
@@ -134,7 +131,6 @@ namespace SkySearch {
} else if (data.back().timestamp < timestamp) {
index = InvalidIndex;
} else {
- index = startIndex;
int size = data.size();
// Linear search: increment the current index, until we find a position having a
// timestamp > the given timestamp
@@ -163,7 +159,7 @@ namespace SkySearch {
template
int updateStartIndex(const std::vector &data, int startIndex, std::int64_t timestamp) noexcept
{
- int index = startIndex;
+ int index {startIndex};
int size = data.size();
if (size > 0) {
if (timestamp < data.back().timestamp) {
@@ -201,8 +197,8 @@ namespace SkySearch {
} else {
// The given timestamp lies "in the past" and could really be anywwhere
// -> binary search in the past
- int low;
- int high;
+ auto low {0};
+ auto high {data.size() - 1};
if (startIndex != InvalidIndex) {
if (timestamp < data.at(startIndex).timestamp) {
// Search in "the past"
@@ -213,10 +209,6 @@ namespace SkySearch {
low = startIndex;
high = data.size() - 1;
}
- } else {
- // index not yet initialised -> search entire timeline
- low = 0;
- high = data.size() - 1;
}
index = binaryIntervalSearch(data, timestamp, low, high);
}
diff --git a/src/Model/include/Model/TimeVariableData.h b/src/Model/include/Model/TimeVariableData.h
index 4de46d8b0..6e04da8a7 100644
--- a/src/Model/include/Model/TimeVariableData.h
+++ b/src/Model/include/Model/TimeVariableData.h
@@ -28,12 +28,16 @@
#include
#include
-#include "SimType.h"
#include "ModelLib.h"
struct MODEL_API TimeVariableData
{
- static constexpr std::int64_t InvalidTime = std::numeric_limits::min();
+ TimeVariableData() = default;
+ TimeVariableData(const TimeVariableData &rhs) = default;
+ TimeVariableData(TimeVariableData &&rhs) = default;
+ TimeVariableData &operator=(const TimeVariableData &rhs) = default;
+ TimeVariableData &operator=(TimeVariableData &&rhs) = default;
+ virtual ~TimeVariableData() = default;
/*!
* Defines the way (use case) the sampled data is accessed.
@@ -48,19 +52,28 @@ struct MODEL_API TimeVariableData
};
// In milliseconds since the start of recording
- std::int64_t timestamp;
-
- TimeVariableData() noexcept;
- TimeVariableData(const TimeVariableData &other) = default;
- TimeVariableData(TimeVariableData &&other) = default;
- virtual ~TimeVariableData() noexcept;
- TimeVariableData &operator=(const TimeVariableData &rhs) = default;
- TimeVariableData &operator=(TimeVariableData &&rhs) = default;
+ std::int64_t timestamp {InvalidTime};
+ /*!
+ * Returns whether this data is considered \enull data.
+ *
+ * \return \c true if this data is \enull (invalid) data; \c false else
+ * \sa reset
+ */
inline bool isNull() const noexcept {
return (timestamp == InvalidTime);
}
+ /*!
+ * Resets this data such that it is considered \e null data afterwards.
+ *
+ * \sa isNull
+ */
+ inline void reset() noexcept
+ {
+ timestamp = InvalidTime;
+ }
+
friend inline bool operator==(const TimeVariableData &lhs, const TimeVariableData &rhs) noexcept
{
return lhs.timestamp == rhs.timestamp;
@@ -75,6 +88,9 @@ struct MODEL_API TimeVariableData
{
return !(lhs >= rhs);
}
+
+ static constexpr std::int64_t InvalidTime = std::numeric_limits::min();
+
};
#endif // TIMEVARIABLEDATA_H
diff --git a/src/Model/include/Model/Waypoint.h b/src/Model/include/Model/Waypoint.h
index e7ccc598c..7f7e2f48a 100644
--- a/src/Model/include/Model/Waypoint.h
+++ b/src/Model/include/Model/Waypoint.h
@@ -29,25 +29,19 @@
#include
#include
-#include "SimType.h"
#include "TimeVariableData.h"
#include "ModelLib.h"
-struct MODEL_API Waypoint : public TimeVariableData
+struct MODEL_API Waypoint final : public TimeVariableData
{
QString identifier;
- float latitude;
- float longitude;
- float altitude;
QDateTime localTime;
QDateTime zuluTime;
+ float latitude {0.0};
+ float longitude {0.0};
+ float altitude {0.0};
explicit Waypoint(float latitude = 0.0f, float longitude = 0.0f, float altitude = 0.0f) noexcept;
- Waypoint(const Waypoint &other) = default;
- Waypoint(Waypoint &&other) noexcept;
- ~Waypoint() override = default;
- Waypoint &operator=(const Waypoint &rhs) = default;
- Waypoint &operator=(Waypoint &&rhs) noexcept;
/*!
* Returns whether this waypoint is valid or not.
@@ -56,11 +50,11 @@ struct MODEL_API Waypoint : public TimeVariableData
*/
bool isValid() const noexcept;
- // Note: declaring the constants as "inline" (with initialisation in the header)
- // apparently won't make them accessible from outside this library (DLL)
+ // Note: declaring the constant as "inline" (with initialisation in the header)
+ // apparently won't make the Waypoint accessible from outside this library (DLL)
static const Waypoint NullWaypoint;
- static const char CustomDepartureIdentifier[];
- static const char CustomArrivalIdentifier[];
+ static constexpr const char *CustomDepartureIdentifier {"CUSTD"};
+ static constexpr const char *CustomArrivalIdentifier {"CUSTA"};
};
#endif // WAYPOINT_H
diff --git a/src/Model/src/Aircraft.cpp b/src/Model/src/Aircraft.cpp
index f3c8c9d13..b33f09831 100644
--- a/src/Model/src/Aircraft.cpp
+++ b/src/Model/src/Aircraft.cpp
@@ -27,13 +27,8 @@
#include
#include
-#include
-#ifdef DEBUG
-#include
-#endif
-
+#include
#include "TimeVariableData.h"
-#include "SkySearch.h"
#include "AircraftInfo.h"
#include "Position.h"
#include "PositionData.h"
@@ -50,17 +45,11 @@
#include "FlightPlan.h"
#include "Aircraft.h"
-class AircraftPrivate
+struct AircraftPrivate
{
public:
- AircraftPrivate() noexcept
- : id(Aircraft::InvalidId),
- aircraftInfo(id),
- duration(TimeVariableData::InvalidTime)
- {}
-
- std::int64_t id;
- AircraftInfo aircraftInfo;
+ std::int64_t id {Const::InvalidId};
+ AircraftInfo aircraftInfo {id};
Position position{aircraftInfo};
Engine engine{aircraftInfo};
PrimaryFlightControl primaryFlightControl{aircraftInfo};
@@ -69,27 +58,18 @@ class AircraftPrivate
Light light{aircraftInfo};
FlightPlan flightPlan;
- mutable std::int64_t duration;
+ mutable std::int64_t duration {TimeVariableData::InvalidTime};
};
// PUBLIC
-Aircraft::Aircraft(QObject *parent) noexcept
- : QObject(parent),
- d(std::make_unique())
-{
- frenchConnection();
-#ifdef DEBUG
- qDebug() << "Aircraft::Aircraft: CREATED, ID:" << d->id;
-#endif
-}
+Aircraft::Aircraft() noexcept
+ : d(std::make_unique())
+{}
-Aircraft::~Aircraft() noexcept
-{
-#ifdef DEBUG
- qDebug() << "Aircraft::~Aircraft: DELETED, ID:" << d->id;
-#endif
-}
+Aircraft::Aircraft(Aircraft &&rhs) = default;
+Aircraft &Aircraft::operator=(Aircraft &&rhs) = default;
+Aircraft::~Aircraft() = default;
std::int64_t Aircraft::getId() const noexcept
{
@@ -144,17 +124,11 @@ const AircraftInfo &Aircraft::getAircraftInfo() const noexcept
void Aircraft::setAircraftInfo(const AircraftInfo &aircraftInfo) noexcept
{
- if (d->aircraftInfo != aircraftInfo) {
- d->aircraftInfo = aircraftInfo;
- emit infoChanged(*this);
- }
+ d->aircraftInfo = aircraftInfo;
}
void Aircraft::setTailNumber(const QString &tailNumber) noexcept {
- if (d->aircraftInfo.tailNumber != tailNumber) {
- d->aircraftInfo.tailNumber = tailNumber;
- emit tailNumberChanged(*this);
- }
+ d->aircraftInfo.tailNumber = tailNumber;
}
std::int64_t Aircraft::getTimeOffset() const noexcept
@@ -163,10 +137,8 @@ std::int64_t Aircraft::getTimeOffset() const noexcept
}
void Aircraft::setTimeOffset(std::int64_t timeOffset) noexcept {
- if (d->aircraftInfo.timeOffset != timeOffset) {
- d->aircraftInfo.timeOffset = timeOffset;
- emit timeOffsetChanged(*this);
- }
+ d->aircraftInfo.timeOffset = timeOffset;
+ invalidateDuration();
}
std::int64_t Aircraft::getDurationMSec() const noexcept
@@ -233,17 +205,3 @@ void Aircraft::invalidateDuration() noexcept
{
d->duration = TimeVariableData::InvalidTime;
}
-
-// PRIVATE
-
-void Aircraft::frenchConnection()
-{
- // Tail number
- connect(this, &Aircraft::tailNumberChanged,
- this, &Aircraft::infoChanged);
- // Timestamp offset
- connect(this, &Aircraft::timeOffsetChanged,
- this, &Aircraft::invalidateDuration);
- connect(this, &Aircraft::timeOffsetChanged,
- this, &Aircraft::infoChanged);
-}
diff --git a/src/Model/src/AircraftHandle.cpp b/src/Model/src/AircraftHandle.cpp
index db3ee0b2e..0680c627d 100644
--- a/src/Model/src/AircraftHandle.cpp
+++ b/src/Model/src/AircraftHandle.cpp
@@ -25,10 +25,6 @@
#include
#include
-#ifdef DEBUG
-#include
-#endif
-
#include
#include
#include "TimeVariableData.h"
@@ -41,21 +37,11 @@
AircraftHandle::AircraftHandle(const AircraftInfo &aircraftInfo) noexcept
: AbstractComponent(aircraftInfo)
-{
-#ifdef DEBUG
- qDebug() << "AircraftHandle::AircraftHandle: CREATED";
-#endif
-}
-
-AircraftHandle::~AircraftHandle() noexcept
-{
-#ifdef DEBUG
- qDebug() << "AircraftHandle::AircraftHandle: DELETED";
-#endif
-}
+{}
-const AircraftHandleData &AircraftHandle::interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept
+AircraftHandleData AircraftHandle::interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept
{
+ AircraftHandleData aircraftHandleData;
const AircraftHandleData *p1 {nullptr}, *p2 {nullptr};
const std::int64_t timeOffset = access != TimeVariableData::Access::Export ? getAircraftInfo().timeOffset : 0;
const std::int64_t adjustedTimestamp = std::max(timestamp + timeOffset, std::int64_t(0));
@@ -87,39 +73,36 @@ const AircraftHandleData &AircraftHandle::interpolate(std::int64_t timestamp, Ti
}
if (p1 != nullptr) {
- m_currentAircraftHandleData.brakeLeftPosition = SkyMath::interpolateLinear(p1->brakeLeftPosition, p2->brakeLeftPosition, tn);
- m_currentAircraftHandleData.brakeRightPosition = SkyMath::interpolateLinear(p1->brakeRightPosition, p2->brakeRightPosition, tn);
- m_currentAircraftHandleData.waterRudderHandlePosition = SkyMath::interpolateLinear(p1->waterRudderHandlePosition, p2->waterRudderHandlePosition, tn);
- m_currentAircraftHandleData.tailhookPosition = SkyMath::interpolateLinear(p1->tailhookPosition, p2->tailhookPosition, tn);
- m_currentAircraftHandleData.canopyOpen = SkyMath::interpolateLinear(p1->canopyOpen, p2->canopyOpen, tn);
- m_currentAircraftHandleData.leftWingFolding = SkyMath::interpolateLinear(p1->leftWingFolding, p2->leftWingFolding, tn);
- m_currentAircraftHandleData.rightWingFolding = SkyMath::interpolateLinear(p1->rightWingFolding, p2->rightWingFolding, tn);
- m_currentAircraftHandleData.gearHandlePosition = p1->gearHandlePosition;
- m_currentAircraftHandleData.smokeEnabled = p1->smokeEnabled;
- m_currentAircraftHandleData.timestamp = adjustedTimestamp;
+ aircraftHandleData.brakeLeftPosition = SkyMath::interpolateLinear(p1->brakeLeftPosition, p2->brakeLeftPosition, tn);
+ aircraftHandleData.brakeRightPosition = SkyMath::interpolateLinear(p1->brakeRightPosition, p2->brakeRightPosition, tn);
+ aircraftHandleData.waterRudderHandlePosition = SkyMath::interpolateLinear(p1->waterRudderHandlePosition, p2->waterRudderHandlePosition, tn);
+ aircraftHandleData.tailhookPosition = SkyMath::interpolateLinear(p1->tailhookPosition, p2->tailhookPosition, tn);
+ aircraftHandleData.canopyOpen = SkyMath::interpolateLinear(p1->canopyOpen, p2->canopyOpen, tn);
+ aircraftHandleData.leftWingFolding = SkyMath::interpolateLinear(p1->leftWingFolding, p2->leftWingFolding, tn);
+ aircraftHandleData.rightWingFolding = SkyMath::interpolateLinear(p1->rightWingFolding, p2->rightWingFolding, tn);
+ aircraftHandleData.gearHandlePosition = p1->gearHandlePosition;
+ aircraftHandleData.smokeEnabled = p1->smokeEnabled;
+ aircraftHandleData.timestamp = adjustedTimestamp;
// Certain aircraft override the CANOPY OPEN, so values need to be repeatedly set
if (Settings::getInstance().isRepeatCanopyOpenEnabled()) {
// We do that my storing the previous values (when the canopy is "open")...
- m_previousAircraftHandleData = m_currentAircraftHandleData;
+ m_previousAircraftHandleData = aircraftHandleData;
} else {
// "Repeat values" setting disabled
- m_previousAircraftHandleData = AircraftHandleData::NullData;
+ m_previousAircraftHandleData = AircraftHandleData();
}
} else if (!m_previousAircraftHandleData.isNull()) {
// ... and send the previous values again
- m_currentAircraftHandleData = m_previousAircraftHandleData;
- m_currentAircraftHandleData.timestamp = adjustedTimestamp;
- } else {
- // No recorded data, or the timestamp exceeds the timestamp of the last recorded position
- m_currentAircraftHandleData = AircraftHandleData::NullData;
+ aircraftHandleData = m_previousAircraftHandleData;
+ aircraftHandleData.timestamp = adjustedTimestamp;
}
setCurrentIndex(currentIndex);
setCurrentTimestamp(adjustedTimestamp);
setCurrentAccess(access);
}
- return m_currentAircraftHandleData;
+ return aircraftHandleData;
}
template class AbstractComponent;
diff --git a/src/Model/src/AircraftHandleData.cpp b/src/Model/src/AircraftHandleData.cpp
deleted file mode 100644
index 2a2d51e34..000000000
--- a/src/Model/src/AircraftHandleData.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Sky Dolly - The Black Sheep for Your Flight Recordings
- *
- * Copyright (c) Oliver Knoll
- * All rights reserved.
- *
- * MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this
- * software and associated documentation files (the "Software"), to deal in the Software
- * without restriction, including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
- * to whom the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
- * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
- * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-#include "TimeVariableData.h"
-#include "AircraftHandleData.h"
-
-// PUBLIC
-
-AircraftHandleData::AircraftHandleData() noexcept
- : TimeVariableData(),
- brakeLeftPosition(0),
- brakeRightPosition(0),
- waterRudderHandlePosition(0),
- tailhookPosition(0),
- canopyOpen(0),
- leftWingFolding(0),
- rightWingFolding(0),
- gearHandlePosition(false),
- smokeEnabled(false)
-{}
-
-const AircraftHandleData AircraftHandleData::NullData = AircraftHandleData();
diff --git a/src/Model/src/AircraftInfo.cpp b/src/Model/src/AircraftInfo.cpp
index 4ad77c922..99eb2f9b0 100644
--- a/src/Model/src/AircraftInfo.cpp
+++ b/src/Model/src/AircraftInfo.cpp
@@ -27,47 +27,14 @@
#include
-#include "AircraftType.h"
#include "AircraftInfo.h"
// PUBLIC
AircraftInfo::AircraftInfo(std::int64_t theAircraftId) noexcept
- : aircraftId(theAircraftId),
- timeOffset(0),
- altitudeAboveGround(0.0f),
- startOnGround(false),
- initialAirspeed(0)
+ : aircraftId(theAircraftId)
{}
-AircraftInfo::AircraftInfo(AircraftInfo &&other) noexcept
- : aircraftId(other.aircraftId),
- aircraftType(std::move(other.aircraftType)),
- timeOffset(other.timeOffset),
- tailNumber(std::move(other.tailNumber)),
- airline(std::move(other.airline)),
- flightNumber(std::move(other.flightNumber)),
- altitudeAboveGround(other.altitudeAboveGround),
- startOnGround(other.startOnGround),
- initialAirspeed(other.initialAirspeed)
-{}
-
-AircraftInfo &AircraftInfo::operator=(AircraftInfo &&rhs) noexcept
-{
- if (this != &rhs) {
- aircraftId = rhs.aircraftId;
- aircraftType = std::move(rhs.aircraftType),
- timeOffset = rhs.timeOffset,
- tailNumber = std::move(rhs.tailNumber),
- airline = std::move(rhs.airline),
- flightNumber = std::move(rhs.flightNumber),
- altitudeAboveGround = rhs.altitudeAboveGround,
- startOnGround = rhs.startOnGround,
- initialAirspeed = rhs.initialAirspeed;
- }
- return *this;
-}
-
void AircraftInfo::clear() noexcept
{
*this = AircraftInfo(aircraftId);
diff --git a/src/Model/src/AircraftType.cpp b/src/Model/src/AircraftType.cpp
index e77c1ff28..69ba8fd7d 100644
--- a/src/Model/src/AircraftType.cpp
+++ b/src/Model/src/AircraftType.cpp
@@ -28,31 +28,9 @@
// PUBLIC
-AircraftType::AircraftType() noexcept
- : wingSpan(0),
- engineType(SimType::EngineType::Unknown),
- numberOfEngines(0)
-{}
-
-AircraftType::AircraftType(AircraftType &&other) noexcept
- : type(std::move(other.type)),
- category(std::move(other.category)),
- wingSpan(other.wingSpan),
- engineType(other.engineType),
- numberOfEngines(other.numberOfEngines)
-{}
-
-AircraftType &AircraftType::operator=(AircraftType &&rhs) noexcept
-{
- if (this != &rhs) {
- type = std::move(rhs.type);
- category = std::move(rhs.category);
- wingSpan = rhs.wingSpan;
- engineType = rhs.engineType;
- numberOfEngines = rhs.numberOfEngines;
- }
- return *this;
-}
+AircraftType::AircraftType(QString type, QString category, int wingSpan, SimType::EngineType engineType, int numberOfEngines) noexcept
+ : type(type), category(category), wingSpan(wingSpan), engineType(engineType), numberOfEngines(numberOfEngines)
+{};
void AircraftType::clear() noexcept
{
diff --git a/src/Model/src/Data.cpp b/src/Model/src/Data.cpp
deleted file mode 100644
index 439728104..000000000
--- a/src/Model/src/Data.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Sky Dolly - The Black Sheep for Your Flight Recordings
- *
- * Copyright (c) Oliver Knoll
- * All rights reserved.
- *
- * MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this
- * software and associated documentation files (the "Software"), to deal in the Software
- * without restriction, including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
- * to whom the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
- * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
- * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
diff --git a/src/Model/src/Engine.cpp b/src/Model/src/Engine.cpp
index d24296baa..c95224c82 100644
--- a/src/Model/src/Engine.cpp
+++ b/src/Model/src/Engine.cpp
@@ -25,10 +25,6 @@
#include
#include
-#ifdef DEBUG
-#include
-#endif
-
#include
#include "TimeVariableData.h"
#include "SkySearch.h"
@@ -40,21 +36,11 @@
Engine::Engine(const AircraftInfo &aircraftInfo) noexcept
: AbstractComponent(aircraftInfo)
-{
-#ifdef DEBUG
- qDebug() << "Engine::Engine: CREATED";
-#endif
-}
-
-Engine::~Engine() noexcept
-{
-#ifdef DEBUG
- qDebug() << "Engine::Engine: DELETED";
-#endif
-}
+{}
-const EngineData &Engine::interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept
+EngineData Engine::interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept
{
+ EngineData engineData;
const EngineData *p1 {nullptr}, *p2 {nullptr};
const std::int64_t timeOffset = access != TimeVariableData::Access::Export ? getAircraftInfo().timeOffset : 0;
const std::int64_t adjustedTimestamp = std::max(timestamp + timeOffset, std::int64_t(0));
@@ -86,48 +72,45 @@ const EngineData &Engine::interpolate(std::int64_t timestamp, TimeVariableData::
}
if (p1 != nullptr) {
- m_currentEngineData.throttleLeverPosition1 = SkyMath::interpolateLinear(p1->throttleLeverPosition1, p2->throttleLeverPosition1, tn);
- m_currentEngineData.throttleLeverPosition2 = SkyMath::interpolateLinear(p1->throttleLeverPosition2, p2->throttleLeverPosition2, tn);
- m_currentEngineData.throttleLeverPosition3 = SkyMath::interpolateLinear(p1->throttleLeverPosition3, p2->throttleLeverPosition3, tn);
- m_currentEngineData.throttleLeverPosition4 = SkyMath::interpolateLinear(p1->throttleLeverPosition4, p2->throttleLeverPosition4, tn);
- m_currentEngineData.propellerLeverPosition1 = SkyMath::interpolateLinear(p1->propellerLeverPosition1, p2->propellerLeverPosition1, tn);
- m_currentEngineData.propellerLeverPosition2 = SkyMath::interpolateLinear(p1->propellerLeverPosition2, p2->propellerLeverPosition2, tn);
- m_currentEngineData.propellerLeverPosition3 = SkyMath::interpolateLinear(p1->propellerLeverPosition3, p2->propellerLeverPosition3, tn);
- m_currentEngineData.propellerLeverPosition4 = SkyMath::interpolateLinear(p1->propellerLeverPosition4, p2->propellerLeverPosition4, tn);
- m_currentEngineData.mixtureLeverPosition1 = SkyMath::interpolateLinear(p1->mixtureLeverPosition1, p2->mixtureLeverPosition1, tn);
- m_currentEngineData.mixtureLeverPosition2 = SkyMath::interpolateLinear(p1->mixtureLeverPosition2, p2->mixtureLeverPosition2, tn);
- m_currentEngineData.mixtureLeverPosition3 = SkyMath::interpolateLinear(p1->mixtureLeverPosition3, p2->mixtureLeverPosition3, tn);
- m_currentEngineData.mixtureLeverPosition4 = SkyMath::interpolateLinear(p1->mixtureLeverPosition4, p2->mixtureLeverPosition4, tn);
- m_currentEngineData.cowlFlapPosition1 = SkyMath::interpolateLinear(p1->cowlFlapPosition1, p2->cowlFlapPosition1, tn);
- m_currentEngineData.cowlFlapPosition2 = SkyMath::interpolateLinear(p1->cowlFlapPosition2, p2->cowlFlapPosition2, tn);
- m_currentEngineData.cowlFlapPosition3 = SkyMath::interpolateLinear(p1->cowlFlapPosition3, p2->cowlFlapPosition3, tn);
- m_currentEngineData.cowlFlapPosition4 = SkyMath::interpolateLinear(p1->cowlFlapPosition4, p2->cowlFlapPosition4, tn);
+ engineData.throttleLeverPosition1 = SkyMath::interpolateLinear(p1->throttleLeverPosition1, p2->throttleLeverPosition1, tn);
+ engineData.throttleLeverPosition2 = SkyMath::interpolateLinear(p1->throttleLeverPosition2, p2->throttleLeverPosition2, tn);
+ engineData.throttleLeverPosition3 = SkyMath::interpolateLinear(p1->throttleLeverPosition3, p2->throttleLeverPosition3, tn);
+ engineData.throttleLeverPosition4 = SkyMath::interpolateLinear(p1->throttleLeverPosition4, p2->throttleLeverPosition4, tn);
+ engineData.propellerLeverPosition1 = SkyMath::interpolateLinear(p1->propellerLeverPosition1, p2->propellerLeverPosition1, tn);
+ engineData.propellerLeverPosition2 = SkyMath::interpolateLinear(p1->propellerLeverPosition2, p2->propellerLeverPosition2, tn);
+ engineData.propellerLeverPosition3 = SkyMath::interpolateLinear(p1->propellerLeverPosition3, p2->propellerLeverPosition3, tn);
+ engineData.propellerLeverPosition4 = SkyMath::interpolateLinear(p1->propellerLeverPosition4, p2->propellerLeverPosition4, tn);
+ engineData.mixtureLeverPosition1 = SkyMath::interpolateLinear(p1->mixtureLeverPosition1, p2->mixtureLeverPosition1, tn);
+ engineData.mixtureLeverPosition2 = SkyMath::interpolateLinear(p1->mixtureLeverPosition2, p2->mixtureLeverPosition2, tn);
+ engineData.mixtureLeverPosition3 = SkyMath::interpolateLinear(p1->mixtureLeverPosition3, p2->mixtureLeverPosition3, tn);
+ engineData.mixtureLeverPosition4 = SkyMath::interpolateLinear(p1->mixtureLeverPosition4, p2->mixtureLeverPosition4, tn);
+ engineData.cowlFlapPosition1 = SkyMath::interpolateLinear(p1->cowlFlapPosition1, p2->cowlFlapPosition1, tn);
+ engineData.cowlFlapPosition2 = SkyMath::interpolateLinear(p1->cowlFlapPosition2, p2->cowlFlapPosition2, tn);
+ engineData.cowlFlapPosition3 = SkyMath::interpolateLinear(p1->cowlFlapPosition3, p2->cowlFlapPosition3, tn);
+ engineData.cowlFlapPosition4 = SkyMath::interpolateLinear(p1->cowlFlapPosition4, p2->cowlFlapPosition4, tn);
// No interpolation for battery and starter/combustion states (boolean)
- m_currentEngineData.electricalMasterBattery1 = p1->electricalMasterBattery1;
- m_currentEngineData.electricalMasterBattery2 = p1->electricalMasterBattery2;
- m_currentEngineData.electricalMasterBattery3 = p1->electricalMasterBattery3;
- m_currentEngineData.electricalMasterBattery4 = p1->electricalMasterBattery4;
- m_currentEngineData.generalEngineStarter1 = p1->generalEngineStarter1;
- m_currentEngineData.generalEngineStarter2 = p1->generalEngineStarter2;
- m_currentEngineData.generalEngineStarter3 = p1->generalEngineStarter3;
- m_currentEngineData.generalEngineStarter4 = p1->generalEngineStarter4;
- m_currentEngineData.generalEngineCombustion1 = p1->generalEngineCombustion1;
- m_currentEngineData.generalEngineCombustion2 = p1->generalEngineCombustion2;
- m_currentEngineData.generalEngineCombustion3 = p1->generalEngineCombustion3;
- m_currentEngineData.generalEngineCombustion4 = p1->generalEngineCombustion4;
+ engineData.electricalMasterBattery1 = p1->electricalMasterBattery1;
+ engineData.electricalMasterBattery2 = p1->electricalMasterBattery2;
+ engineData.electricalMasterBattery3 = p1->electricalMasterBattery3;
+ engineData.electricalMasterBattery4 = p1->electricalMasterBattery4;
+ engineData.generalEngineStarter1 = p1->generalEngineStarter1;
+ engineData.generalEngineStarter2 = p1->generalEngineStarter2;
+ engineData.generalEngineStarter3 = p1->generalEngineStarter3;
+ engineData.generalEngineStarter4 = p1->generalEngineStarter4;
+ engineData.generalEngineCombustion1 = p1->generalEngineCombustion1;
+ engineData.generalEngineCombustion2 = p1->generalEngineCombustion2;
+ engineData.generalEngineCombustion3 = p1->generalEngineCombustion3;
+ engineData.generalEngineCombustion4 = p1->generalEngineCombustion4;
- m_currentEngineData.timestamp = adjustedTimestamp;
- } else {
- // No recorded data, or the timestamp exceeds the timestamp of the last recorded position
- m_currentEngineData = EngineData::NullData;
+ engineData.timestamp = adjustedTimestamp;
}
setCurrentIndex(currentIndex);
setCurrentTimestamp(adjustedTimestamp);
setCurrentAccess(access);
}
- return m_currentEngineData;
+ return engineData;
}
-template class AbstractComponent;
\ No newline at end of file
+template class AbstractComponent;
diff --git a/src/Model/src/EngineData.cpp b/src/Model/src/EngineData.cpp
index a494e9c8a..98a5ba2a1 100644
--- a/src/Model/src/EngineData.cpp
+++ b/src/Model/src/EngineData.cpp
@@ -32,33 +32,7 @@
EngineData::EngineData(std::int16_t theThrottleLeverPosition1, std::int16_t thePropellerLeverPosition1, std::uint8_t theMixtureLeverPosition1, std::uint8_t theCowlFlapPosition1) noexcept
: TimeVariableData(),
throttleLeverPosition1(theThrottleLeverPosition1),
- throttleLeverPosition2(0),
- throttleLeverPosition3(0),
- throttleLeverPosition4(0),
propellerLeverPosition1(thePropellerLeverPosition1),
- propellerLeverPosition2(0),
- propellerLeverPosition3(0),
- propellerLeverPosition4(0),
mixtureLeverPosition1(theMixtureLeverPosition1),
- mixtureLeverPosition2(0),
- mixtureLeverPosition3(0),
- mixtureLeverPosition4(0),
- cowlFlapPosition1(theCowlFlapPosition1),
- cowlFlapPosition2(0),
- cowlFlapPosition3(0),
- cowlFlapPosition4(0),
- electricalMasterBattery1(false),
- electricalMasterBattery2(false),
- electricalMasterBattery3(false),
- electricalMasterBattery4(false),
- generalEngineStarter1(false),
- generalEngineStarter2(false),
- generalEngineStarter3(false),
- generalEngineStarter4(false),
- generalEngineCombustion1(false),
- generalEngineCombustion2(false),
- generalEngineCombustion3(false),
- generalEngineCombustion4(false)
+ cowlFlapPosition1(theCowlFlapPosition1)
{}
-
-const EngineData EngineData::NullData = EngineData();
diff --git a/src/Model/src/Enumeration.cpp b/src/Model/src/Enumeration.cpp
index d88066ea7..e662e164f 100644
--- a/src/Model/src/Enumeration.cpp
+++ b/src/Model/src/Enumeration.cpp
@@ -27,15 +27,13 @@
#include
#include
-#ifdef DEBUG
-#include
-#endif
+#include
#include "Enumeration.h"
struct EnumerationPrivate
{
- EnumerationPrivate(QString theName) noexcept
+ EnumerationPrivate(const QString &theName) noexcept
: name(theName)
{}
@@ -49,20 +47,17 @@ struct EnumerationPrivate
// PUBLIC
-Enumeration::Enumeration(QString name) noexcept
+Enumeration::Enumeration() noexcept
+ : d(std::make_unique(QString()))
+{}
+
+Enumeration::Enumeration(const QString &name) noexcept
: d(std::make_unique(name))
-{
-#ifdef DEBUG
- qDebug() << "Enumeration::Enumeration: CREATED, name:" << d->name;
-#endif
-}
+{}
-Enumeration::~Enumeration() noexcept
-{
-#ifdef DEBUG
- qDebug() << "Enumeration::Enumeration: DELETED, name:" << d->name;
-#endif
-}
+Enumeration::Enumeration(Enumeration &&rhs) = default;
+Enumeration &Enumeration::operator=(Enumeration &&rhs) = default;
+Enumeration::~Enumeration() = default;
QString Enumeration::getName() const noexcept
{
diff --git a/src/Model/src/Flight.cpp b/src/Model/src/Flight.cpp
index 16002fba9..12a676558 100644
--- a/src/Model/src/Flight.cpp
+++ b/src/Model/src/Flight.cpp
@@ -35,6 +35,7 @@
#include
#endif
+#include
#include "FlightCondition.h"
#include "Aircraft.h"
#include "FlightPlan.h"
@@ -49,16 +50,16 @@ struct FlightPrivate
clear(true);
}
- std::int64_t id {Flight::InvalidId};
+ std::int64_t id {Const::InvalidId};
QDateTime creationTime {QDateTime::currentDateTime()};
QString title;
QString description;
FlightCondition flightCondition;
- std::vector> aircraft;
+ std::vector aircraft;
int userAircraftIndex {Flight::InvalidAircraftIndex};
inline void clear(bool withOneAircraft) noexcept {
- id = Flight::InvalidId;
+ id = Const::InvalidId;
title.clear();
description.clear();
flightCondition.clear();
@@ -71,7 +72,7 @@ struct FlightPrivate
// it is newly allocated (the aircraft is only added in the constructor body)
// or cleared just before loading a flight
if (aircraft.size() > 0) {
- aircraft.at(0)->clear();
+ aircraft.at(0).clear();
}
}
};
@@ -84,17 +85,9 @@ Flight::Flight(QObject *parent) noexcept
{
// A flight always has at least one (user) aircraft
addUserAircraft();
-#ifdef DEBUG
- qDebug() << "Flight::Flight: CREATED, ID:" << d->id;
-#endif
}
-Flight::~Flight() noexcept
-{
-#ifdef DEBUG
- qDebug() << "Flight::~Flight: DELETED, ID:" << d->id;
-#endif
-}
+Flight::~Flight() = default;
void Flight::setId(std::int64_t id) noexcept
{
@@ -142,36 +135,32 @@ void Flight::setDescription(const QString &description) noexcept
}
}
-void Flight::setAircraft(std::vector> aircraft) noexcept
+void Flight::setAircraft(std::vector &&aircraft) noexcept
{
d->aircraft = std::move(aircraft);
for (auto &aircraft : d->aircraft) {
- emit aircraftAdded(*aircraft.get());
- connectWithAircraftSignals(*aircraft.get());
+ emit aircraftAdded(aircraft);
}
}
Aircraft &Flight::addUserAircraft() noexcept
{
- std::unique_ptr aircraft = std::make_unique();
- connectWithAircraftSignals(*aircraft.get());
-
- d->aircraft.push_back(std::move(aircraft));
+ d->aircraft.push_back(Aircraft());
switchUserAircraftIndex(static_cast(d->aircraft.size()) - 1);
- emit aircraftAdded(*d->aircraft.back().get());
- return *d->aircraft.back().get();
+ emit aircraftAdded(d->aircraft.back());
+ return d->aircraft.back();
}
Aircraft &Flight::getUserAircraft() const noexcept
{
- return *d->aircraft.at(d->userAircraftIndex);
+ return d->aircraft.at(d->userAircraftIndex);
}
int Flight::getAircraftIndex(const Aircraft &aircraft) const noexcept
{
- std::int64_t index {InvalidAircraftIndex};
+ int index {InvalidAircraftIndex};
const auto it = std::find_if(d->aircraft.cbegin(), d->aircraft.cend(),
- [&aircraft](const std::unique_ptr &a) { return a->getId() == aircraft.getId(); });
+ [&aircraft](const Aircraft &a) { return a.getId() == aircraft.getId(); });
if (it != d->aircraft.cend()) {
index = static_cast(std::distance(d->aircraft.cbegin(), it));
}
@@ -202,10 +191,10 @@ void Flight::switchUserAircraftIndex(int index) noexcept
std::int64_t Flight::deleteAircraftByIndex(int index) noexcept
{
- std::int64_t aircraftId {Aircraft::InvalidId};
+ std::int64_t aircraftId {Const::InvalidId};
// A flight has at least one aircraft
if (d->aircraft.size() > 1) {
- aircraftId = d->aircraft.at(index)->getId();
+ aircraftId = d->aircraft.at(index).getId();
if (index < d->userAircraftIndex) {
// An aircraft with a lower index or the user aircraft index itself
// is to be removed -> re-assign the user aircraft index accordingly
@@ -226,6 +215,24 @@ std::size_t Flight::count() const noexcept
return d->aircraft.size();
}
+void Flight::addWaypoint(const Waypoint &waypoint) noexcept
+{
+ getUserAircraft().getFlightPlan().add(waypoint);
+ emit waypointAdded(waypoint);
+}
+
+void Flight::updateWaypoint(int index, const Waypoint &waypoint) noexcept
+{
+ getUserAircraft().getFlightPlan().update(index, waypoint);
+ emit waypointUpdated(index, waypoint);
+}
+
+void Flight::clearWaypoints() noexcept
+{
+ getUserAircraft().getFlightPlan().clear();
+ emit waypointsCleared();
+}
+
const FlightCondition &Flight::getFlightCondition() const noexcept
{
return d->flightCondition;
@@ -271,7 +278,7 @@ std::int64_t Flight::getTotalDurationMSec(bool ofUserAircraft) const noexcept
totalDuractionMSec = getUserAircraft().getDurationMSec();
} else {
for (const auto &aircraft : d->aircraft) {
- totalDuractionMSec = std::max(aircraft->getDurationMSec(), totalDuractionMSec);
+ totalDuractionMSec = std::max(aircraft.getDurationMSec(), totalDuractionMSec);
}
}
return totalDuractionMSec;
@@ -300,6 +307,7 @@ void Flight::clear(bool withOneAircraft) noexcept
// Only emit the signals if the flight has at least one aircraft
// (but e.g. not shortly before loading a new flight from the logbook)
emit cleared();
+ emit waypointsCleared();
emit descriptionOrTitleChanged();
}
}
@@ -328,26 +336,16 @@ const Flight::Iterator Flight::end() const noexcept
Aircraft &Flight::operator[](std::size_t index) noexcept
{
- return *d->aircraft[index];
+ return d->aircraft[index];
}
const Aircraft &Flight::operator[](std::size_t index) const noexcept
{
- return *d->aircraft[index];
+ return d->aircraft[index];
}
// PRIVATE
-inline void Flight::connectWithAircraftSignals(Aircraft &aircraft)
-{
- connect(&aircraft, &Aircraft::infoChanged,
- this, &Flight::aircraftInfoChanged);
- connect(&aircraft, &Aircraft::tailNumberChanged,
- this, &Flight::tailNumberChanged);
- connect(&aircraft, &Aircraft::timeOffsetChanged,
- this, &Flight::timeOffsetChanged);
-}
-
void Flight::reassignUserAircraftIndex(std::int64_t index) noexcept
{
d->userAircraftIndex = index;
diff --git a/src/Model/src/FlightCondition.cpp b/src/Model/src/FlightCondition.cpp
index 97176f9e2..3d603cd53 100644
--- a/src/Model/src/FlightCondition.cpp
+++ b/src/Model/src/FlightCondition.cpp
@@ -22,70 +22,10 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
-#include
-
-#include "SimType.h"
#include "FlightCondition.h"
// PUBLIC
-FlightCondition::FlightCondition() noexcept
- : groundAltitude{0.0f},
- surfaceType{SimType::SurfaceType::Unknown},
- ambientTemperature{0.0f},
- totalAirTemperature{0.0f},
- windSpeed{0.0f},
- windDirection{0.0f},
- precipitationState{SimType::PrecipitationState::None},
- visibility{0.0f},
- seaLevelPressure{0.0f},
- pitotIcingPercent{0},
- structuralIcingPercent{0},
- inClouds{false}
-{}
-
-FlightCondition::FlightCondition(FlightCondition &&other) noexcept
- : groundAltitude(other.groundAltitude),
- surfaceType(other.surfaceType),
- ambientTemperature(other.ambientTemperature),
- totalAirTemperature(other.totalAirTemperature),
- windSpeed(other.windSpeed),
- windDirection(other.windDirection),
- precipitationState(other.precipitationState),
- visibility(other.visibility),
- seaLevelPressure(other.seaLevelPressure),
- pitotIcingPercent(other.pitotIcingPercent),
- structuralIcingPercent(other.structuralIcingPercent),
- inClouds(other.inClouds),
- startLocalTime(std::move(other.startLocalTime)),
- startZuluTime(std::move(other.startZuluTime)),
- endLocalTime(std::move(other.endLocalTime)),
- endZuluTime(std::move(other.endZuluTime))
-{}
-
-FlightCondition &FlightCondition::operator=(FlightCondition &&rhs) noexcept
-{
- if (this != &rhs) {
- groundAltitude = rhs.groundAltitude;
- surfaceType = rhs.surfaceType;
- ambientTemperature = rhs.ambientTemperature;
- totalAirTemperature = rhs.totalAirTemperature;
- windSpeed = rhs.windSpeed;
- windDirection = rhs.windDirection;
- precipitationState = rhs.precipitationState;
- visibility = rhs.visibility;
- seaLevelPressure = rhs.seaLevelPressure;
- pitotIcingPercent = rhs.pitotIcingPercent;
- structuralIcingPercent = rhs.structuralIcingPercent;
- inClouds = rhs.inClouds;
- startLocalTime = std::move(rhs.startLocalTime);
- startZuluTime = std::move(rhs.startZuluTime);
- endLocalTime = std::move(rhs.endLocalTime);
- endZuluTime = std::move(rhs.endZuluTime);
- }
- return *this;
-}
-
void FlightCondition::clear() noexcept
{
*this = FlightCondition();
diff --git a/src/Model/src/FlightPlan.cpp b/src/Model/src/FlightPlan.cpp
index 11a2c4715..46013b1d8 100644
--- a/src/Model/src/FlightPlan.cpp
+++ b/src/Model/src/FlightPlan.cpp
@@ -32,29 +32,24 @@
#include "Waypoint.h"
#include "FlightPlan.h"
-class FlightPlanPrivate
+struct FlightPlanPrivate
{
-public:
- FlightPlanPrivate() noexcept
- {}
-
std::vector waypoints;
};
// PUBLIC
-FlightPlan::FlightPlan(QObject *parent) noexcept
- : QObject(parent),
- d(std::make_unique())
+FlightPlan::FlightPlan() noexcept
+ : d(std::make_unique())
{}
-FlightPlan::~FlightPlan() noexcept
-{}
+FlightPlan::FlightPlan(FlightPlan &&rhs) = default;
+FlightPlan &FlightPlan::operator=(FlightPlan &&rhs) = default;
+FlightPlan::~FlightPlan() = default;
void FlightPlan::add(const Waypoint &waypoint) noexcept
{
d->waypoints.push_back(waypoint);
- emit waypointAdded(waypoint);
}
void FlightPlan::update(int index, const Waypoint &waypoint) noexcept
@@ -89,7 +84,6 @@ void FlightPlan::update(int index, const Waypoint &waypoint) noexcept
}
if (changed) {
d->waypoints[index] = currentWaypoint;
- emit waypointUpdated(index, currentWaypoint);
}
}
@@ -101,7 +95,6 @@ std::size_t FlightPlan::count() const noexcept
void FlightPlan::clear() noexcept
{
d->waypoints.clear();
- emit waypointsCleared();
}
FlightPlan::Iterator FlightPlan::begin() noexcept
@@ -124,11 +117,6 @@ const FlightPlan::Iterator FlightPlan::end() const noexcept
return Iterator(d->waypoints.end());
}
-FlightPlan::BackInsertIterator FlightPlan::backInsertIterator() noexcept
-{
- return std::back_inserter(d->waypoints);
-}
-
// OPERATORS
Waypoint &FlightPlan::operator[](std::size_t index) noexcept
diff --git a/src/Model/src/FlightSummary.cpp b/src/Model/src/FlightSummary.cpp
deleted file mode 100644
index e471296b4..000000000
--- a/src/Model/src/FlightSummary.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Sky Dolly - The Black Sheep for Your Flight Recordings
- *
- * Copyright (c) Oliver Knoll
- * All rights reserved.
- *
- * MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this
- * software and associated documentation files (the "Software"), to deal in the Software
- * without restriction, including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
- * to whom the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
- * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
- * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-#include "Flight.h"
-#include "FlightSummary.h"
-
-// PUBLIC
-
-FlightSummary::FlightSummary() noexcept
- : flightId(Flight::InvalidId),
- aircraftCount(0)
-{}
-
-FlightSummary::~FlightSummary() noexcept
-{}
-
-FlightSummary::FlightSummary(FlightSummary &&other) noexcept
- : flightId(other.flightId),
- creationDate(std::move(other.creationDate)),
- aircraftType(std::move(other.aircraftType)),
- aircraftCount(other.aircraftCount),
- startSimulationLocalTime(std::move(other.startSimulationLocalTime)),
- startSimulationZuluTime(std::move(other.startSimulationZuluTime)),
- endSimulationLocalTime(std::move(other.endSimulationLocalTime)),
- endSimulationZuluTime(std::move(other.endSimulationZuluTime)),
- startLocation(std::move(other.startLocation)),
- endLocation(std::move(other.endLocation)),
- title(std::move(other.title))
-{}
-
-FlightSummary &FlightSummary::operator=(FlightSummary &&rhs) noexcept
-{
- if (this != &rhs) {
- flightId = rhs.flightId;
- creationDate = std::move(rhs.creationDate);
- aircraftType = std::move(rhs.aircraftType);
- aircraftCount = rhs.aircraftCount;
- startSimulationLocalTime = std::move(rhs.startSimulationLocalTime);
- startSimulationZuluTime = std::move(rhs.startSimulationZuluTime);
- endSimulationLocalTime = std::move(rhs.endSimulationLocalTime);
- endSimulationZuluTime = std::move(rhs.endSimulationZuluTime);
- startLocation = std::move(rhs.startLocation);
- endLocation = std::move(rhs.endLocation);
- title = std::move(rhs.title);
- }
- return *this;
-}
diff --git a/src/Model/src/InitialPosition.cpp b/src/Model/src/InitialPosition.cpp
index b67e9832d..ca2cb6bfb 100644
--- a/src/Model/src/InitialPosition.cpp
+++ b/src/Model/src/InitialPosition.cpp
@@ -31,12 +31,7 @@
InitialPosition::InitialPosition(double theLatitude, double theLongitude, double theAltitude) noexcept
: latitude(theLatitude),
longitude(theLongitude),
- altitude(theAltitude),
- pitch(0.0),
- bank(0.0),
- trueHeading(0.0),
- indicatedAirspeed(InvalidIndicatedAirspeed),
- onGround(false)
+ altitude(theAltitude)
{}
InitialPosition::InitialPosition(const PositionData &positionData, const AircraftInfo &aircraftInfo) noexcept
@@ -44,5 +39,3 @@ InitialPosition::InitialPosition(const PositionData &positionData, const Aircraf
fromPositionData(positionData);
onGround = aircraftInfo.startOnGround;
}
-
-const InitialPosition InitialPosition::NullData = InitialPosition(0.0, 0.0, 0.0);
diff --git a/src/Model/src/Light.cpp b/src/Model/src/Light.cpp
index ecf67b7c1..d7016a6ef 100644
--- a/src/Model/src/Light.cpp
+++ b/src/Model/src/Light.cpp
@@ -25,10 +25,6 @@
#include
#include
-#ifdef DEBUG
-#include
-#endif
-
#include
#include "TimeVariableData.h"
#include "SkySearch.h"
@@ -41,21 +37,11 @@
Light::Light(const AircraftInfo &aircraftInfo) noexcept
: AbstractComponent(aircraftInfo)
-{
-#ifdef DEBUG
- qDebug() << "Light::Light: CREATED";
-#endif
-}
-
-Light::~Light() noexcept
-{
-#ifdef DEBUG
- qDebug() << "Light::Light: DELETED";
-#endif
-}
+{}
-const LightData &Light::interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept
+LightData Light::interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept
{
+ LightData lightData;
const LightData *p1 {nullptr}, *p2 {nullptr};
const std::int64_t timeOffset = access != TimeVariableData::Access::Export ? getAircraftInfo().timeOffset : 0;
const std::int64_t adjustedTimestamp = std::max(timestamp + timeOffset, std::int64_t(0));
@@ -84,18 +70,15 @@ const LightData &Light::interpolate(std::int64_t timestamp, TimeVariableData::Ac
if (p1 != nullptr) {
// No interpolation for light states
- m_currentLightData.lightStates = p1->lightStates;
- m_currentLightData.timestamp = adjustedTimestamp;
- } else {
- // No recorded data, or the timestamp exceeds the timestamp of the last recorded position
- m_currentLightData = LightData::NullData;
+ lightData.lightStates = p1->lightStates;
+ lightData.timestamp = adjustedTimestamp;
}
setCurrentIndex(currentIndex);
setCurrentTimestamp(adjustedTimestamp);
setCurrentAccess(access);
}
- return m_currentLightData;
+ return lightData;
}
-template class AbstractComponent;
\ No newline at end of file
+template class AbstractComponent;
diff --git a/src/Model/src/LightData.cpp b/src/Model/src/LightData.cpp
deleted file mode 100644
index 50041f2d3..000000000
--- a/src/Model/src/LightData.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Sky Dolly - The Black Sheep for Your Flight Recordings
- *
- * Copyright (c) Oliver Knoll
- * All rights reserved.
- *
- * MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this
- * software and associated documentation files (the "Software"), to deal in the Software
- * without restriction, including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
- * to whom the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
- * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
- * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-#include "LightData.h"
-
-// PUBLIC
-
-LightData::LightData(SimType::LightStates theLightStates) noexcept
- : TimeVariableData(),
- lightStates(theLightStates)
-{}
-
-const LightData LightData::NullData = LightData();
diff --git a/src/Model/src/Logbook.cpp b/src/Model/src/Logbook.cpp
index 17a67a8e4..8a4f0aaa0 100644
--- a/src/Model/src/Logbook.cpp
+++ b/src/Model/src/Logbook.cpp
@@ -24,14 +24,17 @@
*/
#include
#include
+#include
#include
+#ifdef DEBUG
+#include
+#endif
#include "Logbook.h"
-class LogbookPrivate
+struct LogbookPrivate
{
-public:
LogbookPrivate() noexcept
{}
@@ -40,18 +43,18 @@ class LogbookPrivate
std::vector> flights;
- static Logbook *instance;
+ static inline std::once_flag onceFlag;
+ static inline Logbook *instance;
};
-Logbook *LogbookPrivate::instance = nullptr;
// PUBLIC
Logbook &Logbook::getInstance() noexcept
{
- if (LogbookPrivate::instance == nullptr) {
+ std::call_once(LogbookPrivate::onceFlag, []() {
LogbookPrivate::instance = new Logbook();
- }
+ });
return *LogbookPrivate::instance;
}
@@ -68,15 +71,6 @@ Flight &Logbook::getCurrentFlight() const noexcept
return *(*d->flights.cbegin());
}
-// PROTECTED
-
-Logbook::~Logbook() noexcept
-{
-#ifdef DEBUG
- qDebug("Logbook::~Logbook: DELETED");
-#endif
-}
-
// PRIVATE
Logbook::Logbook() noexcept
@@ -84,10 +78,16 @@ Logbook::Logbook() noexcept
d(std::make_unique())
{
#ifdef DEBUG
- qDebug("Logbook::Logbook: CREATED");
+ qDebug() << "Logbook::Logbook: CREATED";
#endif
// Logbook may support several flights, but for now there will be always
// exactly one
- std::unique_ptr defaultFlight = std::make_unique();
- d->flights.push_back(std::move(defaultFlight));
+ d->flights.push_back(std::make_unique());
+}
+
+Logbook::~Logbook()
+{
+#ifdef DEBUG
+ qDebug() << "Logbook::~Logbook: DELETED";
+#endif
}
diff --git a/src/Model/src/Position.cpp b/src/Model/src/Position.cpp
index a9353c20d..95024d1f2 100644
--- a/src/Model/src/Position.cpp
+++ b/src/Model/src/Position.cpp
@@ -45,21 +45,11 @@ namespace
Position::Position(const AircraftInfo &aircraftInfo) noexcept
: AbstractComponent(aircraftInfo)
-{
-#ifdef DEBUG
- qDebug() << "Position::Position: CREATED";
-#endif
-}
+{}
-Position::~Position() noexcept
-{
-#ifdef DEBUG
- qDebug() << "Position::Position: DELETED";
-#endif
-}
-
-const PositionData &Position::interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept
+PositionData Position::interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept
{
+ PositionData positionData;
const PositionData *p0 {nullptr}, *p1 {nullptr}, *p2 {nullptr}, *p3 {nullptr};
const std::int64_t timeOffset = access != TimeVariableData::Access::Export ? getAircraftInfo().timeOffset : 0;
const std::int64_t adjustedTimestamp = std::max(timestamp + timeOffset, std::int64_t(0));
@@ -87,41 +77,37 @@ const PositionData &Position::interpolate(std::int64_t timestamp, TimeVariableDa
// Aircraft position & attitude
// Latitude: [-90, 90] - no discontinuity at +/- 90
- m_currentPositionData.latitude = SkyMath::interpolateHermite(p0->latitude, p1->latitude, p2->latitude, p3->latitude, tn);
+ positionData.latitude = SkyMath::interpolateHermite(p0->latitude, p1->latitude, p2->latitude, p3->latitude, tn);
// Longitude: [-180, 180] - discontinuity at the +/- 180 meridian
- m_currentPositionData.longitude = SkyMath::interpolateHermite180(p0->longitude, p1->longitude, p2->longitude, p3->longitude, tn);
+ positionData.longitude = SkyMath::interpolateHermite180(p0->longitude, p1->longitude, p2->longitude, p3->longitude, tn);
// Altitude [open range]
- m_currentPositionData.altitude = SkyMath::interpolateHermite(p0->altitude, p1->altitude, p2->altitude, p3->altitude, tn);
+ positionData.altitude = SkyMath::interpolateHermite(p0->altitude, p1->altitude, p2->altitude, p3->altitude, tn);
// The indicated altitude is not used for replay - only for display and analytical purposes,
// so linear interpolation is sufficient
- m_currentPositionData.indicatedAltitude = SkyMath::interpolateLinear(p1->indicatedAltitude, p2->indicatedAltitude, tn);
+ positionData.indicatedAltitude = SkyMath::interpolateLinear(p1->indicatedAltitude, p2->indicatedAltitude, tn);
// Pitch: [-90, 90] - no discontinuity at +/- 90
- m_currentPositionData.pitch = SkyMath::interpolateHermite(p0->pitch, p1->pitch, p2->pitch, p3->pitch, tn, ::Tension);
+ positionData.pitch = SkyMath::interpolateHermite(p0->pitch, p1->pitch, p2->pitch, p3->pitch, tn, ::Tension);
// Bank: [-180, 180] - discontinuity at +/- 180
- m_currentPositionData.bank = SkyMath::interpolateHermite180(p0->bank, p1->bank, p2->bank, p3->bank, tn, ::Tension);
+ positionData.bank = SkyMath::interpolateHermite180(p0->bank, p1->bank, p2->bank, p3->bank, tn, ::Tension);
// Heading: [0, 360] - discontinuity at 0/360
- m_currentPositionData.trueHeading = SkyMath::interpolateHermite360(p0->trueHeading, p1->trueHeading, p2->trueHeading, p3->trueHeading, tn, ::Tension);
+ positionData.trueHeading = SkyMath::interpolateHermite360(p0->trueHeading, p1->trueHeading, p2->trueHeading, p3->trueHeading, tn, ::Tension);
// Velocity
- m_currentPositionData.velocityBodyX = SkyMath::interpolateLinear(p1->velocityBodyX, p2->velocityBodyX, tn);
- m_currentPositionData.velocityBodyY = SkyMath::interpolateLinear(p1->velocityBodyY, p2->velocityBodyY, tn);
- m_currentPositionData.velocityBodyZ = SkyMath::interpolateLinear(p1->velocityBodyZ, p2->velocityBodyZ, tn);
- m_currentPositionData.rotationVelocityBodyX = SkyMath::interpolateLinear(p1->rotationVelocityBodyX, p2->rotationVelocityBodyX, tn);
- m_currentPositionData.rotationVelocityBodyY = SkyMath::interpolateLinear(p1->rotationVelocityBodyY, p2->rotationVelocityBodyY, tn);
- m_currentPositionData.rotationVelocityBodyZ = SkyMath::interpolateLinear(p1->rotationVelocityBodyZ, p2->rotationVelocityBodyZ, tn);
-
- m_currentPositionData.timestamp = adjustedTimestamp;
-
- } else {
- // No recorded data, or the timestamp exceeds the timestamp of the last recorded position
- m_currentPositionData = PositionData::NullData;
+ positionData.velocityBodyX = SkyMath::interpolateLinear(p1->velocityBodyX, p2->velocityBodyX, tn);
+ positionData.velocityBodyY = SkyMath::interpolateLinear(p1->velocityBodyY, p2->velocityBodyY, tn);
+ positionData.velocityBodyZ = SkyMath::interpolateLinear(p1->velocityBodyZ, p2->velocityBodyZ, tn);
+ positionData.rotationVelocityBodyX = SkyMath::interpolateLinear(p1->rotationVelocityBodyX, p2->rotationVelocityBodyX, tn);
+ positionData.rotationVelocityBodyY = SkyMath::interpolateLinear(p1->rotationVelocityBodyY, p2->rotationVelocityBodyY, tn);
+ positionData.rotationVelocityBodyZ = SkyMath::interpolateLinear(p1->rotationVelocityBodyZ, p2->rotationVelocityBodyZ, tn);
+
+ positionData.timestamp = adjustedTimestamp;
}
setCurrentIndex(currentIndex);
setCurrentTimestamp(adjustedTimestamp);
setCurrentAccess(access);
}
- return m_currentPositionData;
+ return positionData;
}
template class AbstractComponent;
diff --git a/src/Model/src/PositionData.cpp b/src/Model/src/PositionData.cpp
index 6a4582d8e..b38ec001b 100644
--- a/src/Model/src/PositionData.cpp
+++ b/src/Model/src/PositionData.cpp
@@ -34,16 +34,5 @@ PositionData::PositionData(double theLatitude, double theLongitude, double theAl
latitude(theLatitude),
longitude(theLongitude),
altitude(theAltitdue),
- indicatedAltitude(theAltitdue),
- pitch(0.0),
- bank(0.0),
- trueHeading(0.0),
- velocityBodyX(0.0),
- velocityBodyY(0.0),
- velocityBodyZ(0.0),
- rotationVelocityBodyX(0.0),
- rotationVelocityBodyY(0.0),
- rotationVelocityBodyZ(0.0)
+ indicatedAltitude(theAltitdue)
{}
-
-const PositionData PositionData::NullData = PositionData(0.0, 0.0, 0.0);
diff --git a/src/Model/src/PrimaryFlightControl.cpp b/src/Model/src/PrimaryFlightControl.cpp
index 8e22311e4..66d4e48a5 100644
--- a/src/Model/src/PrimaryFlightControl.cpp
+++ b/src/Model/src/PrimaryFlightControl.cpp
@@ -25,10 +25,6 @@
#include
#include
-#ifdef DEBUG
-#include
-#endif
-
#include
#include "TimeVariableData.h"
#include "SkySearch.h"
@@ -36,30 +32,16 @@
#include "PrimaryFlightControlData.h"
#include "PrimaryFlightControl.h"
-namespace
-{
- constexpr double Tension = 0.0;
-}
// PUBLIC
PrimaryFlightControl::PrimaryFlightControl(const AircraftInfo &aircraftInfo) noexcept
: AbstractComponent(aircraftInfo)
-{
-#ifdef DEBUG
- qDebug() << "PrimaryFlightControl::PrimaryFlightControl: CREATED";
-#endif
-}
-
-PrimaryFlightControl::~PrimaryFlightControl() noexcept
-{
-#ifdef DEBUG
- qDebug() << "PrimaryFlightControl::PrimaryFlightControl: DELETED";
-#endif
-}
+{}
-const PrimaryFlightControlData &PrimaryFlightControl::interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept
+PrimaryFlightControlData PrimaryFlightControl::interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept
{
+ PrimaryFlightControlData primaryFlightControlData;
const PrimaryFlightControlData *p1 {nullptr}, *p2 {nullptr};
const std::int64_t timeOffset = access != TimeVariableData::Access::Export ? getAircraftInfo().timeOffset : 0;
const std::int64_t adjustedTimestamp = std::max(timestamp + timeOffset, std::int64_t(0));
@@ -91,20 +73,17 @@ const PrimaryFlightControlData &PrimaryFlightControl::interpolate(std::int64_t t
}
if (p1 != nullptr) {
- m_currentPrimaryFlightControlData.rudderPosition = SkyMath::interpolateLinear(p1->rudderPosition, p2->rudderPosition, tn);
- m_currentPrimaryFlightControlData.elevatorPosition = SkyMath::interpolateLinear(p1->elevatorPosition, p2->elevatorPosition, tn);
- m_currentPrimaryFlightControlData.aileronPosition = SkyMath::interpolateLinear(p1->aileronPosition, p2->aileronPosition, tn);
- m_currentPrimaryFlightControlData.timestamp = adjustedTimestamp;
- } else {
- // No recorded data, or the timestamp exceeds the timestamp of the last recorded position
- m_currentPrimaryFlightControlData = PrimaryFlightControlData::NullData;
+ primaryFlightControlData.rudderPosition = SkyMath::interpolateLinear(p1->rudderPosition, p2->rudderPosition, tn);
+ primaryFlightControlData.elevatorPosition = SkyMath::interpolateLinear(p1->elevatorPosition, p2->elevatorPosition, tn);
+ primaryFlightControlData.aileronPosition = SkyMath::interpolateLinear(p1->aileronPosition, p2->aileronPosition, tn);
+ primaryFlightControlData.timestamp = adjustedTimestamp;
}
setCurrentIndex(currentIndex);
setCurrentTimestamp(adjustedTimestamp);
setCurrentAccess(access);
}
- return m_currentPrimaryFlightControlData;
+ return primaryFlightControlData;
}
template class AbstractComponent;
diff --git a/src/Model/src/PrimaryFlightControlData.cpp b/src/Model/src/PrimaryFlightControlData.cpp
deleted file mode 100644
index 3197aad87..000000000
--- a/src/Model/src/PrimaryFlightControlData.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Sky Dolly - The Black Sheep for Your Flight Recordings
- *
- * Copyright (c) Oliver Knoll
- * All rights reserved.
- *
- * MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this
- * software and associated documentation files (the "Software"), to deal in the Software
- * without restriction, including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
- * to whom the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
- * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
- * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-#include "PrimaryFlightControlData.h"
-
-// PUBLIC
-
-PrimaryFlightControlData::PrimaryFlightControlData() noexcept
- : TimeVariableData(),
- rudderPosition(0),
- elevatorPosition(0),
- aileronPosition(0)
-{}
-
-const PrimaryFlightControlData PrimaryFlightControlData::NullData = PrimaryFlightControlData();
diff --git a/src/Model/src/SecondaryFlightControl.cpp b/src/Model/src/SecondaryFlightControl.cpp
index d8f328708..c5e1193df 100644
--- a/src/Model/src/SecondaryFlightControl.cpp
+++ b/src/Model/src/SecondaryFlightControl.cpp
@@ -25,10 +25,6 @@
#include
#include
-#ifdef DEBUG
-#include
-#endif
-
#include
#include
#include "TimeVariableData.h"
@@ -37,30 +33,15 @@
#include "SecondaryFlightControlData.h"
#include "SecondaryFlightControl.h"
-namespace
-{
- constexpr double Tension = 0.0;
-}
-
// PUBLIC
SecondaryFlightControl::SecondaryFlightControl(const AircraftInfo &aircraftInfo) noexcept
: AbstractComponent(aircraftInfo)
-{
-#ifdef DEBUG
- qDebug() << "SecondaryFlightControl::SecondaryFlightControl: CREATED";
-#endif
-}
-
-SecondaryFlightControl::~SecondaryFlightControl() noexcept
-{
-#ifdef DEBUG
- qDebug() << "SecondaryFlightControl::SecondaryFlightControl: DELETED";
-#endif
-}
+{}
-const SecondaryFlightControlData &SecondaryFlightControl::interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept
+SecondaryFlightControlData SecondaryFlightControl::interpolate(std::int64_t timestamp, TimeVariableData::Access access) noexcept
{
+ SecondaryFlightControlData secondaryFlightControlData;
const SecondaryFlightControlData *p1 {nullptr}, *p2 {nullptr};
const std::int64_t timeOffset = access != TimeVariableData::Access::Export ? getAircraftInfo().timeOffset : 0;
const std::int64_t adjustedTimestamp = std::max(timestamp + timeOffset, std::int64_t(0));
@@ -92,38 +73,35 @@ const SecondaryFlightControlData &SecondaryFlightControl::interpolate(std::int64
}
if (p1 != nullptr) {
- m_currentSecondaryFlightControlData.leadingEdgeFlapsLeftPosition = SkyMath::interpolateLinear(p1->leadingEdgeFlapsLeftPosition, p2->leadingEdgeFlapsLeftPosition, tn);
- m_currentSecondaryFlightControlData.leadingEdgeFlapsRightPosition = SkyMath::interpolateLinear(p1->leadingEdgeFlapsRightPosition, p2->leadingEdgeFlapsRightPosition, tn);
- m_currentSecondaryFlightControlData.trailingEdgeFlapsLeftPosition = SkyMath::interpolateLinear(p1->trailingEdgeFlapsLeftPosition, p2->trailingEdgeFlapsLeftPosition, tn);
- m_currentSecondaryFlightControlData.trailingEdgeFlapsRightPosition = SkyMath::interpolateLinear(p1->trailingEdgeFlapsRightPosition, p2->trailingEdgeFlapsRightPosition, tn);
- m_currentSecondaryFlightControlData.spoilersHandlePosition = SkyMath::interpolateLinear(p1->spoilersHandlePosition, p2->spoilersHandlePosition, tn);
+ secondaryFlightControlData.leadingEdgeFlapsLeftPosition = SkyMath::interpolateLinear(p1->leadingEdgeFlapsLeftPosition, p2->leadingEdgeFlapsLeftPosition, tn);
+ secondaryFlightControlData.leadingEdgeFlapsRightPosition = SkyMath::interpolateLinear(p1->leadingEdgeFlapsRightPosition, p2->leadingEdgeFlapsRightPosition, tn);
+ secondaryFlightControlData.trailingEdgeFlapsLeftPosition = SkyMath::interpolateLinear(p1->trailingEdgeFlapsLeftPosition, p2->trailingEdgeFlapsLeftPosition, tn);
+ secondaryFlightControlData.trailingEdgeFlapsRightPosition = SkyMath::interpolateLinear(p1->trailingEdgeFlapsRightPosition, p2->trailingEdgeFlapsRightPosition, tn);
+ secondaryFlightControlData.spoilersHandlePosition = SkyMath::interpolateLinear(p1->spoilersHandlePosition, p2->spoilersHandlePosition, tn);
// No interpolation for flaps handle position
- m_currentSecondaryFlightControlData.flapsHandleIndex = p1->flapsHandleIndex;
+ secondaryFlightControlData.flapsHandleIndex = p1->flapsHandleIndex;
// Certain aircraft automatically override the FLAPS HANDLE INDEX, so values need to be repeatedly set
if (Settings::getInstance().isRepeatFlapsHandleIndexEnabled()) {
// We do that my storing the previous values (when the flaps are set)...
- m_previousSecondaryFlightControlData = m_currentSecondaryFlightControlData;
+ m_previousSecondaryFlightControlData = secondaryFlightControlData;
} else {
// "Repeat values" setting disabled
- m_previousSecondaryFlightControlData = SecondaryFlightControlData::NullData;
+ m_previousSecondaryFlightControlData = SecondaryFlightControlData();
}
- m_currentSecondaryFlightControlData.timestamp = adjustedTimestamp;
+ secondaryFlightControlData.timestamp = adjustedTimestamp;
} else if (!m_previousSecondaryFlightControlData.isNull()) {
// ... and send the previous values again (for as long as the flaps are extracted)
- m_currentSecondaryFlightControlData = m_previousSecondaryFlightControlData;
- m_currentSecondaryFlightControlData.timestamp = adjustedTimestamp;
- } else {
- // No recorded data, or the timestamp exceeds the timestamp of the last recorded position
- m_currentSecondaryFlightControlData = SecondaryFlightControlData::NullData;
+ secondaryFlightControlData = m_previousSecondaryFlightControlData;
+ secondaryFlightControlData.timestamp = adjustedTimestamp;
}
setCurrentIndex(currentIndex);
setCurrentTimestamp(adjustedTimestamp);
setCurrentAccess(access);
}
- return m_currentSecondaryFlightControlData;
+ return secondaryFlightControlData;
}
template class AbstractComponent;
diff --git a/src/Model/src/SecondaryFlightControlData.cpp b/src/Model/src/SecondaryFlightControlData.cpp
deleted file mode 100644
index 9440a8e83..000000000
--- a/src/Model/src/SecondaryFlightControlData.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Sky Dolly - The Black Sheep for Your Flight Recordings
- *
- * Copyright (c) Oliver Knoll
- * All rights reserved.
- *
- * MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this
- * software and associated documentation files (the "Software"), to deal in the Software
- * without restriction, including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
- * to whom the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
- * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
- * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-#include "SecondaryFlightControlData.h"
-
-// PUBLIC
-
-SecondaryFlightControlData::SecondaryFlightControlData() noexcept
- : TimeVariableData(),
- leadingEdgeFlapsLeftPosition(0),
- leadingEdgeFlapsRightPosition(0),
- trailingEdgeFlapsLeftPosition(0),
- trailingEdgeFlapsRightPosition(0),
- spoilersHandlePosition(0),
- flapsHandleIndex(0)
-{}
-
-const SecondaryFlightControlData SecondaryFlightControlData::NullData = SecondaryFlightControlData();
diff --git a/src/Model/src/TimeVariableData.cpp b/src/Model/src/TimeVariableData.cpp
deleted file mode 100644
index 3500beb4e..000000000
--- a/src/Model/src/TimeVariableData.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Sky Dolly - The Black Sheep for Your Flight Recordings
- *
- * Copyright (c) Oliver Knoll
- * All rights reserved.
- *
- * MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this
- * software and associated documentation files (the "Software"), to deal in the Software
- * without restriction, including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
- * to whom the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
- * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
- * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-#include "TimeVariableData.h"
-
-// PUBLIC
-
-TimeVariableData::TimeVariableData() noexcept
- : timestamp(InvalidTime)
-{}
-
-TimeVariableData::~TimeVariableData() noexcept
-{}
diff --git a/src/Model/src/Waypoint.cpp b/src/Model/src/Waypoint.cpp
index 04f16a84f..0b270a4a6 100644
--- a/src/Model/src/Waypoint.cpp
+++ b/src/Model/src/Waypoint.cpp
@@ -24,7 +24,6 @@
*/
#include
-#include "LightData.h"
#include "Waypoint.h"
// PUBLIC
@@ -36,35 +35,9 @@ Waypoint::Waypoint(float theLatitude, float theLongitude, float theAltitude) noe
altitude(theAltitude)
{}
-Waypoint::Waypoint(Waypoint &&other) noexcept
- : TimeVariableData(std::move(other)),
- identifier(std::move(other.identifier)),
- latitude(other.latitude),
- longitude(other.longitude),
- altitude(other.altitude),
- localTime(std::move(other.localTime)),
- zuluTime(std::move(other.zuluTime))
-{}
-
-Waypoint &Waypoint::operator=(Waypoint &&rhs) noexcept
-{
- if (this != &rhs) {
- TimeVariableData::operator=(rhs);
- identifier = std::move(rhs.identifier);
- latitude = rhs.latitude;
- longitude = rhs.longitude;
- altitude = rhs.altitude;
- localTime = std::move(rhs.localTime);
- zuluTime = std::move(rhs.zuluTime);
- }
- return *this;
-}
-
bool Waypoint::isValid() const noexcept
{
return !identifier.isEmpty();
}
const Waypoint Waypoint::NullWaypoint = Waypoint();
-const char Waypoint::CustomDepartureIdentifier[] = "CUSTD";
-const char Waypoint::CustomArrivalIdentifier[] = "CUSTA";
diff --git a/src/Persistence/CMakeLists.txt b/src/Persistence/CMakeLists.txt
index f766a5e6a..12e4852f2 100644
--- a/src/Persistence/CMakeLists.txt
+++ b/src/Persistence/CMakeLists.txt
@@ -14,9 +14,9 @@ target_compile_definitions(${LIBRARY_NAME}
target_sources(${LIBRARY_NAME}
PRIVATE
include/Persistence/PersistenceLib.h
- include/Persistence/LogbookManager.h src/LogbookManager.cpp
- include/Persistence/FlightSelector.h src/FlightSelector.cpp
- include/Persistence/LocationSelector.h src/LocationSelector.cpp
+ include/Persistence/PersistenceManager.h src/PersistenceManager.cpp
+ include/Persistence/FlightSelector.h
+ include/Persistence/LocationSelector.h
include/Persistence/Metadata.h
include/Persistence/PersistedEnumerationItem.h src/PersistedEnumerationItem.cpp
src/Dao/DatabaseDaoIntf.h
diff --git a/src/Persistence/include/Persistence/FlightSelector.h b/src/Persistence/include/Persistence/FlightSelector.h
index c95cccc6b..38fe0b93c 100644
--- a/src/Persistence/include/Persistence/FlightSelector.h
+++ b/src/Persistence/include/Persistence/FlightSelector.h
@@ -34,14 +34,12 @@
struct PERSISTENCE_API FlightSelector
{
public:
- FlightSelector();
-
- QDate fromDate;
- QDate toDate;
+ QDate fromDate {MinDate};
+ QDate toDate {MaxDate};
QString searchKeyword;
- bool hasFormation;
- SimType::EngineType engineType;
- int mininumDurationMinutes;
+ bool hasFormation {false};
+ SimType::EngineType engineType {SimType::EngineType::All};
+ int mininumDurationMinutes {0};
// The release date of MSFS ;)
static inline const QDate MinDate {2020, 8, 18};
diff --git a/src/Persistence/include/Persistence/LocationSelector.h b/src/Persistence/include/Persistence/LocationSelector.h
index 6653a91d3..6c47f0de5 100644
--- a/src/Persistence/include/Persistence/LocationSelector.h
+++ b/src/Persistence/include/Persistence/LocationSelector.h
@@ -35,7 +35,6 @@
struct PERSISTENCE_API LocationSelector
{
public:
- LocationSelector();
};
#endif // LOCATIONSELECTOR_H
diff --git a/src/Persistence/include/Persistence/PersistedEnumerationItem.h b/src/Persistence/include/Persistence/PersistedEnumerationItem.h
index 55032e75c..5c9071c1c 100644
--- a/src/Persistence/include/Persistence/PersistedEnumerationItem.h
+++ b/src/Persistence/include/Persistence/PersistedEnumerationItem.h
@@ -39,7 +39,12 @@ class PERSISTENCE_API PersistedEnumerationItem
{
public:
PersistedEnumerationItem(QString enumerationName, QString symbolicId) noexcept;
- ~PersistedEnumerationItem() noexcept;
+ PersistedEnumerationItem() = default;
+ PersistedEnumerationItem(const PersistedEnumerationItem &rhs) = delete;
+ PersistedEnumerationItem(PersistedEnumerationItem &&rhs);
+ PersistedEnumerationItem &operator=(const PersistedEnumerationItem &rhs) = delete;
+ PersistedEnumerationItem &operator=(PersistedEnumerationItem &&rhs);
+ ~PersistedEnumerationItem();
std::int64_t id() const noexcept;
diff --git a/src/Persistence/include/Persistence/LogbookManager.h b/src/Persistence/include/Persistence/PersistenceManager.h
similarity index 72%
rename from src/Persistence/include/Persistence/LogbookManager.h
rename to src/Persistence/include/Persistence/PersistenceManager.h
index 8e08a8ade..39181fe32 100644
--- a/src/Persistence/include/Persistence/LogbookManager.h
+++ b/src/Persistence/include/Persistence/PersistenceManager.h
@@ -22,10 +22,11 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
-#ifndef LOGBOOKMANAGER_H
-#define LOGBOOKMANAGER_H
+#ifndef PERSISTENCEMANAGER_H
+#define PERSISTENCEMANAGER_H
#include
+#include
#include
@@ -39,13 +40,18 @@ class Version;
class Metadata;
class Version;
-class LogbookManagerPrivate;
+struct PersistenceManagerPrivate;
-class PERSISTENCE_API LogbookManager : public QObject
+class PERSISTENCE_API PersistenceManager final : public QObject
{
Q_OBJECT
public:
- static LogbookManager &getInstance() noexcept;
+ PersistenceManager(const PersistenceManager &rhs) = delete;
+ PersistenceManager(PersistenceManager &&rhs) = delete;
+ PersistenceManager &operator=(const PersistenceManager &rhs) = delete;
+ PersistenceManager &operator=(PersistenceManager &&rhs) = delete;
+
+ static PersistenceManager &getInstance() noexcept;
static void destroyInstance() noexcept;
/*!
@@ -57,12 +63,12 @@ class PERSISTENCE_API LogbookManager : public QObject
* paths (or to quit the application altogether).
*
* The actual logbook path (which is usually the given \c logbookPath)
- * is stored in the Settings.
+ * is stored in the PersistenceManager.
*
* \param logbookPath
* the path of the logbook (database) file to connect with
* \return \c true if the connection succeeded; \c false else
- * \sa Settings#setLogbookPath
+ * \sa PersistenceManager#setLogbookPath
* \sa connectionChanged
*/
bool connectWithLogbook(const QString &logbookPath, QWidget *parent) noexcept;
@@ -75,9 +81,9 @@ class PERSISTENCE_API LogbookManager : public QObject
bool optimise() noexcept;
bool backup(const QString &backupLogbookPath) noexcept;
- bool getMetadata(Metadata &metadata) const noexcept;
- bool getDatabaseVersion(Version &databaseVersion) const noexcept;
- bool getBackupDirectoryPath(QString &backupDirectoryPath) const noexcept;
+ Metadata getMetadata(bool *ok = nullptr) const noexcept;
+ Version getDatabaseVersion(bool *ok = nullptr) const noexcept;
+ QString getBackupDirectoryPath(bool *ok = nullptr) const noexcept;
QString getBackupFileName(const QString &backupDirectoryPath) const noexcept;
static QString createBackupPathIfNotExists(const QString &relativeOrAbsoluteBackupDirectoryPath) noexcept;
@@ -85,17 +91,14 @@ class PERSISTENCE_API LogbookManager : public QObject
signals:
void connectionChanged(bool connected);
-protected:
- ~LogbookManager() noexcept override;
-
private:
- Q_DISABLE_COPY(LogbookManager)
- std::unique_ptr d;
+ const std::unique_ptr d;
- LogbookManager() noexcept;
+ PersistenceManager() noexcept;
+ ~PersistenceManager() override;
bool connectDb(const QString &logbookPath) noexcept;
- bool checkDatabaseVersion(Version &databaseVersion) const noexcept;
+ std::pair checkDatabaseVersion() const noexcept;
};
-#endif // LOGBOOKMANAGER_H
+#endif // PERSISTENCEMANAGER_H
diff --git a/src/Persistence/include/Persistence/Service/AircraftService.h b/src/Persistence/include/Persistence/Service/AircraftService.h
index 5e9b6243e..2f823de14 100644
--- a/src/Persistence/include/Persistence/Service/AircraftService.h
+++ b/src/Persistence/include/Persistence/Service/AircraftService.h
@@ -34,17 +34,21 @@
#include
#include "../PersistenceLib.h"
-class AircraftServicePrivate;
+struct AircraftServicePrivate;
class PERSISTENCE_API AircraftService
{
public:
AircraftService() noexcept;
- ~AircraftService() noexcept;
+ AircraftService(const AircraftService &rhs) = delete;
+ AircraftService(AircraftService &&rhs);
+ AircraftService &operator=(const AircraftService &rhs) = delete;
+ AircraftService &operator=(AircraftService &&rhs);
+ ~AircraftService();
bool store(std::int64_t flightId, std::size_t sequenceNumber, Aircraft &aircraft) noexcept;
bool deleteByIndex(int index) noexcept;
- bool getAircraftInfos(std::int64_t flightId, std::vector &aircraftInfos) const noexcept;
+ std::vector getAircraftInfos(std::int64_t flightId, bool *ok = nullptr) const noexcept;
bool changeTimeOffset(Aircraft &aircraft, std::int64_t newOffset) noexcept;
bool changeTailNumber(Aircraft &aircraft, const QString &tailNumber) noexcept;
diff --git a/src/Persistence/include/Persistence/Service/AircraftTypeService.h b/src/Persistence/include/Persistence/Service/AircraftTypeService.h
index 0e67b0391..687d0332b 100644
--- a/src/Persistence/include/Persistence/Service/AircraftTypeService.h
+++ b/src/Persistence/include/Persistence/Service/AircraftTypeService.h
@@ -28,24 +28,26 @@
#include
#include
-#include
-
class QString;
#include
#include
#include "../PersistenceLib.h"
-class AircraftTypeServicePrivate;
+struct AircraftTypeServicePrivate;
class PERSISTENCE_API AircraftTypeService
{
public:
AircraftTypeService() noexcept;
- ~AircraftTypeService() noexcept;
-
- bool getByType(const QString &type, AircraftType &aircraftType) const noexcept;
- bool getAll(std::back_insert_iterator> backInsertIterator) const noexcept;
+ AircraftTypeService(const AircraftTypeService &rhs) = delete;
+ AircraftTypeService(AircraftTypeService &&rhs);
+ AircraftTypeService &operator=(const AircraftTypeService &rhs) = delete;
+ AircraftTypeService &operator=(AircraftTypeService &&rhs);
+ ~AircraftTypeService();
+
+ AircraftType getByType(const QString &type, bool *ok = nullptr) const noexcept;
+ std::vector getAll(bool *ok = nullptr) const noexcept;
bool exists(const QString &type) const noexcept;
private:
diff --git a/src/Persistence/include/Persistence/Service/DatabaseService.h b/src/Persistence/include/Persistence/Service/DatabaseService.h
index 82b171d8e..85c490505 100644
--- a/src/Persistence/include/Persistence/Service/DatabaseService.h
+++ b/src/Persistence/include/Persistence/Service/DatabaseService.h
@@ -33,17 +33,20 @@ class QString;
class QWidget;
class QDateTime;
-#include "../Metadata.h"
#include "../PersistenceLib.h"
class Version;
-class DatabaseServicePrivate;
+struct DatabaseServicePrivate;
class PERSISTENCE_API DatabaseService
{
public:
DatabaseService() noexcept;
- ~DatabaseService() noexcept;
+ DatabaseService(const DatabaseService &rhs) = delete;
+ DatabaseService(DatabaseService &&rhs);
+ DatabaseService &operator=(const DatabaseService &rhs) = delete;
+ DatabaseService &operator=(DatabaseService &&rhs);
+ ~DatabaseService();
bool backup() noexcept;
diff --git a/src/Persistence/include/Persistence/Service/EnumerationService.h b/src/Persistence/include/Persistence/Service/EnumerationService.h
index a23888ee5..a24943bc3 100644
--- a/src/Persistence/include/Persistence/Service/EnumerationService.h
+++ b/src/Persistence/include/Persistence/Service/EnumerationService.h
@@ -38,16 +38,22 @@ class PERSISTENCE_API EnumerationService
{
public:
EnumerationService() noexcept;
- ~EnumerationService() noexcept;
+ EnumerationService(const EnumerationService &rhs) = delete;
+ EnumerationService(EnumerationService &&rhs);
+ EnumerationService &operator=(const EnumerationService &rhs) = delete;
+ EnumerationService &operator=(EnumerationService &&rhs);
+ ~EnumerationService();
/*!
- * Gets the persisted Enumeration by its \c enumeration.name.
+ * Gets the persisted Enumeration by its enumeration \c name.
*
- * \param enumeration
- * the persisted Enumeration to get, identified by its \c name member
- * \return \c true if successful; \c false else (unknown Enumeration name, no database connection)
+ * \param name
+ * the name of the enumeration
+ * \param ok
+ * if set, \c true if successful; \c false else (unknown Enumeration name, no database connection)
+ * \return the persisted Enumeration to get, identified by the \c name
*/
- bool getEnumerationByName(Enumeration &enumeration);
+ Enumeration getEnumerationByName(const QString &name, bool *ok = nullptr);
// Implementation note:
// Well-known database enumerations: TitleCase name must match with corresponding
diff --git a/src/Persistence/include/Persistence/Service/FlightService.h b/src/Persistence/include/Persistence/Service/FlightService.h
index 505283a6b..597d8a346 100644
--- a/src/Persistence/include/Persistence/Service/FlightService.h
+++ b/src/Persistence/include/Persistence/Service/FlightService.h
@@ -35,13 +35,17 @@
#include "../PersistenceLib.h"
class SkyConnectIntf;
-class FlightServicePrivate;
+struct FlightServicePrivate;
class PERSISTENCE_API FlightService
{
public:
FlightService() noexcept;
- ~FlightService() noexcept;
+ FlightService(const FlightService &rhs) = delete;
+ FlightService(FlightService &&rhs);
+ FlightService &operator=(const FlightService &rhs) = delete;
+ FlightService &operator=(FlightService &&rhs);
+ ~FlightService();
bool store(Flight &flight) noexcept;
bool restore(std::int64_t id, Flight &flight) noexcept;
diff --git a/src/Persistence/include/Persistence/Service/LocationService.h b/src/Persistence/include/Persistence/Service/LocationService.h
index 86963777b..4c9e251ac 100644
--- a/src/Persistence/include/Persistence/Service/LocationService.h
+++ b/src/Persistence/include/Persistence/Service/LocationService.h
@@ -26,7 +26,7 @@
#define LOCATIONSERVICE_H
#include
-#include
+#include
#include
#include
@@ -34,19 +34,23 @@
#include "../PersistenceLib.h"
struct LocationSelector;
-class LocationServicePrivate;
+struct LocationServicePrivate;
class PERSISTENCE_API LocationService
{
public:
LocationService() noexcept;
- ~LocationService() noexcept;
+ LocationService(const LocationService &rhs) = delete;
+ LocationService(LocationService &&rhs);
+ LocationService &operator=(const LocationService &rhs) = delete;
+ LocationService &operator=(LocationService &&rhs);
+ ~LocationService();
bool store(Location &location) noexcept;
bool update(const Location &location) noexcept;
bool deleteById(std::int64_t id) noexcept;
- bool getAll(std::back_insert_iterator> backInsertIterator) const noexcept;
- bool getSelectedLocations(const LocationSelector &locationSelector, std::back_insert_iterator> backInsertIterator) const noexcept;
+ std::vector getAll(bool *ok = nullptr) const noexcept;
+ std::vector getSelectedLocations(const LocationSelector &locationSelector, bool *ok = nullptr) const noexcept;
private:
std::unique_ptr d;
diff --git a/src/Persistence/include/Persistence/Service/LogbookService.h b/src/Persistence/include/Persistence/Service/LogbookService.h
index 08c3e9719..5ca81f407 100644
--- a/src/Persistence/include/Persistence/Service/LogbookService.h
+++ b/src/Persistence/include/Persistence/Service/LogbookService.h
@@ -35,13 +35,17 @@
#include "../PersistenceLib.h"
class FlightSelector;
-class LogbookServicePrivate;
+struct LogbookServicePrivate;
class PERSISTENCE_API LogbookService
{
public:
LogbookService() noexcept;
- ~LogbookService() noexcept;
+ LogbookService(const LogbookService &rhs) = delete;
+ LogbookService(LogbookService &&rhs);
+ LogbookService &operator=(const LogbookService &rhs) = delete;
+ LogbookService &operator=(LogbookService &&rhs);
+ ~LogbookService();
bool getFlightDates(std::front_insert_iterator> frontInsertIterator) const noexcept;
std::vector getFlightSummaries(const FlightSelector &flightSelector) const noexcept;
diff --git a/src/Persistence/src/Dao/AircraftDaoIntf.h b/src/Persistence/src/Dao/AircraftDaoIntf.h
index 7710e1420..cd7c4660f 100644
--- a/src/Persistence/src/Dao/AircraftDaoIntf.h
+++ b/src/Persistence/src/Dao/AircraftDaoIntf.h
@@ -27,18 +27,22 @@
#include
#include
-#include
#include
#include
class QString;
class Aircraft;
-class AircraftInfo;
+struct AircraftInfo;
class AircraftDaoIntf
{
public:
+ AircraftDaoIntf() = default;
+ AircraftDaoIntf(const AircraftDaoIntf &rhs) = delete;
+ AircraftDaoIntf(AircraftDaoIntf &&rhs) = default;
+ AircraftDaoIntf &operator=(const AircraftDaoIntf &rhs) = delete;
+ AircraftDaoIntf &operator=(AircraftDaoIntf &&rhs) = default;
virtual ~AircraftDaoIntf() = default;
/*!
@@ -53,11 +57,11 @@ class AircraftDaoIntf
* \return \c true on success; \c false else
*/
virtual bool add(std::int64_t flightId, std::size_t sequenceNumber, Aircraft &aircraft) noexcept = 0;
- virtual bool getByFlightId(std::int64_t flightId, std::back_insert_iterator>> backInsertIterator) const noexcept = 0;
+ virtual std::vector getByFlightId(std::int64_t flightId, bool *ok = nullptr) const noexcept = 0;
virtual bool adjustAircraftSequenceNumbersByFlightId(std::int64_t id, std::size_t sequenceNumber) noexcept = 0;
virtual bool deleteAllByFlightId(std::int64_t flightId) noexcept = 0;
virtual bool deleteById(std::int64_t id) noexcept = 0;
- virtual bool getAircraftInfosByFlightId(std::int64_t flightId, std::vector &aircraftInfos) const noexcept = 0;
+ virtual std::vector getAircraftInfosByFlightId(std::int64_t flightId, bool *ok = nullptr) const noexcept = 0;
virtual bool updateTimeOffset(std::int64_t id, std::int64_t timeOffset) noexcept = 0;
virtual bool updateTailNumber(std::int64_t id, const QString &tailNumber) noexcept = 0;
};
diff --git a/src/Persistence/src/Dao/AircraftTypeDaoIntf.h b/src/Persistence/src/Dao/AircraftTypeDaoIntf.h
index fe9c0ad02..4efa9cccb 100644
--- a/src/Persistence/src/Dao/AircraftTypeDaoIntf.h
+++ b/src/Persistence/src/Dao/AircraftTypeDaoIntf.h
@@ -27,9 +27,6 @@
#include
#include
-#include
-
-#include
class QString;
@@ -38,11 +35,16 @@ struct AircraftType;
class AircraftTypeDaoIntf
{
public:
+ AircraftTypeDaoIntf() = default;
+ AircraftTypeDaoIntf(const AircraftTypeDaoIntf &rhs) = delete;
+ AircraftTypeDaoIntf(AircraftTypeDaoIntf &&rhs) = default;
+ AircraftTypeDaoIntf &operator=(const AircraftTypeDaoIntf &rhs) = delete;
+ AircraftTypeDaoIntf &operator=(AircraftTypeDaoIntf &&rhs) = default;
virtual ~AircraftTypeDaoIntf() = default;
virtual bool upsert(const AircraftType &aircraftType) noexcept = 0;
- virtual bool getByType(const QString &type, AircraftType &aircraftType) const noexcept = 0;
- virtual bool getAll(std::back_insert_iterator> backInsertIterator) const noexcept = 0;
+ virtual AircraftType getByType(const QString &type, bool *ok = nullptr) const noexcept = 0;
+ virtual std::vector getAll(bool *ok = nullptr) const noexcept = 0;
virtual bool exists(const QString &type) const noexcept = 0;
};
diff --git a/src/Persistence/src/Dao/DaoFactory.cpp b/src/Persistence/src/Dao/DaoFactory.cpp
index 053bccc99..e93df6986 100644
--- a/src/Persistence/src/Dao/DaoFactory.cpp
+++ b/src/Persistence/src/Dao/DaoFactory.cpp
@@ -52,9 +52,8 @@
#include "EnumerationDaoIntf.h"
#include "DaoFactory.h"
-class DaoFactoryPrivate
+struct DaoFactoryPrivate
{
-public:
DaoFactoryPrivate(DaoFactory::DbType theDbType)
: dbType(theDbType)
{}
@@ -68,8 +67,9 @@ DaoFactory::DaoFactory(DbType dbType)
: d(std::make_unique(dbType))
{}
-DaoFactory::~DaoFactory()
-{}
+DaoFactory::DaoFactory(DaoFactory &&rhs) = default;
+DaoFactory &DaoFactory::operator=(DaoFactory &&rhs) = default;
+DaoFactory::~DaoFactory() = default;
std::unique_ptr DaoFactory::createDatabaseDao() noexcept
{
diff --git a/src/Persistence/src/Dao/DaoFactory.h b/src/Persistence/src/Dao/DaoFactory.h
index 6ddd25196..33f07f0de 100644
--- a/src/Persistence/src/Dao/DaoFactory.h
+++ b/src/Persistence/src/Dao/DaoFactory.h
@@ -42,7 +42,7 @@ class DatabaseDaoIntf;
class LocationDaoIntf;
class EnumerationDaoIntf;
-class DaoFactoryPrivate;
+struct DaoFactoryPrivate;
class DaoFactory
{
@@ -54,7 +54,12 @@ class DaoFactory
};
DaoFactory(DbType dbType);
- ~DaoFactory();
+ DaoFactory() = default;
+ DaoFactory(const DaoFactory &rhs) = delete;
+ DaoFactory(DaoFactory &&rhs);
+ DaoFactory &operator=(const DaoFactory &rhs) = delete;
+ DaoFactory &operator=(DaoFactory &&rhs);
+ virtual ~DaoFactory();
std::unique_ptr createDatabaseDao() noexcept;
std::unique_ptr