2
0

aentry.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. *openPilotLog - A FOSS Pilot Logbook Application
  3. *Copyright (C) 2020-2022 Felix Turowsky
  4. *
  5. *This program is free software: you can redistribute it and/or modify
  6. *it under the terms of the GNU General Public License as published by
  7. *the Free Software Foundation, either version 3 of the License, or
  8. *(at your option) any later version.
  9. *
  10. *This program is distributed in the hope that it will be useful,
  11. *but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. *GNU General Public License for more details.
  14. *
  15. *You should have received a copy of the GNU General Public License
  16. *along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. #ifndef AENTRY_H
  19. #define AENTRY_H
  20. #include <QString>
  21. #include <QStringList>
  22. #include <QHash>
  23. #include <QPair>
  24. #include <QVariant>
  25. #include "src/database/databasetypes.h"
  26. /*!
  27. * \brief The Entry class encapsulates table metadata(table name, row id)
  28. * and data for new and existing entries in the database to operate on.
  29. */
  30. class AEntry {
  31. protected:
  32. DataPosition position;
  33. public:
  34. RowData_T tableData;
  35. public:
  36. AEntry() = delete;
  37. AEntry(const AEntry&) = default;
  38. AEntry& operator=(const AEntry&) = default;
  39. AEntry(DataPosition position_);
  40. AEntry(RowData_T table_data);
  41. AEntry(DataPosition position_, RowData_T table_data);
  42. void setData(RowData_T table_data);
  43. void setPosition(DataPosition position_);
  44. const DataPosition& getPosition() const;
  45. const TableName_T &getTableName() const { return position.tableName; }
  46. const RowId_T &getRowId() const { return position.rowId; }
  47. const RowData_T& getData() const;
  48. /*!
  49. * \brief operator QString provides compatibilty with QDebug() - prints
  50. * the tableData in a readable formatting to stdout
  51. */
  52. operator QString() const;
  53. };
  54. #endif // AENTRY_H