ctkPluginDatabase_p.h

Go to the documentation of this file.
00001 /*=============================================================================
00002 
00003   Library: CTK
00004 
00005   Copyright (c) 2010 German Cancer Research Center,
00006     Division of Medical and Biological Informatics
00007 
00008   Licensed under the Apache License, Version 2.0 (the "License");
00009   you may not use this file except in compliance with the License.
00010   You may obtain a copy of the License at
00011 
00012     http://www.apache.org/licenses/LICENSE-2.0
00013 
00014   Unless required by applicable law or agreed to in writing, software
00015   distributed under the License is distributed on an "AS IS" BASIS,
00016   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00017   See the License for the specific language governing permissions and
00018   limitations under the License.
00019 
00020 =============================================================================*/
00021 
00022 #ifndef CTKPLUGINDATABASE_P_H
00023 #define CTKPLUGINDATABASE_P_H
00024 
00025 #include <QtSql>
00026 #include <QList>
00027 
00028 
00029 
00030 // CTK class forward declarations
00031 class ctkPluginStorage;
00032 class ctkPluginArchive;
00033 
00034 class ctkPluginDatabase {
00035 
00036   public:
00037     ctkPluginDatabase(ctkPluginStorage* storage);
00038 
00039     virtual ~ctkPluginDatabase();
00040 
00051     void open();
00052 
00059     void close();
00060 
00064     bool isOpen() const;
00065 
00069     void setDatabasePath(const QString &databasePath);
00070 
00074     QString getDatabasePath() const;
00075 
00087     QByteArray getPluginResource(long pluginId, const QString& res) const;
00088 
00098     QStringList findResourcesPath(long pluginId, const QString& path) const;
00099 
00111     ctkPluginArchive* insertPlugin(const QUrl& location, const QString& localPath, bool createArchive = true);
00112 
00118     void removeArchive(const ctkPluginArchive* pa);
00119 
00126     QList<ctkPluginArchive*> getPluginArchives() const;
00127 
00128 
00129   private:
00130 
00131     enum TransactionType{Read, Write};
00132 
00138     void createTables();
00139     bool dropTables();
00140 
00146     bool checkTables() const;
00147 
00153     void checkConnection() const;
00154 
00162     void updateDB();
00163 
00175     void executeQuery(QSqlQuery* query, const QString &statement, const QList<QVariant> &bindValues = QList<QVariant>()) const;
00176 
00182     void beginTransaction(QSqlQuery* query, TransactionType);
00183 
00189     void commitTransaction(QSqlQuery* query);
00190 
00196     void rollbackTransaction(QSqlQuery* query);
00197 
00198 
00199     QString m_databasePath;
00200     QString m_connectionName;
00201     bool m_isDatabaseOpen;
00202     bool m_inTransaction;
00203     ctkPluginStorage* m_PluginStorage;
00204 };
00205 
00206 
00207 #endif // CTKPLUGINDATABASE_P_H
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines