~ubuntu-branches/ubuntu/saucy/goldencheetah/saucy

« back to all changes in this revision

Viewing changes to src/DBAccess.h

  • Committer: Package Import Robot
  • Author(s): KURASHIKI Satoru
  • Date: 2013-08-18 07:02:45 UTC
  • mfrom: (4.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20130818070245-zgdvb47e1k3mtgil
Tags: 3.0-3
debian/control: remove needless dependency. (Closes: #719571)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 
 
1
/*
2
2
 * Copyright (c) 2009 Justin F. Knotzke (jknotzke@shampoo.ca)
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify it
5
5
 * under the terms of the GNU General Public License as published by the Free
6
6
 * Software Foundation; either version 2 of the License, or (at your option)
7
7
 * any later version.
8
 
 * 
 
8
 *
9
9
 * This program is distributed in the hope that it will be useful, but WITHOUT
10
10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12
12
 * more details.
13
 
 * 
 
13
 *
14
14
 * You should have received a copy of the GNU General Public License along
15
15
 * with this program; if not, write to the Free Software Foundation, Inc., 51
16
16
 * Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19
19
#ifndef _GC_DBAccess_h
20
20
#define _GC_DBAccess_h 1
21
21
 
 
22
#include "GoldenCheetah.h"
22
23
 
23
24
 
24
25
#include <QDir>
28
29
#include "MainWindow.h"
29
30
#include "Season.h"
30
31
#include "RideFile.h"
 
32
#include "SpecialFields.h"
 
33
#include "RideMetadata.h"
 
34
 
 
35
extern int DBSchemaVersion;
31
36
 
32
37
class RideFile;
33
38
class Zones;
34
39
class RideMetric;
35
40
class DBAccess
36
41
{
37
 
        
 
42
 
38
43
        public:
39
44
 
40
45
    // get connection name
43
48
    // check the db structure is up to date
44
49
    void checkDBVersion();
45
50
 
 
51
    // get schema version
 
52
    int getDBVersion();
 
53
 
46
54
    // create and drop connections
47
55
        DBAccess(MainWindow *main, QDir home);
48
56
    ~DBAccess();
49
57
 
50
 
    // Create/Delete Records
51
 
        bool importRide(SummaryMetrics *summaryMetrics, RideFile *ride, unsigned long, bool);
 
58
    // Create/Delete Metrics
 
59
        bool importRide(SummaryMetrics *summaryMetrics, RideFile *ride, QColor color, unsigned long, bool);
52
60
    bool deleteRide(QString);
53
61
 
 
62
    // Create/Delete Measures
 
63
    bool importMeasure(SummaryMetrics *summaryMetrics);
 
64
 
54
65
    // Query Records
 
66
    QList<SummaryMetrics> getAllMetricsFor(QDateTime start, QDateTime end);
 
67
    QList<SummaryMetrics> getAllMetricsFor(DateRange dr) {
 
68
        return getAllMetricsFor(QDateTime(dr.from,QTime(0,0,0)), QDateTime(dr.to, QTime(23,59,59)));
 
69
    }
 
70
 
 
71
    bool getRide(QString filename, SummaryMetrics &metrics, QColor&color);
 
72
    QList<SummaryMetrics> getAllMeasuresFor(QDateTime start, QDateTime end);
 
73
    QList<SummaryMetrics> getAllMeasuresFor(DateRange dr) { 
 
74
        return getAllMeasuresFor(QDateTime(dr.from,QTime(0,0,0)), QDateTime(dr.to, QTime(23,59,59)));
 
75
    }
 
76
 
 
77
    SummaryMetrics getRideMetrics(QString filename); // for a filename
 
78
 
55
79
        QList<QDateTime> getAllDates();
56
 
    QList<SummaryMetrics> getAllMetricsFor(QDateTime start, QDateTime end);
57
80
    QList<Season> getAllSeasons();
58
81
 
59
82
        private:
62
85
    QSqlDatabase dbconn;
63
86
    QString sessionid;
64
87
 
 
88
    SpecialFields msp;
 
89
    QList<FieldDefinition> mfieldDefinitions;
 
90
    QList<KeywordDefinition> mkeywordDefinitions; //NOTE: not used in measures.xml
 
91
    QString mcolorfield;
 
92
 
65
93
        typedef QHash<QString,RideMetric*> MetricMap;
66
94
 
67
95
        bool createDatabase();
68
96
    void closeConnection();
69
97
    bool createMetricsTable();
70
98
    bool dropMetricTable();
71
 
        bool createIndex();
 
99
    bool createMeasuresTable();
 
100
    bool dropMeasuresTable();
72
101
        void initDatabase(QDir home);
73
 
 
74
 
 
75
102
};
76
103
#endif