Statistics - final bits including all stats and error handling
[scorecard] / src / data.h
1 #ifndef __SCORE_DATA_H
2 #define __SCORE_DATA_H
3
4 #include <QDebug>
5 #include <QVector>
6 #include <QXmlAttributes>
7 #include <QDomElement>
8 #include <QDomDocument>
9
10 enum { TotalOut, TotalIn, Total };
11
12
13 class Hole {
14  public:
15   Hole(const QXmlAttributes &attrs);
16   Hole(const QDomElement node);
17   Hole(int num, QString &shots);
18   Hole(int num, QString &par, QString &hcp);
19   QDomElement toElement(QDomDocument doc);
20   QString getShots();
21   void setShots(QString& shots);
22   QString getHcp();
23   void setHcp(QString& shots);
24   QString getPar();
25   void setPar(QString& shots);
26   void dump();
27
28  private:
29   QString num, shots, putts, hcp, length, par;
30 };
31
32 class Score {
33  public:
34
35   Score(const QXmlAttributes &attrs);
36   Score(QString &iClub, QString &iCourse, QString &iDate);
37   Score(const QDomElement node);
38   Score(QVector<QString> scores, QString &club, QString &course, QString &date);
39
40   bool operator< (const Score& val) const 
41   { 
42     return date < val.getDate();
43   }
44
45   QDomElement toElement(QDomDocument doc);
46   int update(QVector<QString> &scores);
47   void addHole(Hole *iHole);
48   QString getScore(int i) const;
49   QString getTotal(int what) const;
50   const QString& getClubName() const;
51   const QString& getCourseName() const;
52   const QString& getDate() const;
53   void dump();
54
55  private:
56   QList <Hole *> holeList;
57   QString club, course, date;
58 };
59
60 class Course {
61  public:
62   Course(const QXmlAttributes &attrs);
63   Course(const QDomElement node);
64   Course(QString &name, QVector<QString> &, QVector<QString> &);
65   QDomElement toElement(QDomDocument doc);
66   int update(QVector<QString> &, QVector<QString> &, QVector<QString> &);
67   void addHole(Hole *iHole);
68   QString getPar(int i);
69   QString getHcp(int i);
70   QString& getName();
71   QString getTotal(int what);
72   void dump();
73
74  private:
75   QList <Hole *> holeList;
76   QString name;
77 };
78
79 class Club {
80  public:
81
82   Club(const QXmlAttributes &attrs);
83   Club(const QDomElement node);
84   Club(QString &name);
85
86   QDomElement toElement(QDomDocument doc);
87   void addCourse(Course *iCourse);
88   void dump();
89   QString& getName();
90   Course *getCourse(int pos);
91   Course *getCourse(const QString &courseName);
92
93   QList <Course *> getCourseList() { return courseList; } // HACK: fixme
94
95  private:
96   QList <Course *> courseList;
97   QString name;
98
99 };
100 #endif