Player12
An open source football management simulator
Loading...
Searching...
No Matches
fixture_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 <optional>
13#include <vector>
14
16#include "model/calendar.h"
17#include "model/match.h"
18
19struct MatchReport;
20
27{
28 public:
33 explicit FixtureRepository(std::shared_ptr<DatabaseConnection> db_conn);
34
39 std::vector<Match> loadAllMatches() const;
40
45 void insertFixture(const Match& match) const;
46
51 void saveCalendar(const Calendar& calendar) const;
52
57 void loadCalendar(Calendar& calendar) const;
58
60 void saveMatchReports(const std::vector<MatchReport>& reports) const;
61
63 std::optional<MatchReport> loadMatchReport(const GameDateValue& date,
64 TeamID home_id,
65 TeamID away_id) const;
66
68 std::vector<MatchReport> loadTeamMatchReports(uint16_t season,
69 TeamID team_id) const;
70
71 private:
72 std::shared_ptr<DatabaseConnection> db_conn;
73};
Manages the match calendar for a season.
Definition calendar.h:133
Repository class for managing Match and Calendar entities in the database, plus the per-fixture match...
Definition fixture_repository.h:27
void saveCalendar(const Calendar &calendar) const
Save the calendar to the database.
Definition fixture_repository.cpp:185
std::optional< MatchReport > loadMatchReport(const GameDateValue &date, TeamID home_id, TeamID away_id) const
Loads the report of one fixture, if it was stored.
Definition fixture_repository.cpp:338
void loadCalendar(Calendar &calendar) const
Load the calendar from the database.
Definition fixture_repository.cpp:284
void saveMatchReports(const std::vector< MatchReport > &reports) const
Inserts or replaces match reports (keyed by date and teams).
Definition fixture_repository.cpp:294
std::vector< MatchReport > loadTeamMatchReports(uint16_t season, TeamID team_id) const
Loads all stored reports of a team in a season, by date.
Definition fixture_repository.cpp:354
void insertFixture(const Match &match) const
Insert a match fixture into the database.
Definition fixture_repository.cpp:141
std::vector< Match > loadAllMatches() const
Load all matches from the database.
Definition fixture_repository.cpp:149
std::shared_ptr< DatabaseConnection > db_conn
Definition fixture_repository.h:72
Represents a football match between two teams.
Definition match.h:38
Represents a specific date in the game world.
Definition gamedate.h:20
Structured summary of a played fixture, persisted per fixture.
Definition match_report.h:93
uint16_t TeamID
Type alias for Team identifiers.
Definition types.h:18