WIP refractoring

This commit is contained in:
TinyAtoms 2019-06-29 19:59:48 -03:00
parent 8160f84e20
commit a606119626
9 changed files with 27 additions and 17 deletions

View File

@ -9,7 +9,17 @@ include_directories(
) )
add_executable(park main.cpp data.cpp headers/data.h Customer.cpp headers/Customer.h Park_spot.cpp headers/Park_spot.h Park_time.cpp headers/Park_time.h) add_executable(park
main.cpp
data.cpp
headers/data.h
#[[Customer.cpp
headers/Customer.h
Park_spot.cpp
headers/Park_spot.h
Park_time.cpp
headers/Park_time.h]]
)

View File

@ -1,6 +1,12 @@
#ifndef DATA_H
#define DATA_H
#pragma once
#include "../thirdparty/SQLiteCpp/include/SQLiteCpp/SQLiteCpp.h" #include "../thirdparty/SQLiteCpp/include/SQLiteCpp/SQLiteCpp.h"
#include "Customer.h"
namespace data { namespace data {
SQLite::Database start_db(); SQLite::Database start_db();
static SQLite::Database db = start_db();
} }
#endif

View File

@ -1,8 +1,8 @@
#include "headers/Park_spot.h" #include "thirdparty/SQLiteCpp/include/SQLiteCpp/SQLiteCpp.h"
#include "headers/data.h" #include "headers/data.h"
#include <iostream> #include <iostream>
#include <thread> // to make pausing work, not sure if i need chrono, or this, or both
#include <vector> #include <vector>
#include <string>
/* /*
Code strucure like this: Code strucure like this:
@ -19,22 +19,16 @@ record die zegt dat een customer voor x tijd geparkeert heeft bij spot x, enz.
De client clockt in en uit bij een spot. De client clockt in en uit bij een spot.
*/ */
void Wait(int sec)
/*
a wait function where 1 sec represents 1 hour irl.
*/
{
std::this_thread::sleep_for(seconds{sec});
}
using std::cout; using std::cout;
int main() { int main() {
SQLite::Statement test(data::db, "SELECT * FROM Customer WHERE id > 2");
while (test.executeStep()){
int id = test.getColumn(0);
std::string name = test.getColumn(1);
cout << id << ", " << name << std::endl;
}
SQLite::Database db = data::start_db();
// see implementation of update_db, save_db and delete_db of customer to see how queries and statements work
Customer sagar{"Sagar Winston Ramsaransing", Verhicle_type::medium, db};
sagar.update_db(db);
cout << "THIS WRKS";
// sagar.delete_db(db);
} }