summaryrefslogtreecommitdiff
path: root/src/discipline/Sport.h
blob: 78968fe192332faa834419cfd6b2ef12da78ccbe (plain)
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

#ifndef ITAT_CHALLANGE_OLYMPICS_SPORT_H
#define ITAT_CHALLANGE_OLYMPICS_SPORT_H


#include <set>

#include <QJsonObject>
#include <QJsonDocument>
#include <QString>

using namespace std;


class Sport {

public:

    Sport(QJsonObject discipline) {
        this->discipline = discipline;
    }

    set<QString> getCategories();
    QJsonArray getCompetitorsByCategory(QString category);

    // filter to change the current competitor array
    void lastName(QJsonArray& competitors);
    void filterByName(QJsonArray& competitors, QString name);
    void filterByCountry(QJsonArray& competitors, QString nocShort);

    // sort functions to change the order of the current competitor array
    void sortByName(QJsonArray &competitors);
    void sortByCountry(QJsonArray &competitors);
    void sortByResult(QJsonArray &competitors);

    void setDiscipline(QJsonObject discipline) {
        this->discipline = QJsonObject(discipline);
    }

private:

    /*
     * Analysis of provided competitor objects:
     *
     * Attributes:
     * - code
     * - noc (national olympics comittee)
     * - name (sometimes the country name? mostly the competitors name)
     * - order
     * [- results] (only if the results are out!)
     *
     *
     * Analysis of provided result objects:
     *
     * Attributes:
     * - position
     * - mark
     * - medalType
     * - irk
     * [- winnerLoserTie] (only if provided in the discipline?)
     */
    QJsonObject discipline;

    void filterCompetitors(QJsonArray& competitors, QString attribute, QString filter);
    void sortCompetitors(QJsonArray &competitors,  function<bool (const QJsonValue &left, const QJsonValue &right)> compare);

};


#endif //ITAT_CHALLANGE_OLYMPICS_SPORT_H