#ifndef PARK_TIME_H #define PARK_TIME_H #pragma once #include "data.h" #include #include #include #include using namespace std::chrono; using std::cout; using std::string; using std::to_string; /* Record of who parked at what park_spot and at what time. public interface------------------------------------------- The constructors. one for creating new customers, the other one used by the query functions to construct the object from information stored in the database. clock_out is the function that gets called from customer.clock_out(). It verifies that the customer is clocking out at the correct parkspot, and saves the current time of clocking out in end. It also calculates duration so it doesn't have to be calculated more than once. operator<< is << overload, can(should) be used for report generation. // implementation stuff------------------------ start and end are time points representing when someone clocks in and out. they're from the chrono namespace. save and update save and update info in the database. auto_increment pulls the highest id stored in the db, to be used in the constructor. start_to_int() is used to convert the start timepoint to an integer that can be saved in the database SQL datetime and chrono datetime don't seem the most compatible. */ class Park_time { public: Park_time(int c_id, int s_id); Park_time(int id_, int customer_id_, int spot_id_, int start_, int duration_); int id; int customer_id; int spot_id; int duration; void clock_out(int c_id, int s_id); friend std::ostream& operator<<(std::ostream& os, const Park_time& pt); private: high_resolution_clock::time_point start; high_resolution_clock::time_point end; void save_db(); void update_db(); int auto_increment_db(); // helper int start_to_int(); // helper }; #endif // Park_time