1 #ifndef TOURNAMENT_RUNNER_TOURNAMENT_H_
2 #define TOURNAMENT_RUNNER_TOURNAMENT_H_
9 #include <boost/serialization/access.hpp>
10 #include <boost/serialization/vector.hpp>
11 #include <boost/serialization/nvp.hpp>
13 #include "tournament_runner/karateka.h"
14 #include "tournament_runner/date.h"
16 using boost::serialization::make_nvp;
21 namespace TournamentRunner
45 name_ = std::move(name);
65 date_ = std::move(date);
77 date_ =
Date(date_as_string);
97 location_ = std::move(address);
103 std::string location_{};
128 std::string
name ()
const;
185 using RankAnnotatedParticipant = std::pair<size_t, Karateka>;
187 static constexpr
auto rank_annotated_participant_rank_idx = 0u;
188 static constexpr
auto rank_annotated_participant_karateka_idx = 1u;
216 void reassign_startnumbers ();
217 friend class boost::serialization::access;
219 template<
class Archive>
220 void serialize (Archive& archive,
221 const unsigned int version);
223 std::vector<size_t> get_list_of_participants_for_next_kata_round (
size_t no_of_participants_for_round)
const;
226 std::vector<Karateka> participants_;
227 uint8_t current_kata_round_{};
238 return data_.location_;
253 return current_kata_round_;
258 return participants_.size();
264 return participants_.at(start_number);
267 template<
class Archive>
268 void Tournament::serialize (Archive& archive,
271 archive & make_nvp(
"CurrentKataRound", current_kata_round_);
272 archive & make_nvp(
"Name", data_.name_);
273 archive & make_nvp(
"Location", data_.location_);
274 archive & make_nvp(
"Date", data_.date_);
275 archive & make_nvp(
"Participants", participants_);
280 #endif // TOURNAMENT_RUNNER_TOURNAMENT_H_
void update_data(const TournamentData &data)
Update the tournament data.
Definition: tournament.h:246
TournamentData & on_date(const std::string &date_as_string)
Set the tournament date.
Definition: tournament.h:75
TournamentData & with_name(const std::string &name)
Set the tournament name.
Definition: tournament.h:34
std::vector< Karateka > get_ranked_list_of_participants() const
Return a ranked list of participants. The highest ranked comes first.
Definition: tournament.cpp:40
The Tournament class is the starting point for the tournament management.
Definition: tournament.h:110
void add_participant(const Karateka &participant)
Register a participant to the tournament.
Definition: tournament.cpp:20
TournamentData & at_location(std::string &&address) noexcept
Definition: tournament.h:95
The Karateka class.
Definition: karateka.h:33
TournamentData & on_date(Date &&date) noexcept
Definition: tournament.h:63
TournamentData & with_name(std::string &&name) noexcept
Definition: tournament.h:43
void remove_participant(size_t start_number)
remove_participant
Definition: tournament.cpp:28
std::vector< RankAnnotatedParticipant > get_anotated_ranked_list_of_participants() const
Return a ranked list of participants anotated with the actual rank.
Definition: tournament.cpp:49
Tournament()=default
Default empty Tournament constructor.
std::string date_as_string() const
Return the date the tournament is held as ISO 8601 extended format string (CCYY-MM-DD) ...
Definition: tournament.cpp:15
The Date class provides Date handling based on the boost::gregorian::date.
Definition: date.h:21
Date date() const
Return the date the tournament is held as Date.
Definition: tournament.h:241
TournamentData & on_date(const Date &date)
Set the tournament date.
Definition: tournament.h:54
uint8_t get_current_round() const
Return the current active round.
Definition: tournament.h:251
std::string name() const
Tournament name.
Definition: tournament.h:231
std::vector< size_t > get_startlist_for_next_kata_round(size_t no_of_participants_for_round) const
Return the startlist for the next kata round.
Definition: tournament.cpp:86
TournamentData & at_location(const std::string &address)
Set the location the tournament is held.
Definition: tournament.h:86
Karateka & get_participant(size_t start_number)
Return the participant with the given startnumber.
Definition: tournament.h:262
uint8_t start_next_kata_round()
Start the next kata round.
Definition: tournament.cpp:74
The TournamentData struct holding all tournament relevant informations.
Definition: tournament.h:27
std::string location() const
Tournament location address.
Definition: tournament.h:236
size_t number_of_participants() const
Return the number of registred participants.
Definition: tournament.h:256