Player12
An open source football management simulator
Loading...
Searching...
No Matches
LeagueRepository Class Reference

Repository class for managing League entities in the database. More...

#include <league_repository.h>

Public Member Functions

 LeagueRepository (std::shared_ptr< DatabaseConnection > db_conn)
 Construct a new League Repository object.
 
std::vector< League > loadAllLeagues () const
 Load all leagues from the database.
 
void insertLeague (const League &league) const
 Insert a new league into the database.
 
void insertLeagueWithId (const League &league) const
 Insert a league with a specific ID into the database.
 
void saveLeaguePoints (const League &league) const
 Save the points of teams in a league to the database.
 
void loadLeaguePoints (League &league) const
 Load the points of teams for a specific league from the database.
 
void saveTeamMemberships (const League &league) const
 Persists the league membership (Teams.league_id) of its teams.
 
void resetAllLeaguePoints () const
 Reset points for all leagues in the database.
 

Private Member Functions

void loadTeamsForLeague (League &league) const
 

Private Attributes

std::shared_ptr< DatabaseConnection > db_conn
 

Detailed Description

Repository class for managing League entities in the database.

Constructor & Destructor Documentation

◆ LeagueRepository()

LeagueRepository::LeagueRepository ( std::shared_ptr< DatabaseConnection >  db_conn)
explicit

Construct a new League Repository object.

Parameters
db_connShared pointer to the database connection.

Member Function Documentation

◆ insertLeague()

void LeagueRepository::insertLeague ( const League &  league) const

Insert a new league into the database.

Parameters
leagueThe League object to insert.

◆ insertLeagueWithId()

void LeagueRepository::insertLeagueWithId ( const League &  league) const

Insert a league with a specific ID into the database.

Parameters
leagueThe League object to insert.

◆ loadAllLeagues()

std::vector< League > LeagueRepository::loadAllLeagues ( ) const

Load all leagues from the database.

Returns
A vector of League objects.

◆ loadLeaguePoints()

void LeagueRepository::loadLeaguePoints ( League &  league) const

Load the points of teams for a specific league from the database.

Parameters
leagueThe League object to populate with points.

◆ loadTeamsForLeague()

void LeagueRepository::loadTeamsForLeague ( League &  league) const
private

◆ resetAllLeaguePoints()

void LeagueRepository::resetAllLeaguePoints ( ) const

Reset points for all leagues in the database.

◆ saveLeaguePoints()

void LeagueRepository::saveLeaguePoints ( const League &  league) const

Save the points of teams in a league to the database.

Parameters
leagueThe League object whose points are to be saved.

◆ saveTeamMemberships()

void LeagueRepository::saveTeamMemberships ( const League &  league) const

Persists the league membership (Teams.league_id) of its teams.

Parameters
leagueThe League whose teams are stored.

Member Data Documentation

◆ db_conn

std::shared_ptr<DatabaseConnection> LeagueRepository::db_conn
private

The documentation for this class was generated from the following files: