-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
competitor.hpp
133 lines (112 loc) · 4.17 KB
/
competitor.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*****************************************************************************
* Copyright (C) 2021 by Lorenzo Buzzi ([email protected]) *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
*****************************************************************************/
#ifndef COMPETITOR_H
#define COMPETITOR_H
#include <QCoreApplication>
#include <QDataStream>
#include <QString>
#include <QList>
#include "category.hpp"
namespace competitor {
class Competitor;
class CompetitorSorter;
}
class Competitor
{
Q_DECLARE_TR_FUNCTIONS(Competitor)
public:
enum class Sex
{
UNDEFINED,
MALE,
FEMALE
};
enum class Field
{
CMF_FIRST = 0,
CMF_BIB = 0,
CMF_NAME = 1,
CMF_SEX = 2,
CMF_YEAR = 3,
CMF_CLUB = 4,
CMF_TEAM = 5,
CMF_OFFSET_LEG = 6,
CMF_LAST = 6,
CMF_COUNT = 7
};
private:
static QString empty;
uint bib { 0u };
QString name { "" };
Sex sex { Sex::UNDEFINED };
uint year { 1900 };
QString club { "" };
QString team { "" };
uint leg { 1u };
int offset { -1 };
QList<Category const *> categories { };
bool isInCategory(Category const *category) const;
public:
Competitor() = default;
explicit Competitor(uint const bib) : bib(bib) { };
friend QDataStream &operator<<(QDataStream &out, Competitor const &comp);
friend QDataStream &operator>>(QDataStream &in, Competitor &comp);
QString const &getName() const;
QString getName(int width) const;
void setName(QString const &newName);
uint getBib() const;
void setBib(uint newBib);
Sex getSex() const;
void setSex(Sex const newSex);
QString const &getClub() const;
QString getClub(int newWidth) const;
void setClub(QString const &newClub);
void setClub(QString const *newClub);
QString const &getTeam() const;
QString getTeam(int newWidth) const;
void setTeam(QString const &newTeam);
void setTeam(QString const *newTeam);
uint getYear() const;
void setYear(uint newYear);
uint getLeg() const;
void setLeg(uint newLeg);
int getOffset() const;
void setOffset(int newOffset);
void setOffset(int const *newOffset);
bool isValid() const;
Category const *getCategory() const;
QList<Category const *> &getCategories();
void setCategories(QList<Category> const &newCategories);
bool operator< (Competitor const &rhs) const;
bool operator> (Competitor const &rhs) const;
bool operator<= (Competitor const &rhs) const;
bool operator>= (Competitor const &rhs) const;
};
Competitor::Field &operator++(Competitor::Field &field);
Competitor::Field operator++(Competitor::Field &field, int);
class CompetitorSorter {
private:
static Qt::SortOrder sortingOrder;
static Competitor::Field sortingField;
public:
static Qt::SortOrder getSortingOrder();
static void setSortingOrder(Qt::SortOrder const &value);
static Competitor::Field getSortingField();
static void setSortingField(Competitor::Field const &value);
bool operator() (Competitor const &lhs, Competitor const &rhs) const;
};
#endif // COMPETITOR_H