source: SMSSender/gateways/Schoolnet/persistence/deepthought/deepthoughtstorage.h @ 319:1ec456878bcb

separation-frontend-backend
Last change on this file since 319:1ec456878bcb was 319:1ec456878bcb, checked in by Sämy Zehnder <saemy.zehnder@…>, 8 years ago
  • Adjusts header guards to follow common pattern based on the filename.
File size: 2.9 KB
Line 
1/*
2 Schoolnet gateway plugin - The smssender plugin for the Schoolnet sms platform.
3 Copyright (C) 2007-2014, gorrión. See http://smssender.gorrion.ch
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18#ifndef SCHOOLNET_PERSISTENCE_DEEPTHOUGHT_DEEPTHOUGHTSTORAGE_H
19#define SCHOOLNET_PERSISTENCE_DEEPTHOUGHT_DEEPTHOUGHTSTORAGE_H
20
21#include <QDateTime>
22#include <QList>
23#include <QObject>
24#include <QSqlDatabase>
25#include <QSqlQuery>
26
27#include "common/persistence/impl/versionedstorage.h"
28#include "gateways/Schoolnet/business/deepthought/datatypes.h"
29
30namespace Schoolnet {
31class Account;
32
33namespace DeepThought {
34namespace Persistence {
35
36class DeepThoughtStorage : public ::Persistence::VersionedStorage {
37public:
38    QDateTime lastDeepThoughtRun();
39    void setLastDeepThoughtRun(QDateTime lastrun);
40
41    // Creates questions, caller takes ownership
42    void loadQuestions(QList<Question*> *questions);
43    void saveQuestion(const Question &question);
44    void removeQuestion(int questionId);
45
46    uint questionStatusAtSchoolnet(const Account &account, const Question &question);
47    void setQuestionStatusAtSchoolnet(const Account &account, const Question &question, uint status);
48
49    bool isQuestionStatusAtSchoolnetChecked(const Account &account, const Question &question);
50    void setQuestionStatusAtSchoolnetChecked(const Account &account, const Question &question);
51
52    bool isQuestionAnsweredAtSchoolnet(const Account &account, const Question &question);
53    void setQuestionAnsweredAtSchoolnet(const Account &account, const Question &question);
54
55public:
56    DeepThoughtStorage();
57
58protected:
59    void setDatabaseOptions();
60    bool doDatabaseUpgrade(uint currentDbVersion);
61
62private:
63    // Creates question, caller takes ownership.
64    void loadQuestion(int questionId, Question **question);
65
66    // Creates answers, caller takes ownership.
67    void loadAnswers(Question *question, QList<Answer*> *answers);
68
69    // Creates answer, caller takes ownership.
70    void loadAnswer(Question *question, const QString &answerId, Answer **answer);
71
72private:
73    void saveAnswer(const Answer &answer);
74
75private:
76    void initDB();
77    void version1To2();
78    void version2To3();
79    void version3To4();
80    void version4To5();
81};
82
83} // namespace Persistence
84} // namespace DeepThought
85} // namespace Schoolnet
86
87#endif /* SCHOOLNET_PERSISTENCE_DEEPTHOUGHT_DEEPTHOUGHTSTORAGE_H */
Note: See TracBrowser for help on using the repository browser.