row.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef ROW_H
  2. #define ROW_H
  3. #include "src/opl.h"
  4. namespace OPL {
  5. /*!
  6. * \brief The Row class provides an interface for retreiving and submitting entries from the database.
  7. * It is a bass class and when instantiated, the appropriate subclass should be used.
  8. */
  9. class Row
  10. {
  11. public:
  12. Row() { valid = false;} // Require specifying position
  13. Row(OPL::DbTable table_name, int row_id, const RowData_T &row_data);
  14. Row(OPL::DbTable table_name, int row_id);
  15. Row(OPL::DbTable table_name);
  16. Row(const Row&) = default;
  17. Row& operator=(const Row&) = default;
  18. RowData_T getData() const;
  19. void setData(const RowData_T &value);
  20. int getRowId() const;
  21. void setRowId(int value);
  22. OPL::DbTable getTableName() const;
  23. bool isValid() const {return hasData && valid;}
  24. // For Debugging
  25. operator QString() const;
  26. private:
  27. OPL::DbTable table;
  28. int rowId;
  29. RowData_T rowData;
  30. protected:
  31. bool hasData;
  32. bool valid = true;
  33. };
  34. class AircraftEntry : public Row
  35. {
  36. public:
  37. AircraftEntry();
  38. AircraftEntry(const RowData_T &row_data);
  39. AircraftEntry(int row_id, const RowData_T &row_data);
  40. };
  41. class TailEntry : public Row
  42. {
  43. public:
  44. TailEntry();
  45. TailEntry(const RowData_T &row_data);
  46. TailEntry(int row_id, const RowData_T &row_data);
  47. const QString registration() const;
  48. const QString type() const;
  49. };
  50. class PilotEntry : public Row
  51. {
  52. public:
  53. PilotEntry();
  54. PilotEntry(const RowData_T &row_data);
  55. PilotEntry(int row_id, const RowData_T &row_data);
  56. };
  57. class SimulatorEntry : public Row
  58. {
  59. public:
  60. SimulatorEntry();
  61. SimulatorEntry(const RowData_T &row_data);
  62. SimulatorEntry(int row_id, const RowData_T &row_data);
  63. };
  64. class FlightEntry : public Row
  65. {
  66. public:
  67. FlightEntry();
  68. FlightEntry(const RowData_T &row_data);
  69. FlightEntry(int row_id, const RowData_T &row_data);
  70. };
  71. class CurrencyEntry : public Row
  72. {
  73. public:
  74. CurrencyEntry();
  75. CurrencyEntry(const RowData_T &row_data);
  76. CurrencyEntry(int row_id, const RowData_T &row_data);
  77. };
  78. } // namespace OPL
  79. #endif // ROW_H