Initial commit
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
#ifndef SQLITE_DATABASE_H
|
||||
#define SQLITE_DATABASE_H
|
||||
|
||||
#include "database_interface.h"
|
||||
#include <functional>
|
||||
#include <sqlite3.h>
|
||||
|
||||
// Forward declaration
|
||||
class SQLiteStatement;
|
||||
|
||||
// SQLite implementation of the DatabaseInterface
|
||||
class SQLiteDatabase : public DatabaseInterface {
|
||||
private:
|
||||
sqlite3 *db_; // Pointer to SQLite database connection
|
||||
|
||||
// Helper functions
|
||||
int executeNonQuery(
|
||||
const std::string &query,
|
||||
const std::function<void(SQLiteStatement &)> &bindFunc = nullptr);
|
||||
std::vector<std::vector<std::string>> executeSelectQuery(
|
||||
const std::string &query,
|
||||
const std::function<void(SQLiteStatement &)> &bindFunc = nullptr);
|
||||
|
||||
friend class SQLiteDatabaseForeignKeyTest;
|
||||
friend class SQLiteDatabaseCRUDTest;
|
||||
friend class SQLiteDatabaseTriggerTest;
|
||||
|
||||
public:
|
||||
// Verification of the database availability
|
||||
bool isDatabaseAvailable() override { return db_ != nullptr; }
|
||||
|
||||
public:
|
||||
SQLiteDatabase(const std::string &db_file);
|
||||
~SQLiteDatabase();
|
||||
|
||||
SQLiteDatabase(const SQLiteDatabase &) = delete;
|
||||
SQLiteDatabase &operator=(const SQLiteDatabase &) = delete;
|
||||
|
||||
SQLiteDatabase(SQLiteDatabase &&) noexcept;
|
||||
SQLiteDatabase &operator=(SQLiteDatabase &&) noexcept;
|
||||
|
||||
// Genre operations
|
||||
bool addGenre(const NewGenre &genre) override;
|
||||
bool removeGenre(int genre_id) override;
|
||||
bool updateGenre(const Genre &genre) override;
|
||||
Genre getGenre(int genre_id) override;
|
||||
std::vector<Genre> getAllGenres() override;
|
||||
|
||||
// Movie operations
|
||||
bool addMovie(const NewMovie &movie) override;
|
||||
bool removeMovie(int movie_id) override;
|
||||
bool updateMovie(const Movie &movie) override;
|
||||
Movie getMovie(int movie_id) override;
|
||||
std::vector<Movie> getAllMovies() override;
|
||||
|
||||
// Hall operations
|
||||
bool addHall(const NewHall &hall) override;
|
||||
bool removeHall(int hall_id) override;
|
||||
bool updateHall(const Hall &hall) override;
|
||||
Hall getHall(int hall_id) override;
|
||||
std::vector<Hall> getAllHalls() override;
|
||||
|
||||
// Session operations
|
||||
bool addSession(const NewSession &session) override;
|
||||
bool removeSession(int session_id) override;
|
||||
bool updateSession(const Session &session) override;
|
||||
Session getSession(int session_id) override;
|
||||
std::vector<Session> getAllSessions() override;
|
||||
|
||||
// Ticket operations
|
||||
bool addTicket(const NewTicket &ticket) override;
|
||||
bool removeTicket(int ticket_id) override;
|
||||
bool updateTicket(const Ticket &ticket) override;
|
||||
Ticket getTicket(int ticket_id) override;
|
||||
std::vector<Ticket> getAllTickets() override;
|
||||
|
||||
// Refund operations
|
||||
bool addRefund(const NewRefund &refund) override;
|
||||
bool removeRefund(int refund_id) override;
|
||||
bool updateRefund(const Refund &refund) override;
|
||||
Refund getRefund(int refund_id) override;
|
||||
std::vector<Refund> getAllRefunds() override;
|
||||
};
|
||||
|
||||
#endif // SQLITE_DATABASE_H
|
||||
Reference in New Issue
Block a user