1 #ifndef TOURNAMENT_RUNNER_KARATEKA_H_
2 #define TOURNAMENT_RUNNER_KARATEKA_H_
9 #include <boost/serialization/access.hpp>
10 #include <boost/serialization/array.hpp>
11 #include <boost/serialization/nvp.hpp>
13 #include "tournament_runner/date.h"
14 #include "tournament_runner/kata_performer_interface.h"
15 #include "tournament_runner/kataround_scores.h"
18 using boost::serialization::make_nvp;
20 namespace TournamentRunner
40 Karateka& with_name (
const std::string& karateka_name);
41 Karateka& with_name (std::string&& karateka_name) noexcept;
42 Karateka& with_surname (
const std::string& karateka_surname);
43 Karateka& with_surname (std::string&& karateka_surname) noexcept;
46 Karateka& with_birthdate (
const std::string& birthdate_as_string);
47 Karateka& from_dojo (
const std::string& dojo_name);
48 Karateka& from_dojo (std::string&& dojo_name) noexcept;
49 Karateka& with_grade (
const std::string& grade_as_string);
50 Karateka& with_grade (std::string&& grade_as_string) noexcept;
119 KataRoundScores::ScoreVectorType
get_scores (uint8_t round)
const;
121 float get_deduction (uint8_t round)
const;
127 std::string
name ()
const;
150 std::string
dojo ()
const;
155 std::string
grade ()
const;
159 friend class boost::serialization::access;
164 template<
class Archive>
165 void serialize (Archive& archive,
const unsigned int version);
168 std::string surname_{};
169 Date date_of_birth_{};
171 std::string grade_{};
172 array<KataRoundScores, max_number_of_kata_rounds> kata_scores_;
173 size_t start_number_{};
174 uint8_t current_kata_round_{};
202 start_number_ = start_number;
207 return start_number_;
227 return date_of_birth_;
240 template<
class Archive>
241 void Karateka::serialize (Archive& archive,
244 archive & make_nvp(
"Name", name_);
245 archive & make_nvp(
"Surname", surname_);
246 archive & make_nvp(
"DateOfBirth", date_of_birth_);
247 archive & make_nvp(
"Dojo", dojo_);
248 archive & make_nvp(
"Grade", grade_);
249 archive & make_nvp(
"Scores", kata_scores_);
250 archive & make_nvp(
"Startnumber", start_number_);
251 archive & make_nvp(
"CurrentKataRound", current_kata_round_);
256 #endif // TOURNAMENT_RUNNER_KARATEKA_H_
std::string dojo() const
Return the dojo the Karateka belongs to.
Definition: karateka.h:230
KataRoundScores::ScoreVectorType get_scores(uint8_t round) const
Return all scores of a round.
Definition: karateka.cpp:124
float get_minimum_score_of_current_round() const final
Return the minimum score of the current round.
Definition: karateka.cpp:114
Date date_of_birth() const
Return a date of birth string of the Karateka.
Definition: karateka.h:225
void add_deduction(float deduction) final
Add a deduction, which is subtracted from the overall score.
Definition: karateka.cpp:79
The Karateka class.
Definition: karateka.h:33
size_t get_startnumber() const
Return the startnumber.
Definition: karateka.h:205
float get_overall_score_of_round(uint8_t round) const final
Return the overall score of the given round.
Definition: karateka.cpp:104
std::string date_of_birth_as_string() const
Return the date of birth of the Karateka.
Definition: karateka.h:220
std::string grade() const
Return the rank of the Karateka.
Definition: karateka.h:235
std::string to_iso_extended_string() const
Return date as extended iso string.
Definition: date.cpp:23
float get_maximum_score_of_round(uint8_t round) const final
Return the maximum score of the given round.
Definition: karateka.cpp:94
float get_overall_score_of_current_round() const final
Return the overall score of the current round.
Definition: karateka.cpp:119
bool kata_score_sort_greater(const IKataPerformer &lhs, const IKataPerformer &rhs)
Karateka score compare method for std::sort algorithm.
Definition: karateka.cpp:171
The Date class provides Date handling based on the boost::gregorian::date.
Definition: date.h:21
void add_kata_score(float score) final
Add a kata score for the current round.
Definition: karateka.cpp:74
std::string name() const
Return the name of the Karateka.
Definition: karateka.h:210
void set_startnumber(size_t start_number)
set_startnumber
Definition: karateka.h:200
float get_maximum_score_of_current_round() const final
Return the maximum score of the current round.
Definition: karateka.cpp:109
uint8_t next_round() final
Move to next round.
Definition: karateka.cpp:84
bool kata_score_is_equal(const IKataPerformer &lhs, const IKataPerformer &rhs)
kata_score_is_equal
Definition: karateka.cpp:186
constexpr auto max_number_of_kata_rounds
Max number of kata rounds (3)
Definition: karateka.h:26
std::string surname() const
Return the surname of the Karateka.
Definition: karateka.h:215
float get_minimum_score_of_round(uint8_t round) const final
Return the minimum score of the given round.
Definition: karateka.cpp:99