openPilotLog
row.h
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 
19 #ifndef ROW_H
20 #define ROW_H
21 #include "src/opl.h"
22 
23 namespace OPL {
24 
45 class Row
46 {
47 public:
48  Row() { valid = false;} // Require specifying position
49  Row(OPL::DbTable table_name, int row_id, const RowData_T &row_data);
50  Row(OPL::DbTable table_name, int row_id);
51  Row(OPL::DbTable table_name);
52 
53  Row(const Row&) = default;
54  Row& operator=(const Row&) = default;
55 
56  RowData_T getData() const;
57  void setData(const RowData_T &value);
58  int getRowId() const;
59  void setRowId(int value);
60  OPL::DbTable getTable() const;
61  const QString getTableName() const;
62  const QString getPosition() const;
63 
64  bool isValid() const {return hasData && valid;}
65 
69  operator QString() const;
70 
71 
72 private:
73  OPL::DbTable table;
74  int rowId;
75  RowData_T rowData;
76 protected:
77  bool hasData;
78  bool valid = true;
79 };
80 
84 class AircraftEntry : public Row
85 {
86 public:
87  AircraftEntry();
88  AircraftEntry(const RowData_T &row_data);
89  AircraftEntry(int row_id, const RowData_T &row_data);
90 };
91 
95 class TailEntry : public Row
96 {
97 public:
98  TailEntry();
99  TailEntry(const RowData_T &row_data);
100  TailEntry(int row_id, const RowData_T &row_data);
101 
102  const QString registration() const;
103  const QString type() const;
104 };
105 
109 class PilotEntry : public Row
110 {
111 public:
112  PilotEntry();
113  PilotEntry(const RowData_T &row_data);
114  PilotEntry(int row_id, const RowData_T &row_data);
115 
116 };
117 
121 class SimulatorEntry : public Row
122 {
123 public:
124  SimulatorEntry();
125  SimulatorEntry(const RowData_T &row_data);
126  SimulatorEntry(int row_id, const RowData_T &row_data);
127 };
128 
132 class FlightEntry : public Row
133 {
134 public:
135  FlightEntry();
136  FlightEntry(const RowData_T &row_data);
137  FlightEntry(int row_id, const RowData_T &row_data);
138 };
139 
143 class CurrencyEntry : public Row
144 {
145 public:
146  CurrencyEntry();
147  CurrencyEntry(const RowData_T &row_data);
148  CurrencyEntry(int row_id, const RowData_T &row_data);
149 };
150 
154 class AirportEntry : public Row
155 {
156 public:
157  AirportEntry();
158  AirportEntry(const RowData_T &row_data);
159  AirportEntry(int row_id, const RowData_T &row_data);
160 };
161 
162 } // namespace OPL
163 #endif // ROW_H
A Row representing an Aircraft entry. See Row class for details.
Definition: row.h:85
A Row representing an Airport entry. See Row class for details.
Definition: row.h:155
A Row representing a Currency entry. See Row class for details.
Definition: row.h:144
A Row representing a Flight entry. See Row class for details.
Definition: row.h:133
A Row representing a Pilot entry. See Row class for details.
Definition: row.h:110
The Row class provides an interface for retreiving and submitting entries from the database.
Definition: row.h:46
A Row representing a Simulator entry. See Row class for details.
Definition: row.h:122
A Row representing a Tail (Registration) entry. See Row class for details.
Definition: row.h:96
A namespace to collect constants and enums used throughout the application.
Definition: paths.cpp:3
DbTable
Enumerates the tables in the database.
Definition: opl.h:122