Sayonara Player
AbstractDatabase.h
1 /* AbstractDatabase.h */
2 
3 /* Copyright (C) 2011-2016 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 
23 #ifndef ABSTRACTDATABASE_H
24 #define ABSTRACTDATABASE_H
25 
26 #include <QSqlDatabase>
27 #include <QFile>
28 #include <QDir>
29 #include <QSqlError>
30 #include <QMap>
31 #include <QList>
32 
33 
34 class AbstractDatabase : public QObject
35 {
36 
37 public:
38  explicit AbstractDatabase(quint8 db_id, const QString& db_dir, const QString& db_name, QObject *parent=nullptr);
39  virtual ~AbstractDatabase();
40 
41  virtual void close_db();
42  virtual bool is_initialized();
43 
44  virtual void transaction();
45  virtual void commit();
46  virtual void rollback();
47 
48  static void remove_connections();
49 
50  quint8 get_id();
51 
52 
53 protected:
54  QSqlDatabase _database;
55  QString _db_path;
56  QString _db_name;
57  QString _db_dir;
58  quint8 _db_id;
59 
65 
66  virtual bool exists();
67  virtual bool create_db();
68  virtual bool open_db();
69  virtual bool apply_fixes()=0;
70 
71  virtual bool check_and_insert_column(QString tablename, QString column, QString sqltype);
72  virtual bool check_and_create_table(QString tablename, QString sql_create_str);
73  virtual bool check_and_drop_table(QString tablename);
74 };
75 
76 #endif // ABSTRACTDATABASE_H
Definition: AbstractDatabase.h:34
bool _initialized
Definition: AbstractDatabase.h:64