Parkmanne/headers/Park_time.h

51 lines
1.1 KiB
C
Raw Normal View History

2019-05-28 16:46:55 +00:00
#ifndef PARK_TIME_H
#define PARK_TIME_H
#pragma once
#include <chrono>
#include <iostream>
2019-06-30 00:50:36 +00:00
#include <string>
#include "data.h"
2019-05-28 16:46:55 +00:00
using namespace std::chrono;
2019-06-30 00:50:36 +00:00
using std::string;
using std::to_string;
2019-05-28 16:46:55 +00:00
/*
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
2019-06-20 11:08:02 +00:00
Dit is gewoon een record van hoe lang, wie en waar iemand parkeert. Basically, een component van
de internal state van customer.
2019-05-28 16:46:55 +00:00
*/
class Park_time {
public:
int id;
int customer_id;
int spot_id;
int duration;
Park_time(int c_id, int s_id);
2019-06-30 00:50:36 +00:00
// Park_time(int c_id, int s_id );
2019-05-28 16:46:55 +00:00
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;
2019-06-30 00:50:36 +00:00
void save_db();
void update_db();
int auto_increment_db(); // helper
int start_to_int(); // helper
2019-05-28 16:46:55 +00:00
};
#endif // Park_time