2019-07-02 00:51:23 +00:00
|
|
|
#include "headers/Query.h"
|
2019-06-27 03:55:27 +00:00
|
|
|
|
2019-07-01 23:42:41 +00:00
|
|
|
#include <chrono>
|
2019-06-30 01:30:47 +00:00
|
|
|
#include <thread>
|
|
|
|
|
2019-07-01 23:42:41 +00:00
|
|
|
|
|
|
|
using namespace std::chrono;
|
2019-07-02 00:18:52 +00:00
|
|
|
|
2019-06-27 03:55:27 +00:00
|
|
|
/*
|
|
|
|
Code strucure like this:
|
|
|
|
class declarations zijn in /headers/class_naam.h, en definitions van de member
|
|
|
|
functs in /class_naam.cpp elke klas in zn eigen file omdat ik incomplete class
|
|
|
|
declarations wilt tegengaan, omdat ik ze niet goed begrijp. En header/source
|
|
|
|
split om multiple definition errors tegen te gaan.
|
|
|
|
|
|
|
|
Park_spot representeert een parkeermeter bij elke parkeer spot.
|
|
|
|
Een customer is een customer.
|
|
|
|
Park time is een object die reffereert naar parkspot en customer, basically een
|
|
|
|
record die zegt dat een customer voor x tijd geparkeert heeft bij spot x, enz.
|
|
|
|
|
|
|
|
De client clockt in en uit bij een spot.
|
|
|
|
*/
|
|
|
|
|
2019-06-30 17:49:20 +00:00
|
|
|
void Wait(int sec)
|
2019-06-30 01:30:47 +00:00
|
|
|
/*
|
|
|
|
a wait function where 1 sec represents 1 hour irl.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
std::this_thread::sleep_for(seconds{sec});
|
|
|
|
}
|
|
|
|
|
2019-07-02 01:11:46 +00:00
|
|
|
static vector<Park_spot> parking_spots = populate_spots(); // to save the parking spots in memory
|
|
|
|
static vector<Customer> park_customers; // save the customers that are parked in here
|
|
|
|
|
2019-06-30 17:49:20 +00:00
|
|
|
int main() {
|
2019-07-02 01:11:46 +00:00
|
|
|
Customer sagar = query_customer_with_name("stefan udit")[0];
|
|
|
|
Customer sagar1 = query_customer_with_id(2);
|
|
|
|
cout << sagar.id << "," << sagar.name << "," << sagar.password<< "\n";
|
|
|
|
cout << sagar1.id << "," << sagar1.name << "," << sagar1.password;
|
|
|
|
cout << parking_spots.size();
|
2019-07-02 00:51:23 +00:00
|
|
|
|
2019-07-02 01:11:46 +00:00
|
|
|
for (auto i : parking_spots){
|
|
|
|
cout << "\n" << i.id << "," << i.parked_customer;
|
|
|
|
}
|
2019-07-02 00:18:52 +00:00
|
|
|
|
2019-07-02 01:38:06 +00:00
|
|
|
populate_spots();
|
|
|
|
|
2019-07-01 17:23:15 +00:00
|
|
|
}
|
2019-07-02 01:11:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-07-02 01:38:06 +00:00
|
|
|
// vector<Park_spot> populate_spots(){
|
|
|
|
// vector<Park_spot> spots;
|
|
|
|
// SQLite::Statement query(data::db, "SELECT * FROM Park_spot WHERE id > 0;");
|
|
|
|
// // query.bind(1, 2);
|
|
|
|
// while (query.executeStep()) {
|
|
|
|
// int id = query.getColumn(0);
|
|
|
|
// int taken = query.getColumn(1);
|
|
|
|
// int cid = query.getColumn(2);
|
|
|
|
// // park_customers.push_back(query_customer_with_id(cid));
|
|
|
|
// spots.push_back({id, taken, cid});
|
|
|
|
// }
|
|
|
|
// return spots;
|
|
|
|
// }
|