Basic demonstrator
Works fine but can be slow, especially because of heavy IO.
This commit is contained in:
commit
afe832654d
8 changed files with 414 additions and 0 deletions
36
LicenceOperations.h
Normal file
36
LicenceOperations.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
//
|
||||
// Created by trotfunky on 02/10/2021.
|
||||
//
|
||||
|
||||
#ifndef AUTOPOINTSPERMIS_LICENCEOPERATIONS_H
|
||||
#define AUTOPOINTSPERMIS_LICENCEOPERATIONS_H
|
||||
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <sqlite3.h>
|
||||
#include <string>
|
||||
|
||||
#include "db_info.h"
|
||||
|
||||
// Assign values directly to prevent starting from 0 without using a dummy value
|
||||
enum class offenceClass {
|
||||
One = 1,
|
||||
Two = 2,
|
||||
Three = 3,
|
||||
Four = 4,
|
||||
Five = 5
|
||||
};
|
||||
|
||||
void dbError(const std::string& errorMessage, char* dbError);
|
||||
|
||||
/// Adds a new licence with 12 points and no counters running.
|
||||
int addNewLicence(sqlite3* db, const std::string& licenceID);
|
||||
/// Apply a new offence to an existing licence.
|
||||
int applyOffence(sqlite3* db, const std::string& licenceID, int lostPoints, offenceClass offenceClass);
|
||||
/// Apply the countdowns, check for completion and add points back.
|
||||
/// Fetched columns : idHash, Points, Countdown, OnePointCoutdown, TenYearCountdown
|
||||
int countdown(void* db, int columnCount, char** rowData, char** columnNames);
|
||||
/// Resets all counters and maximum points for an existing licence
|
||||
int reset(sqlite3* db, const std::string& idHash);
|
||||
|
||||
#endif //AUTOPOINTSPERMIS_LICENCEOPERATIONS_H
|
Loading…
Add table
Add a link
Reference in a new issue