From a6061196267af211a6ab29f1f81404a67736a0ad Mon Sep 17 00:00:00 2001 From: TinyAtoms Date: Sat, 29 Jun 2019 19:59:48 -0300 Subject: [PATCH] WIP refractoring --- CMakeLists.txt | 12 +++++++++++- headers/data.h | 8 +++++++- main.cpp | 24 +++++++++--------------- Customer.cpp => old/Customer.cpp | 0 Park_spot.cpp => old/Park_spot.cpp | 0 Park_time.cpp => old/Park_time.cpp | 0 {headers => old/headers}/Customer.h | 0 {headers => old/headers}/Park_spot.h | 0 {headers => old/headers}/Park_time.h | 0 9 files changed, 27 insertions(+), 17 deletions(-) rename Customer.cpp => old/Customer.cpp (100%) rename Park_spot.cpp => old/Park_spot.cpp (100%) rename Park_time.cpp => old/Park_time.cpp (100%) rename {headers => old/headers}/Customer.h (100%) rename {headers => old/headers}/Park_spot.h (100%) rename {headers => old/headers}/Park_time.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c278d3c..62ade13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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]] + ) diff --git a/headers/data.h b/headers/data.h index 5595cdf..1f7aff5 100644 --- a/headers/data.h +++ b/headers/data.h @@ -1,6 +1,12 @@ +#ifndef DATA_H +#define DATA_H +#pragma once #include "../thirdparty/SQLiteCpp/include/SQLiteCpp/SQLiteCpp.h" -#include "Customer.h" namespace data { SQLite::Database start_db(); +static SQLite::Database db = start_db(); + } + +#endif \ No newline at end of file diff --git a/main.cpp b/main.cpp index cc0b796..6df10b8 100644 --- a/main.cpp +++ b/main.cpp @@ -1,8 +1,8 @@ -#include "headers/Park_spot.h" +#include "thirdparty/SQLiteCpp/include/SQLiteCpp/SQLiteCpp.h" #include "headers/data.h" #include -#include // to make pausing work, not sure if i need chrono, or this, or both #include +#include /* 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. */ -void Wait(int sec) -/* -a wait function where 1 sec represents 1 hour irl. - */ -{ - std::this_thread::sleep_for(seconds{sec}); -} using std::cout; 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); } diff --git a/Customer.cpp b/old/Customer.cpp similarity index 100% rename from Customer.cpp rename to old/Customer.cpp diff --git a/Park_spot.cpp b/old/Park_spot.cpp similarity index 100% rename from Park_spot.cpp rename to old/Park_spot.cpp diff --git a/Park_time.cpp b/old/Park_time.cpp similarity index 100% rename from Park_time.cpp rename to old/Park_time.cpp diff --git a/headers/Customer.h b/old/headers/Customer.h similarity index 100% rename from headers/Customer.h rename to old/headers/Customer.h diff --git a/headers/Park_spot.h b/old/headers/Park_spot.h similarity index 100% rename from headers/Park_spot.h rename to old/headers/Park_spot.h diff --git a/headers/Park_time.h b/old/headers/Park_time.h similarity index 100% rename from headers/Park_time.h rename to old/headers/Park_time.h