park time can be saved to db now
This commit is contained in:
51
headers/Park_time.h
Normal file
51
headers/Park_time.h
Normal file
@ -0,0 +1,51 @@
|
||||
#ifndef PARK_TIME_H
|
||||
#define PARK_TIME_H
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "data.h"
|
||||
|
||||
|
||||
using namespace std::chrono;
|
||||
using std::string;
|
||||
using std::to_string;
|
||||
/*
|
||||
db repr of Park_time
|
||||
int id (not null, auto increment)
|
||||
int customer_id (not null) (many to one or something like that)
|
||||
int spot_id (not null, many to one or something like that)
|
||||
int duration
|
||||
datetime start (not null)
|
||||
datetime end
|
||||
|
||||
Dit is gewoon een record van hoe lang, wie en waar iemand parkeert. Basically, een component van
|
||||
de internal state van customer.
|
||||
*/
|
||||
|
||||
class Park_time {
|
||||
public:
|
||||
int id;
|
||||
int customer_id;
|
||||
int spot_id;
|
||||
int duration;
|
||||
Park_time(int c_id, int s_id);
|
||||
// Park_time(int c_id, int s_id );
|
||||
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
|
Reference in New Issue
Block a user