| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /** | ||
| * 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 <memory> | ||
|
|
||
| #include <QObject> | ||
| #include <QVector> | ||
|
|
||
| #include "FlightPlanData.h" | ||
| #include "FlightPlan.h" | ||
|
|
||
| class FlightPlanPrivate | ||
| { | ||
| public: | ||
| FlightPlanPrivate() noexcept | ||
| {} | ||
|
|
||
| QVector<FlightPlanData> flightPlanData; | ||
| }; | ||
|
|
||
| // PUBLIC | ||
|
|
||
| FlightPlan::FlightPlan(QObject *parent) noexcept | ||
| : QObject(parent), | ||
| d(std::make_unique<FlightPlanPrivate>()) | ||
| { | ||
| } | ||
|
|
||
| FlightPlan::~FlightPlan() noexcept | ||
| { | ||
| } | ||
|
|
||
| void FlightPlan::add(const FlightPlanData &flightPlanData) noexcept | ||
| { | ||
| d->flightPlanData.append(flightPlanData); | ||
| emit dataChanged(); | ||
| } | ||
|
|
||
| QVector<FlightPlanData> &FlightPlan::getAll() const noexcept | ||
| { | ||
| return d->flightPlanData; | ||
| } | ||
|
|
||
| const QVector<FlightPlanData> &FlightPlan::getAllConst() const noexcept | ||
| { | ||
| return d->flightPlanData; | ||
| } | ||
|
|
||
| void FlightPlan::clear() noexcept | ||
| { | ||
| d->flightPlanData.clear(); | ||
| emit dataChanged(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| #ifndef FLIGHTPLAN_H | ||
| #define FLIGHTPLAN_H | ||
|
|
||
|
|
||
| #include <memory> | ||
|
|
||
| #include <QObject> | ||
| #include <QByteArray> | ||
| #include <QVector> | ||
|
|
||
| #include "ModelLib.h" | ||
|
|
||
| class FlightPlanData; | ||
| class FlightPlanPrivate; | ||
|
|
||
| class MODEL_API FlightPlan : public QObject | ||
| { | ||
| Q_OBJECT | ||
| public: | ||
| FlightPlan(QObject *parent = nullptr) noexcept; | ||
| virtual ~FlightPlan() noexcept; | ||
|
|
||
| void add(const FlightPlanData &flightPlanData) noexcept; | ||
| QVector<FlightPlanData> &getAll() const noexcept; | ||
| const QVector<FlightPlanData> &getAllConst() const noexcept; | ||
|
|
||
| void clear() noexcept; | ||
|
|
||
| signals: | ||
| void dataChanged(); | ||
|
|
||
| private: | ||
| Q_DISABLE_COPY(FlightPlan) | ||
| std::unique_ptr<FlightPlanPrivate> d; | ||
| }; | ||
|
|
||
| #endif // FLIGHTPLAN_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| #ifndef FLIGHTPLANDATA_H | ||
| #define FLIGHTPLANDATA_H | ||
|
|
||
| #include <QtGlobal> | ||
| #include <QString> | ||
|
|
||
| #include "SimType.h" | ||
| #include "TimeVariableData.h" | ||
| #include "ModelLib.h" | ||
|
|
||
| struct MODEL_API FlightPlanData | ||
| { | ||
| QString waypointIdentifier; | ||
| float waypointLatitude; | ||
| float waypointLongitude; | ||
| float waypointAltitude; | ||
|
|
||
| FlightPlanData() noexcept; | ||
| FlightPlanData(FlightPlanData &&) = default; | ||
| FlightPlanData(const FlightPlanData &) = default; | ||
| FlightPlanData &operator= (const FlightPlanData &) = default; | ||
| }; | ||
|
|
||
| #endif // FLIGHTPLANDATA_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /** | ||
| * 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 "ScenarioDescription.h" | ||
|
|
||
| // PUBLIC | ||
|
|
||
| ScenarioDescription::ScenarioDescription() | ||
| {} | ||
|
|
||
| ScenarioDescription::~ScenarioDescription() | ||
| {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| #ifndef SCENARIODESCRIPTION_H | ||
| #define SCENARIODESCRIPTION_H | ||
|
|
||
| #include <QString> | ||
| #include <QDateTime> | ||
|
|
||
| #include "ModelLib.h" | ||
|
|
||
| struct MODEL_API ScenarioDescription | ||
| { | ||
| ScenarioDescription(); | ||
| ~ScenarioDescription(); | ||
|
|
||
| qint64 id; | ||
| QDateTime creationDate; | ||
| QString aircraftType; | ||
| QDateTime startDate; | ||
| QDateTime endDate; | ||
| QString startLocation; | ||
| QString endLocation; | ||
| QString description; | ||
| }; | ||
|
|
||
| #endif // SCENARIODESCRIPTION_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| add_definitions(-DPERSISTENCE_EXPORT) | ||
|
|
||
| if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) | ||
| qt_add_library(Persistence SHARED "") | ||
| else() | ||
| add_library(Persistence SHARED "") | ||
| endif() | ||
|
|
||
| target_sources(Persistence | ||
| PRIVATE | ||
| src/PersistenceLib.h | ||
| src/ConnectionManager.cpp | ||
| src/ConnectionManager.h | ||
| src/Metadata.h | ||
| src/Dao/DatabaseDaoIntf.h | ||
| src/Dao/ScenarioDaoIntf.h | ||
| src/Dao/AircraftDaoIntf.h | ||
| src/Dao/PositionDaoIntf.h | ||
| src/Dao/EngineDaoIntf.h | ||
| src/Dao/PrimaryFlightControlDaoIntf.h | ||
| src/Dao/SecondaryFlightControlDaoIntf.h | ||
| src/Dao/HandleDaoIntf.h | ||
| src/Dao/LightDaoIntf.h | ||
| src/Dao/FlightPlanDaoIntf.h | ||
| src/Dao/DaoFactory.cpp | ||
| src/Dao/DaoFactory.h | ||
| src/Dao/SQLite/SQLiteDatabaseDao.cpp | ||
| src/Dao/SQLite/SQLiteDatabaseDao.h | ||
| src/Dao/SQLite/SQLiteScenarioDao.cpp | ||
| src/Dao/SQLite/SQLiteScenarioDao.h | ||
| src/Dao/SQLite/SQLiteAircraftDao.cpp | ||
| src/Dao/SQLite/SQLiteAircraftDao.h | ||
| src/Dao/SQLite/SQLitePositionDao.cpp | ||
| src/Dao/SQLite/SQLitePositionDao.h | ||
| src/Dao/SQLite/SQLiteEngineDao.cpp | ||
| src/Dao/SQLite/SQLiteEngineDao.h | ||
| src/Dao/SQLite/SQLitePrimaryFlightControlDao.cpp | ||
| src/Dao/SQLite/SQLitePrimaryFlightControlDao.h | ||
| src/Dao/SQLite/SQLiteSecondaryFlightControlDao.cpp | ||
| src/Dao/SQLite/SQLiteSecondaryFlightControlDao.h | ||
| src/Dao/SQLite/SQLiteHandleDao.cpp | ||
| src/Dao/SQLite/SQLiteHandleDao.h | ||
| src/Dao/SQLite/SQLiteLightDao.cpp | ||
| src/Dao/SQLite/SQLiteLightDao.h | ||
| src/Dao/SQLite/SQLiteFlightPlanDao.cpp | ||
| src/Dao/SQLite/SQLiteFlightPlanDao.h | ||
| src/Dao/SQLite/SqlMigration.cpp | ||
| src/Dao/SQLite/SqlMigration.h | ||
| src/Dao/SQLite/SqlMigrationStep.cpp | ||
| src/Dao/SQLite/SqlMigrationStep.h | ||
| src/Dao/SQLite/Migration/migr-ex-ante.sql | ||
| src/Dao/SQLite/Migration/migr-ddl.sql | ||
| src/Dao/SQLite/Migration/migr-ex-post.sql | ||
| src/Dao/SQLite/Migration/Migration.qrc | ||
| src/Service/ScenarioService.cpp | ||
| src/Service/ScenarioService.h | ||
| src/Service/AircraftService.cpp | ||
| src/Service/AircraftService.h | ||
| src/Service/DatabaseService.cpp | ||
| src/Service/DatabaseService.h | ||
| src/Service/CSVService.cpp | ||
| src/Service/CSVService.h | ||
| src/CSVConst.cpp | ||
| src/CSVConst.h | ||
| src/Export/CSVExport.cpp | ||
| src/Export/CSVExport.h | ||
| src/Import/CSVImport.cpp | ||
| src/Import/CSVImport.h | ||
| ) | ||
|
|
||
| set(PERSISTENCE_LIBS | ||
| Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Sql Kernel Model | ||
| ) | ||
| if (APPLE) | ||
| list(APPEND PERSISTENCE_LIBS -lc++) | ||
| endif() | ||
|
|
||
| target_link_libraries(Persistence PRIVATE ${PERSISTENCE_LIBS}) | ||
| set_target_properties(Persistence PROPERTIES VERSION ${PROJECT_VERSION}) | ||
| set_target_properties(Persistence PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR}) | ||
|
|
||
| target_include_directories(Persistence PUBLIC | ||
| "${CMAKE_CURRENT_BINARY_DIR}" | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| /** | ||
| * 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 <memory> | ||
|
|
||
| #include <QString> | ||
|
|
||
| #include "../../Kernel/src/Settings.h" | ||
| #include "Metadata.h" | ||
| #include "Dao/DaoFactory.h" | ||
| #include "Dao/DatabaseDaoIntf.h" | ||
| #include "ConnectionManager.h" | ||
|
|
||
| class ConnectionManagerPrivate | ||
| { | ||
| public: | ||
|
|
||
| std::unique_ptr<DaoFactory> daoFactory; | ||
| std::unique_ptr<DatabaseDaoIntf> databaseDao; | ||
| QString libraryPath; | ||
| bool connected; | ||
|
|
||
| static ConnectionManager *instance; | ||
|
|
||
| ConnectionManagerPrivate() noexcept | ||
| : daoFactory(std::make_unique<DaoFactory>(DaoFactory::DbType::SQLite)), | ||
| databaseDao(daoFactory->createDatabaseDao()), | ||
| connected(false) | ||
| {} | ||
| }; | ||
|
|
||
| ConnectionManager *ConnectionManagerPrivate::instance = nullptr; | ||
|
|
||
| // PUBLIC | ||
|
|
||
| ConnectionManager &ConnectionManager::getInstance() noexcept | ||
| { | ||
| if (ConnectionManagerPrivate::instance == nullptr) { | ||
| ConnectionManagerPrivate::instance = new ConnectionManager(); | ||
| } | ||
| return *ConnectionManagerPrivate::instance; | ||
| } | ||
|
|
||
| void ConnectionManager::destroyInstance() noexcept | ||
| { | ||
| if (ConnectionManagerPrivate::instance != nullptr) { | ||
| delete ConnectionManagerPrivate::instance; | ||
| ConnectionManagerPrivate::instance = nullptr; | ||
| } | ||
| } | ||
|
|
||
| bool ConnectionManager::connectDb(const QString &libraryPath) noexcept | ||
| { | ||
| if (d->libraryPath != libraryPath) { | ||
| d->connected = d->databaseDao->connectDb(libraryPath); | ||
| d->libraryPath = libraryPath; | ||
| emit connectionChanged(d->connected); | ||
| } | ||
| return d->connected; | ||
| } | ||
|
|
||
| void ConnectionManager::disconnectDb() noexcept | ||
| { | ||
| d->databaseDao->disconnectDb(); | ||
| d->connected = false; | ||
| emit connectionChanged(d->connected); | ||
| } | ||
|
|
||
| bool ConnectionManager::isConnected() const noexcept | ||
| { | ||
| return d->connected; | ||
| } | ||
|
|
||
| const QString &ConnectionManager::getLibraryPath() const noexcept | ||
| { | ||
| return d->libraryPath; | ||
| } | ||
|
|
||
| bool ConnectionManager::migrate() noexcept | ||
| { | ||
| return d->databaseDao->migrate(); | ||
| } | ||
|
|
||
| bool ConnectionManager::optimise() noexcept | ||
| { | ||
| emit connectionChanged(d->connected); | ||
| return d->databaseDao->optimise(); | ||
| } | ||
|
|
||
| bool ConnectionManager::backup(const QString &backupLibraryPath) noexcept | ||
| { | ||
| emit connectionChanged(d->connected); | ||
| return d->databaseDao->backup(backupLibraryPath); | ||
| } | ||
|
|
||
| bool ConnectionManager::getMetadata(Metadata &metadata) noexcept | ||
| { | ||
| return d->databaseDao->getMetadata(metadata); | ||
| } | ||
|
|
||
| // PROTECTED | ||
|
|
||
| ConnectionManager::~ConnectionManager() noexcept | ||
| {} | ||
|
|
||
| // PRIVATE | ||
|
|
||
| ConnectionManager::ConnectionManager() noexcept | ||
| : d(std::make_unique<ConnectionManagerPrivate>()) | ||
| {} | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| #ifndef CONNECTIONMANAGER_H | ||
| #define CONNECTIONMANAGER_H | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include <QObject> | ||
|
|
||
| class QString; | ||
|
|
||
| class Metadata; | ||
|
|
||
| #include "PersistenceLib.h" | ||
|
|
||
| class ConnectionManagerPrivate; | ||
|
|
||
| class ConnectionManager : public QObject | ||
| { | ||
| Q_OBJECT | ||
| public: | ||
| static ConnectionManager &getInstance() noexcept; | ||
| PERSISTENCE_API static void destroyInstance() noexcept; | ||
|
|
||
| bool connectDb(const QString &libraryPath) noexcept; | ||
| void disconnectDb() noexcept; | ||
| bool isConnected() const noexcept; | ||
| const QString &getLibraryPath() const noexcept; | ||
|
|
||
| bool migrate() noexcept; | ||
| bool optimise() noexcept; | ||
| bool backup(const QString &backupLibraryPath) noexcept; | ||
| bool getMetadata(Metadata &metadata) noexcept; | ||
|
|
||
| signals: | ||
| void connectionChanged(bool connected); | ||
|
|
||
| protected: | ||
| virtual ~ConnectionManager() noexcept; | ||
|
|
||
| private: | ||
| Q_DISABLE_COPY(ConnectionManager) | ||
| std::unique_ptr<ConnectionManagerPrivate> d; | ||
|
|
||
| ConnectionManager() noexcept; | ||
| }; | ||
|
|
||
| #endif // CONNECTIONMANAGER_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| #ifndef AIRCRAFTDAOINTF_H | ||
| #define AIRCRAFTDAOINTF_H | ||
|
|
||
| #include <QtGlobal> | ||
|
|
||
| class Aircraft; | ||
|
|
||
| class AircraftDaoIntf | ||
| { | ||
| public: | ||
| virtual ~AircraftDaoIntf() = default; | ||
|
|
||
| /*! | ||
| * Persists the \c aircraft. The \c id in \c aircraft is updated. | ||
| * | ||
| * \param scenarioId | ||
| * the scenario the \c aircraft belongs to | ||
| * \param sequenceNumber | ||
| * the sequence number of the aircraft | ||
| * \param aircraft | ||
| * the aircraft to be persisted | ||
| * \return \c true on success; \c false else | ||
| */ | ||
| virtual bool add(qint64 scenarioId, int sequenceNumber, Aircraft &aircraft) = 0; | ||
| virtual bool getById(qint64 id, Aircraft &aircraft) const = 0; | ||
| virtual bool getByScenarioId(qint64 scenarioId, int sequenceNumber, Aircraft &aircraft) const = 0; | ||
| virtual bool deleteByScenarioId(qint64 scenarioId) = 0; | ||
| }; | ||
|
|
||
| #endif // AIRCRAFTDAOINTF_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,185 @@ | ||
| /** | ||
| * 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 <memory> | ||
|
|
||
| #include "SQLite/SQLiteDatabaseDao.h" | ||
| #include "SQLite/SQLiteScenarioDao.h" | ||
| #include "SQLite/SQLiteAircraftDao.h" | ||
| #include "SQLite/SQLitePositionDao.h" | ||
| #include "SQLite/SQLiteEngineDao.h" | ||
| #include "SQLite/SQLitePrimaryFlightControlDao.h" | ||
| #include "SQLite/SQLiteSecondaryFlightControlDao.h" | ||
| #include "SQLite/SQLiteHandleDao.h" | ||
| #include "SQLite/SQLiteLightDao.h" | ||
| #include "SQLite/SQLiteFlightPlanDao.h" | ||
| #include "ScenarioDaoIntf.h" | ||
| #include "AircraftDaoIntf.h" | ||
| #include "PositionDaoIntf.h" | ||
| #include "EngineDaoIntf.h" | ||
| #include "PrimaryFlightControlDaoIntf.h" | ||
| #include "SecondaryFlightControlDaoIntf.h" | ||
| #include "HandleDaoIntf.h" | ||
| #include "LightDaoIntf.h" | ||
| #include "FlightPlanDaoIntf.h" | ||
| #include "DaoFactory.h" | ||
|
|
||
| class DaoFactoryPrivate | ||
| { | ||
| public: | ||
| DaoFactoryPrivate(DaoFactory::DbType theDbType) | ||
| : dbType(theDbType) | ||
| {} | ||
|
|
||
| DaoFactory::DbType dbType; | ||
| }; | ||
|
|
||
| // PUBLIC | ||
|
|
||
| DaoFactory::DaoFactory(DbType dbType) | ||
| : d(std::make_unique<DaoFactoryPrivate>(dbType)) | ||
| {} | ||
|
|
||
| DaoFactory::~DaoFactory() | ||
| {} | ||
|
|
||
| std::unique_ptr<DatabaseDaoIntf> DaoFactory::createDatabaseDao() noexcept | ||
| { | ||
| switch (d->dbType) { | ||
| case DbType::SQLite: | ||
| return std::make_unique<SQLiteDatabaseDao>(); | ||
| break; | ||
| default: | ||
| return nullptr; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| std::unique_ptr<ScenarioDaoIntf> DaoFactory::createScenarioDao() noexcept | ||
| { | ||
| switch (d->dbType) { | ||
| case DbType::SQLite: | ||
| return std::make_unique<SQLiteScenarioDao>(); | ||
| break; | ||
| default: | ||
| return nullptr; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| std::unique_ptr<AircraftDaoIntf> DaoFactory::createAircraftDao() noexcept | ||
| { | ||
| switch (d->dbType) { | ||
| case DbType::SQLite: | ||
| return std::make_unique<SQLiteAircraftDao>(); | ||
| break; | ||
| default: | ||
| return nullptr; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| std::unique_ptr<PositionDaoIntf> DaoFactory::createPositionDao() noexcept | ||
| { | ||
| switch (d->dbType) { | ||
| case DbType::SQLite: | ||
| return std::make_unique<SQLitePositionDao>(); | ||
| break; | ||
| default: | ||
| return nullptr; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| std::unique_ptr<EngineDaoIntf> DaoFactory::createEngineDao() noexcept | ||
| { | ||
| switch (d->dbType) { | ||
| case DbType::SQLite: | ||
| return std::make_unique<SQLiteEngineDao>(); | ||
| break; | ||
| default: | ||
| return nullptr; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| std::unique_ptr<PrimaryFlightControlDaoIntf> DaoFactory::createPrimaryFlightControlDao() noexcept | ||
| { | ||
| switch (d->dbType) { | ||
| case DbType::SQLite: | ||
| return std::make_unique<SQLitePrimaryFlightControlDao>(); | ||
| break; | ||
| default: | ||
| return nullptr; | ||
| break; | ||
| } | ||
| }; | ||
|
|
||
| std::unique_ptr<SecondaryFlightControlDaoIntf> DaoFactory::createSecondaryFlightControlDao() noexcept | ||
| { | ||
| switch (d->dbType) { | ||
| case DbType::SQLite: | ||
| return std::make_unique<SQLiteSecondaryFlightControlDao>(); | ||
| break; | ||
| default: | ||
| return nullptr; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| std::unique_ptr<HandleDaoIntf> DaoFactory::createHandleDao() noexcept | ||
| { | ||
| switch (d->dbType) { | ||
| case DbType::SQLite: | ||
| return std::make_unique<SQLiteHandleDao>(); | ||
| break; | ||
| default: | ||
| return nullptr; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| std::unique_ptr<LightDaoIntf> DaoFactory::createLightDao() noexcept | ||
| { | ||
| switch (d->dbType) { | ||
| case DbType::SQLite: | ||
| return std::make_unique<SQLiteLightDao>(); | ||
| break; | ||
| default: | ||
| return nullptr; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| std::unique_ptr<FlightPlanDaoIntf> DaoFactory::createFlightPlanDao() noexcept | ||
| { | ||
| switch (d->dbType) { | ||
| case DbType::SQLite: | ||
| return std::make_unique<SQLiteFlightPlanDao>(); | ||
| break; | ||
| default: | ||
| return nullptr; | ||
| break; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| #ifndef DAOFACTORY_H | ||
| #define DAOFACTORY_H | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "ScenarioDaoIntf.h" | ||
| #include "AircraftDaoIntf.h" | ||
| #include "PositionDaoIntf.h" | ||
| #include "EngineDaoIntf.h" | ||
| #include "PrimaryFlightControlDaoIntf.h" | ||
| #include "SecondaryFlightControlDaoIntf.h" | ||
| #include "HandleDaoIntf.h" | ||
| #include "LightDaoIntf.h" | ||
| #include "FlightPlanDaoIntf.h" | ||
| #include "DatabaseDaoIntf.h" | ||
|
|
||
| class DaoFactoryPrivate; | ||
|
|
||
| class DaoFactory | ||
| { | ||
| public: | ||
|
|
||
| enum class DbType | ||
| { | ||
| SQLite = 0 | ||
| }; | ||
|
|
||
| DaoFactory(DbType dbType); | ||
| ~DaoFactory(); | ||
|
|
||
| std::unique_ptr<DatabaseDaoIntf> createDatabaseDao() noexcept; | ||
| std::unique_ptr<ScenarioDaoIntf> createScenarioDao() noexcept; | ||
| std::unique_ptr<AircraftDaoIntf> createAircraftDao() noexcept; | ||
| std::unique_ptr<PositionDaoIntf> createPositionDao() noexcept; | ||
| std::unique_ptr<EngineDaoIntf> createEngineDao() noexcept; | ||
| std::unique_ptr<PrimaryFlightControlDaoIntf> createPrimaryFlightControlDao() noexcept; | ||
| std::unique_ptr<SecondaryFlightControlDaoIntf> createSecondaryFlightControlDao() noexcept; | ||
| std::unique_ptr<HandleDaoIntf> createHandleDao() noexcept; | ||
| std::unique_ptr<LightDaoIntf> createLightDao() noexcept; | ||
| std::unique_ptr<FlightPlanDaoIntf> createFlightPlanDao() noexcept; | ||
|
|
||
| private: | ||
| std::unique_ptr<DaoFactoryPrivate> d; | ||
| }; | ||
|
|
||
| #endif // DAOFACTORY_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| #ifndef DATABASEDAOINTF_H | ||
| #define DATABASEDAOINTF_H | ||
|
|
||
| class QString; | ||
|
|
||
| #include "../Metadata.h" | ||
|
|
||
| class DatabaseDaoIntf | ||
| { | ||
| public: | ||
| virtual ~DatabaseDaoIntf() = default; | ||
|
|
||
| virtual bool connectDb(const QString &libraryPath) = 0; | ||
| virtual void disconnectDb() = 0; | ||
|
|
||
| virtual bool migrate() = 0; | ||
| virtual bool optimise() = 0; | ||
| virtual bool backup(const QString &backupPath) = 0; | ||
|
|
||
| virtual bool getMetadata(Metadata &metadata) const = 0; | ||
| }; | ||
|
|
||
| #endif // DATABASEDAOINTF_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| #ifndef ENGINEDAOINTF_H | ||
| #define ENGINEDAOINTF_H | ||
|
|
||
| #include <QVector> | ||
|
|
||
| class EngineData; | ||
|
|
||
| class EngineDaoIntf | ||
| { | ||
| public: | ||
| virtual ~EngineDaoIntf() = default; | ||
|
|
||
| /*! | ||
| * Persists the \c data. | ||
| * | ||
| * \param aircraftId | ||
| * the aircraft the \c data belongs to | ||
| * \param data | ||
| * the EngineData to be persisted | ||
| * \return \c true on success; \c false else | ||
| */ | ||
| virtual bool add(qint64 aircraftId, const EngineData &data) = 0; | ||
| virtual bool getByAircraftId(qint64 aircraftId, QVector<EngineData> &data) const = 0; | ||
| virtual bool deleteByScenarioId(qint64 scenarioId) = 0; | ||
| }; | ||
|
|
||
|
|
||
| #endif // ENGINEDAOINTF_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| #ifndef FLIGHTPLANDAOINTF_H | ||
| #define FLIGHTPLANDAOINTF_H | ||
|
|
||
| class FlightPlanData; | ||
|
|
||
| class FlightPlanDaoIntf | ||
| { | ||
| public: | ||
| virtual ~FlightPlanDaoIntf() = default; | ||
|
|
||
| /*! | ||
| * Persists the \c data. | ||
| * | ||
| * \param aircraftId | ||
| * the aircraft the \c data belongs to | ||
| * \param data | ||
| * the FlightPlanData to be persisted | ||
| * \return \c true on success; \c false else | ||
| */ | ||
| virtual bool add(qint64 aircraftId, const QVector<FlightPlanData> &data) = 0; | ||
| virtual bool getByAircraftId(qint64 aircraftId, QVector<FlightPlanData> &data) const = 0; | ||
| virtual bool deleteByScenarioId(qint64 scenarioId) = 0; | ||
| }; | ||
|
|
||
| #endif // FLIGHTPLANDAOINTF_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| #ifndef HANDLEDAOINTF_H | ||
| #define HANDLEDAOINTF_H | ||
|
|
||
| #include <QVector> | ||
|
|
||
| class AircraftHandleData; | ||
|
|
||
| class HandleDaoIntf | ||
| { | ||
| public: | ||
| virtual ~HandleDaoIntf() = default; | ||
|
|
||
| /*! | ||
| * Persists the \c data. | ||
| * | ||
| * \param aircraftId | ||
| * the aircraft the \c data belongs to | ||
| * \param data | ||
| * the AircraftHandleData to be persisted | ||
| * \return \c true on success; \c false else | ||
| */ | ||
| virtual bool add(qint64 aircraftId, const AircraftHandleData &data) = 0; | ||
| virtual bool getByAircraftId(qint64 aircraftId, QVector<AircraftHandleData> &data) const = 0; | ||
| virtual bool deleteByScenarioId(qint64 scenarioId) = 0; | ||
| }; | ||
|
|
||
| #endif // HANDLEDAOINTF_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| #ifndef LIGHTDAOINTF_H | ||
| #define LIGHTDAOINTF_H | ||
|
|
||
| class LightData; | ||
|
|
||
| class LightDaoIntf | ||
| { | ||
| public: | ||
| virtual ~LightDaoIntf() = default; | ||
|
|
||
| /*! | ||
| * Persists the \c data. | ||
| * | ||
| * \param aircraftId | ||
| * the aircraft the \c data belongs to | ||
| * \param data | ||
| * the LightData to be persisted | ||
| * \return \c true on success; \c false else | ||
| */ | ||
| virtual bool add(qint64 aircraftId, const LightData &lightData) = 0; | ||
| virtual bool getByAircraftId(qint64 aircraftId, QVector<LightData> &data) const = 0; | ||
| virtual bool deleteByScenarioId(qint64 scenarioId) = 0; | ||
| }; | ||
|
|
||
| #endif // LIGHTDAOINTF_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| #ifndef POSITIONDAOINTF_H | ||
| #define POSITIONDAOINTF_H | ||
|
|
||
| #include <QVector> | ||
|
|
||
| class AircraftData; | ||
|
|
||
| class PositionDaoIntf | ||
| { | ||
| public: | ||
| virtual ~PositionDaoIntf() = default; | ||
|
|
||
| /*! | ||
| * Persists the \c data. | ||
| * | ||
| * \param aircraftId | ||
| * the aircraft the \c data belongs to | ||
| * \param data | ||
| * the AircraftData to be persisted | ||
| * \return \c true on success; \c false else | ||
| */ | ||
| virtual bool add(qint64 aircraftId, const AircraftData &data) = 0; | ||
| virtual bool getByAircraftId(qint64 aircraftId, QVector<AircraftData> &data) const = 0; | ||
| virtual bool deleteByScenarioId(qint64 scenarioId) = 0; | ||
| }; | ||
|
|
||
| #endif // POSITIONDAOINTF_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| #ifndef PRIMARYFLIGHTCONTROLDAOINTF_H | ||
| #define PRIMARYFLIGHTCONTROLDAOINTF_H | ||
|
|
||
| #include <QVector> | ||
|
|
||
| class PrimaryFlightControlData; | ||
|
|
||
| class PrimaryFlightControlDaoIntf | ||
| { | ||
| public: | ||
| virtual ~PrimaryFlightControlDaoIntf() = default; | ||
|
|
||
| /*! | ||
| * Persists the \c data. | ||
| * | ||
| * \param aircraftId | ||
| * the aircraft the \c data belongs to | ||
| * \param data | ||
| * the SecondaryFlightControlData to be persisted | ||
| * \return \c true on success; \c false else | ||
| */ | ||
| virtual bool add(qint64 aircraftId, const PrimaryFlightControlData &primaryFlightControlData) = 0; | ||
| virtual bool getByAircraftId(qint64 aircraftId, QVector<PrimaryFlightControlData> &data) const = 0; | ||
| virtual bool deleteByScenarioId(qint64 scenarioId) = 0; | ||
| }; | ||
|
|
||
| #endif // PRIMARYFLIGHTCONTROLDAOINTF_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| /** | ||
| * 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 <QFile> | ||
| #include <QTextStream> | ||
| #include <QRegularExpression> | ||
|
|
||
| #include "DbMigration.h" | ||
|
|
||
| class DbMigrationPrivate | ||
| { | ||
| public: | ||
| DbMigrationPrivate() | ||
| {} | ||
| }; | ||
|
|
||
| // PUBLIC | ||
|
|
||
| DbMigration::DbMigration() | ||
| : d(std::make_unique<DbMigrationPrivate>()) | ||
| { | ||
| } | ||
|
|
||
| DbMigration::~DbMigration() | ||
| {} | ||
|
|
||
| bool DbMigration::migrateExAnte() noexcept | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| bool DbMigration::migrateDdl() noexcept | ||
| { | ||
|
|
||
| Q_INIT_RESOURCE(Migration); | ||
|
|
||
| QFile migr(":/dao/sqlite/migr/migr-ddl.sql"); | ||
| migr.open(QFile::OpenModeFlag::ReadOnly | QFile::OpenModeFlag::Text); | ||
|
|
||
| QTextStream textStream(&migr); | ||
| QStringList lines; | ||
| while (!textStream.atEnd()) { | ||
| lines += textStream.readLine(); | ||
| } | ||
|
|
||
| for (const QString &line : std::as_const(lines)) { | ||
| if (line.trimmed().startsWith("@migr")) { | ||
| // https://regex101.com/ | ||
| const QRegularExpression regexp("@migr\\(([\\w=\"\\-,.\\s]+)\\)"); | ||
| QRegularExpressionMatch match = regexp.match(line); | ||
| if (match.hasMatch()) { | ||
| QString migrTag = match.captured(); | ||
| qDebug("migration: %s", qPrintable(migrTag)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| migr.close(); | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| bool DbMigration::migrateExPost() noexcept | ||
| { | ||
| return true; | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| #ifndef DBMIGRATION_H | ||
| #define DBMIGRATION_H | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include <QString> | ||
|
|
||
| class DbMigrationPrivate; | ||
|
|
||
| class DbMigration | ||
| { | ||
| public: | ||
| DbMigration(); | ||
| ~DbMigration(); | ||
|
|
||
| bool migrateExAnte() noexcept; | ||
| bool migrateDdl() noexcept; | ||
| bool migrateExPost() noexcept; | ||
|
|
||
| private: | ||
| std::unique_ptr<DbMigrationPrivate> d; | ||
| }; | ||
|
|
||
| #endif // DBMIGRATION_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <RCC> | ||
| <qresource prefix="/dao/sqlite/migr"> | ||
| <file>migr-ddl.sql</file> | ||
| <file>migr-ex-ante.sql</file> | ||
| <file>migr-ex-post.sql</file> | ||
| </qresource> | ||
| </RCC> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| @migr(id = "4a66fae6-d70a-4230-ad1e-0db27c9b1466", descn = "Create meta info table", step_cnt = 2) | ||
| create table meta ( | ||
| creation_date datetime, | ||
| last_optim_date datetime, | ||
| last_backup_date datetime | ||
| ); | ||
|
|
||
| @migr(id = "da30cf74-c698-4a73-bad1-c1cf3f380f32", descn = "Create scenario table", step_cnt = 1) | ||
| create table scenario ( | ||
| id integer primary key, | ||
| creation_date datetime default current_timestamp, | ||
| description text, | ||
| surface_type integer, | ||
| ground_altitude real, | ||
| ambient_temperature real, | ||
| total_air_temperature real, | ||
| wind_velocity real, | ||
| wind_direction real, | ||
| visibility real, | ||
| sea_level_pressure real, | ||
| pitot_icing real, | ||
| structural_icing real, | ||
| precipitation_state integer, | ||
| in_clouds integer, | ||
| local_sim_time datetime, | ||
| zulu_sim_time datetime | ||
| ); | ||
|
|
||
| @migr(id = "1fb17949-6c94-4bbf-98a2-ff54fe3a749f", descn = "Create aircraft table", step_cnt = 1) | ||
| create table aircraft ( | ||
| id integer primary key, | ||
| scenario_id integer not null, | ||
| seq_nr integer not null, | ||
| start_date datetime, | ||
| end_date datetime, | ||
| type text, | ||
| tail_number text, | ||
| airline text, | ||
| flight_number text, | ||
| category integer, | ||
| initial_airspeed integer, | ||
| wing_span integer, | ||
| engine_type integer, | ||
| nof_engines integer, | ||
| altitude_above_ground real, | ||
| start_on_ground integer, | ||
| foreign key(scenario_id) references scenario(id) | ||
| ); | ||
| create unique index aircraft_idx1 on aircraft (scenario_id, seq_nr); | ||
|
|
||
| @migr(id = "9b831594-f6c2-489c-906d-2de31bb9788b", descn = "Create position table", step_cnt = 1) | ||
| create table position ( | ||
| aircraft_id integer not null, | ||
| timestamp integer not null, | ||
| latitude real, | ||
| longitude real, | ||
| altitude real, | ||
| pitch real, | ||
| bank real, | ||
| heading real, | ||
| velocity_x real, | ||
| velocity_y real, | ||
| velocity_z real, | ||
| rotation_velocity_x real, | ||
| rotation_velocity_y real, | ||
| rotation_velocity_z real, | ||
| primary key(aircraft_id, timestamp), | ||
| foreign key(aircraft_id) references aircraft(id) | ||
| ); | ||
|
|
||
| @migr(id = "0f5e5cc3-8977-4de0-be15-104f3ab045aa", descn = "Create engine table", step_cnt = 1) | ||
| create table engine ( | ||
| aircraft_id integer not null, | ||
| timestamp integer not null, | ||
| throttle_lever_position1 real, | ||
| throttle_lever_position2 real, | ||
| throttle_lever_position3 real, | ||
| throttle_lever_position4 real, | ||
| propeller_lever_position1 real, | ||
| propeller_lever_position2 real, | ||
| propeller_lever_position3 real, | ||
| propeller_lever_position4 real, | ||
| mixture_lever_position1 real, | ||
| mixture_lever_position2 real, | ||
| mixture_lever_position3 real, | ||
| mixture_lever_position4 real, | ||
| cowl_flap_position1 real, | ||
| cowl_flap_position2 real, | ||
| cowl_flap_position3 real, | ||
| cowl_flap_position4 real, | ||
| electrical_master_battery1 real, | ||
| electrical_master_battery2 real, | ||
| electrical_master_battery3 real, | ||
| electrical_master_battery4 real, | ||
| general_engine_starter1 real, | ||
| general_engine_starter2 real, | ||
| general_engine_starter3 real, | ||
| general_engine_starter4 real, | ||
| primary key(aircraft_id, timestamp), | ||
| foreign key(aircraft_id) references aircraft(id) | ||
| ); | ||
|
|
||
| @migr(id = "148779f2-44c5-4d8c-9c0a-06d6d8158655", descn = "Create primary flight controls table", step_cnt = 1) | ||
| create table primary_flight_control ( | ||
| aircraft_id integer not null, | ||
| timestamp integer not null, | ||
| rudder_position integer, | ||
| elevator_position integer, | ||
| aileron_position integer, | ||
| primary key(aircraft_id, timestamp), | ||
| foreign key(aircraft_id) references aircraft(id) | ||
| ); | ||
|
|
||
| @migr(id = "73f7c48a-53f4-42a7-ab1d-011266c8ead3", descn = "Create secondary flight controls table", step_cnt = 1) | ||
| create table secondary_flight_control ( | ||
| aircraft_id integer not null, | ||
| timestamp integer not null, | ||
| leading_edge_flaps_left_percent integer, | ||
| leading_edge_flaps_right_percent integer, | ||
| trailing_edge_flaps_left_percent integer, | ||
| trailing_edge_flaps_right_percent integer, | ||
| spoilers_handle_position integer, | ||
| flaps_handle_index integer, | ||
| primary key(aircraft_id, timestamp), | ||
| foreign key(aircraft_id) references aircraft(id) | ||
| ); | ||
|
|
||
| @migr(id = "b9a56065-d6ac-4572-bba0-39f7ba8a3169", descn = "Create handles and levers table", step_cnt = 1) | ||
| create table handle ( | ||
| aircraft_id integer not null, | ||
| timestamp integer not null, | ||
| brake_left_position integer, | ||
| brake_right_position integer, | ||
| water_rudder_handle_position integer, | ||
| tail_hook_position integer, | ||
| canopy_open integer, | ||
| gear_handle_position integer, | ||
| folding_wing_handle_position integer, | ||
| primary key(aircraft_id, timestamp), | ||
| foreign key(aircraft_id) references aircraft(id) | ||
| ); | ||
|
|
||
| @migr(id = "ae5cb680-41fa-40e8-8ea9-0777c3574bd4", descn = "Create lights table", step_cnt = 1) | ||
| create table light ( | ||
| aircraft_id integer not null, | ||
| timestamp integer not null, | ||
| light_states integer, | ||
| primary key(aircraft_id, timestamp), | ||
| foreign key(aircraft_id) references aircraft(id) | ||
| ); | ||
|
|
||
| @migr(id = "fb2a21ad-5b8d-4be0-ae94-33e63be2ef3a", descn = "Create flight plan table", step_cnt = 1) | ||
| create table flight_plan ( | ||
| aircraft_id integer not null, | ||
| seq_nr integer, | ||
| ident text, | ||
| latitude real, | ||
| longitude real, | ||
| altitude real, | ||
| primary key(aircraft_id, seq_nr), | ||
| foreign key(aircraft_id) references aircraft(id) | ||
| ); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| @migr(id = "4a66fae6-d70a-4230-ad1e-0db27c9b1466", descn = "Create meta info table", step = 2) | ||
| insert into meta (creation_date) | ||
| values (datetime('now')); |