aentry.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. *openPilotLog - A FOSS Pilot Logbook Application
  3. *Copyright (C) 2020-2021 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 <QMap>
  23. #include <QPair>
  24. #include <QVariant>
  25. #include "src/database/adatabasetypes.h"
  26. // [G]: Define what data is public and what not. For objects such as
  27. // DataPosition which are consumable its no biggy. Are entries the same?
  28. // If so we could avoid getters and setters
  29. // [F]: In the way we are using the entries atm, we do access and edit the
  30. // TableData quite frequently. Maybe the data could be public, but the
  31. // position private? Except for creating a new entry, the position should
  32. // never really be changed.
  33. /*!
  34. * \brief The Entry class encapsulates table metadata(table name, row id)
  35. * and data for new and existing entries in the database to operate on.
  36. */
  37. class AEntry {
  38. protected:
  39. DataPosition position;
  40. public:
  41. RowData_T tableData;
  42. public:
  43. AEntry() = delete; // Demand specificity from default constructor
  44. AEntry(const AEntry&) = default;
  45. AEntry& operator=(const AEntry&) = default;
  46. AEntry(DataPosition position_);
  47. AEntry(RowData_T table_data);
  48. AEntry(DataPosition position_, RowData_T table_data);
  49. void setData(RowData_T table_data);
  50. void setPosition(DataPosition position_);
  51. const DataPosition& getPosition();
  52. const RowData_T& getData();
  53. };
  54. #endif // AENTRY_H