Parkmanne/headers/Query.h
2019-07-02 15:40:37 -03:00

60 lines
1.6 KiB
C++

#ifndef QUERY_H
#define QUERY_H
#pragma once
#include "Park_spot.h"
/*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);
vector<Park_spot> populate_spots();
#endif // CUSTOMER_H