2019-07-06 14:52:01 +00:00
|
|
|
#include "headers/Interface.h"
|
2019-06-27 03:55:27 +00:00
|
|
|
|
|
|
|
/*
|
2019-07-02 17:53:45 +00:00
|
|
|
Code structure is like this:
|
|
|
|
1. encrypt.cpp en /header/encrypt.h contain functions to hash passwords and
|
|
|
|
verify passwords
|
|
|
|
|
|
|
|
2. data.cpp and /header/data.h contain the code to start up the database.
|
|
|
|
Originally, they were supposed to contain all the functions to save to the
|
|
|
|
database and query from the database. I had trouble doing that, (cyclical
|
|
|
|
includes) and some other issues. the other issues are gone due to the latest
|
|
|
|
refactor, but to make it like my original plan is going to take a few hours, and
|
|
|
|
I have done too much already to want to do more work unless needed.
|
|
|
|
The functions to save to a database have been integrated in the classes
|
|
|
|
themself, and unless issues arrise from that I'm not changing that. Functions to
|
|
|
|
get objects from the database are in Query.cpp en header.
|
|
|
|
|
|
|
|
3. Park_time.cpp en header.
|
|
|
|
Contain the implementation details of Park_time, which is basically a record of
|
|
|
|
who parked at what spot and when. Uses a mix of ctime and chrono functions to do
|
|
|
|
most of the stuff, it's a mess. I will probably have to commit to Doing it one
|
|
|
|
way or the other to make it more comperhensible, especially for whoever will
|
|
|
|
make report functions.
|
|
|
|
|
|
|
|
4. Customer.cpp and header.
|
|
|
|
Contains the implementation of Customer. Customer represents a customer, and
|
|
|
|
saves park_time instances in itself. Not much to explain.
|
|
|
|
|
|
|
|
5. Park_spot.cpp and header.
|
|
|
|
It contians the implementation details of Park_spot, which represents it's
|
|
|
|
namesake.
|
|
|
|
|
|
|
|
6. Query.cpp and header.
|
|
|
|
Cointain functions that search the database and return objects(P_time, P_spot,
|
|
|
|
Customer) It is the least tested of the whole project, use with care.
|
|
|
|
|
|
|
|
Explanation of what members do of P_time, P_spot, Customer are in the respective
|
|
|
|
headers. Explanations of how the member functions work(Or how I intended for
|
|
|
|
them to work) are in the respective .cpp files. void Wait(int sec)
|
2019-06-27 03:55:27 +00:00
|
|
|
*/
|
|
|
|
|
2019-07-02 17:53:45 +00:00
|
|
|
static vector<Park_spot> parking_spots = populate_spots();
|
|
|
|
// this queries the db for all the saved parking_spots and initializes them
|
|
|
|
static vector<Customer> park_customers;
|
2019-07-02 01:11:46 +00:00
|
|
|
|
2019-06-30 17:49:20 +00:00
|
|
|
int main() {
|
2019-07-06 15:14:18 +00:00
|
|
|
// state of db:
|
|
|
|
// er zijn 10 parkspots, 5 met biketype en 5 met pickup type
|
2019-07-06 14:52:01 +00:00
|
|
|
// er is een customer met id 1(testcustomer) met password "password"
|
2019-07-16 21:26:49 +00:00
|
|
|
do { interface(parking_spots);} while (true);
|
2019-07-01 17:23:15 +00:00
|
|
|
}
|
2019-07-02 01:11:46 +00:00
|
|
|
|
2019-07-02 17:53:45 +00:00
|
|
|
/*
|
|
|
|
Why is this not in query.cpp? Because somehow, it errors out when it's there.
|
|
|
|
The error message indicates it is a memory issue but I suspect it's a
|
|
|
|
concurrency issue. Do not move this.
|
|
|
|
*/
|
|
|
|
vector<Park_spot> populate_spots() {
|
|
|
|
vector<Park_spot> spots;
|
|
|
|
SQLite::Statement query(data::db, "SELECT * FROM Park_spot WHERE id > 0;");
|
|
|
|
while (query.executeStep()) {
|
|
|
|
int id = query.getColumn(0);
|
|
|
|
int taken = query.getColumn(1);
|
|
|
|
int cid = query.getColumn(2);
|
2019-07-06 15:14:18 +00:00
|
|
|
Vehicle_type vtype = Vehicle_type(int(query.getColumn(3)));
|
|
|
|
spots.push_back({id, taken, cid, vtype});
|
2019-07-02 17:53:45 +00:00
|
|
|
}
|
|
|
|
return spots;
|
|
|
|
}
|