70 lines
1.9 KiB
C++
70 lines
1.9 KiB
C++
#ifndef QUERY_H
|
|
#define QUERY_H
|
|
#pragma once
|
|
|
|
#include "Park_spot.h"
|
|
#include <iomanip>
|
|
using std::pair;
|
|
|
|
/*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.
|
|
so now you'd do
|
|
|
|
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
|
|
}
|
|
|
|
instead of
|
|
try {
|
|
customer test = query_customer_with_name("Testman");
|
|
}
|
|
catch(someException.probablycalled_not_found) {do_Stuff};
|
|
catch(...) {
|
|
do stuff
|
|
}
|
|
finally{
|
|
do more stuff
|
|
}
|
|
|
|
3. Ya boi needs to brush up on how to create custom exceptions class, and it will complicate code
|
|
furhter.
|
|
|
|
*/
|
|
|
|
vector<Park_time> query_parktimes_for_customer(int cid);
|
|
vector<Customer> query_customer_with_name(string name);
|
|
Customer query_customer_with_id(int id);
|
|
Park_spot query_parkspot_with_id(int id, vector<Park_spot>& parkspots);
|
|
int query_role_customer(int id);
|
|
|
|
vector<Park_spot> populate_spots();
|
|
|
|
void reports_from_parkspot(int spotid, pair<int, int> period);
|
|
void reports_from_allparkspots(pair<int, int> period);
|
|
void current_status_parkspots(vector<Park_spot>& spots);
|
|
vector<Park_time> reports_from_customer(int cid, pair<int, int> period);
|
|
|
|
#endif // CUSTOMER_H
|