Player12
An open source football management simulator
Loading...
Searching...
No Matches
player_repository.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2// Football Management Project
3// Copyright (c) 2025 - 2026 Flavio Milinanni. All Rights Reserved.
4//
5// This file is part of the Football Management Project.
6// See the LICENSE file in the project root.
7// -----------------------------------------------------------------------------
8
9#pragma once
10
11#include <memory>
12#include <vector>
13
15#include "model/player.h"
16
17struct sqlite3_stmt;
18
24{
25 public:
30 explicit PlayerRepository(std::shared_ptr<DatabaseConnection> db_conn);
31
36 std::vector<Player> loadAllPlayers() const;
37
42 void insertPlayer(const Player& player) const;
43
48 void insertPlayerWithId(const Player& player) const;
49
54 void insertPlayers(
55 const std::vector<std::reference_wrapper<const Player>>& players) const;
56
61 void updatePlayer(const Player& player) const;
62
67 void updatePlayers(
68 const std::vector<std::reference_wrapper<const Player>>& players) const;
69
74 void deletePlayer(PlayerID player_id) const;
75
81 void transferPlayer(PlayerID player_id, uint16_t new_team_id) const;
82
83 private:
84 std::shared_ptr<DatabaseConnection> db_conn;
85};
Repository class for managing Player entities in the database.
Definition player_repository.h:24
void deletePlayer(PlayerID player_id) const
Delete a player from the database by ID.
Definition player_repository.cpp:462
std::vector< Player > loadAllPlayers() const
Load all players from the database.
Definition player_repository.cpp:332
void insertPlayer(const Player &player) const
Insert a new player into the database.
Definition player_repository.cpp:394
void updatePlayer(const Player &player) const
Update an existing player in the database.
Definition player_repository.cpp:426
void transferPlayer(PlayerID player_id, uint16_t new_team_id) const
Transfer a player to a new team in the database.
Definition player_repository.cpp:472
void insertPlayers(const std::vector< std::reference_wrapper< const Player > > &players) const
Insert multiple players into the database.
Definition player_repository.cpp:404
void insertPlayerWithId(const Player &player) const
Insert a player with a specific ID into the database.
Definition player_repository.cpp:421
std::shared_ptr< DatabaseConnection > db_conn
Definition player_repository.h:84
void updatePlayers(const std::vector< std::reference_wrapper< const Player > > &players) const
Update multiple players in the database, inserting new ones.
Definition player_repository.cpp:431
Persistent career identity, attributes, traits and day-to-day state.
Definition player.h:104
uint32_t PlayerID
Type alias for Player identifiers.
Definition types.h:21