2019-07-02 00:51:23 +00:00
|
|
|
#ifndef QUERY_H
|
|
|
|
#define QUERY_H
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Park_spot.h"
|
|
|
|
|
2019-07-02 18:40:37 +00:00
|
|
|
/*these are the functions that search the database and create objects from it.
|
|
|
|
|
|
|
|
query_parktimes_for_customer searches for the parktimes that are needed in
|
|
|
|
customer initialisaiton. generally, i see no use outside of that.
|
|
|
|
|
|
|
|
query_customer_with_name searches for customer data by name.
|
|
|
|
|
|
|
|
query_customer_with_id does what the above does, but with id.
|
|
|
|
|
|
|
|
|
|
|
|
populate_spots is used to query for all the park_spots and return them as
|
|
|
|
objects.
|
|
|
|
|
|
|
|
The design desision to use vector<T> instead of <T> is for the following
|
|
|
|
reasons:
|
|
|
|
|
|
|
|
1. some of these can potentially return more than one object. For example, 2
|
|
|
|
customers who have the same name.
|
|
|
|
|
|
|
|
2. I have no clue how many of you have done error handling in c++
|
|
|
|
(try/catch/finally).
|
|
|
|
Ya boi is nice and doesn't want to bombard you with more new concepts than needed.
|
2019-07-08 20:57:09 +00:00
|
|
|
so now you'd do
|
2019-07-02 18:40:37 +00:00
|
|
|
|
|
|
|
vector<Customer> test = query_customer_with_name("Testman");
|
|
|
|
|
|
|
|
if (!test.size()) {print no customers found, do stuff}
|
|
|
|
else if (test.size() > 1) { do stuff to get the right one if you only need one
|
|
|
|
}
|
|
|
|
|
2019-07-08 20:57:09 +00:00
|
|
|
instead of
|
2019-07-02 18:40:37 +00:00
|
|
|
try {
|
|
|
|
customer test = query_customer_with_name("Testman");
|
|
|
|
}
|
|
|
|
catch(someException.probablycalled_not_found) {do_Stuff};
|
|
|
|
catch(...) {
|
|
|
|
do stuff
|
|
|
|
}
|
|
|
|
finally{
|
|
|
|
do more stuff
|
|
|
|
}
|
|
|
|
|
2019-07-08 20:57:09 +00:00
|
|
|
3. Ya boi needs to brush up on how to create custom exceptions class, and it will complicate code
|
|
|
|
furhter.
|
2019-07-02 18:40:37 +00:00
|
|
|
|
|
|
|
*/
|
2019-07-02 00:51:23 +00:00
|
|
|
|
|
|
|
vector<Park_time> query_parktimes_for_customer(int cid);
|
|
|
|
|
|
|
|
vector<Customer> query_customer_with_name(string name);
|
|
|
|
Customer query_customer_with_id(int id);
|
|
|
|
|
2019-07-02 01:11:46 +00:00
|
|
|
vector<Park_spot> populate_spots();
|
|
|
|
|
2019-07-06 16:32:00 +00:00
|
|
|
Park_spot query_parkspot_with_id(int id, vector<Park_spot>& parkspots);
|
|
|
|
|
2019-07-08 20:57:09 +00:00
|
|
|
void reports_from_parkspot(int spotid, bool weekly = false);
|
|
|
|
void reports_from_allparkspots(bool weekly = false);
|
2019-07-06 16:32:00 +00:00
|
|
|
|
2019-07-07 18:15:51 +00:00
|
|
|
void current_status_parkspots(vector<Park_spot>& spots);
|
|
|
|
#endif // CUSTOMER_H
|