kexi

kexidbconnection.h

00001 /***************************************************************************
00002  * kexidbconnection.h
00003  * This file is part of the KDE project
00004  * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this program; see the file COPYING.  If not, write to
00016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  ***************************************************************************/
00019 
00020 #ifndef KROSS_KEXIDB_KEXIDBCONNECTION_H
00021 #define KROSS_KEXIDB_KEXIDBCONNECTION_H
00022 
00023 #include <qstring.h>
00024 #include <ksharedptr.h>
00025 
00026 #include <api/object.h>
00027 #include <api/variant.h>
00028 #include <api/list.h>
00029 #include <api/class.h>
00030 
00031 //#include <kexidb/driver.h>
00032 #include <kexidb/connection.h>
00033 
00034 namespace Kross { namespace KexiDB {
00035 
00036     // Forward declarations.
00037     class KexiDBDriver;
00038     class KexiDBConnectionData;
00039     class KexiDBCursor;
00040     class KexiDBTableSchema;
00041     class KexiDBQuerySchema;
00042     class KexiDBTransaction;
00043     class KexiDBParser;
00044 
00068     class KexiDBConnection : public Kross::Api::Class<KexiDBConnection>
00069     {
00070         public:
00071             KexiDBConnection(::KexiDB::Connection* connection, KexiDBDriver* driver = 0, KexiDBConnectionData* connectiondata = 0);
00072             virtual ~KexiDBConnection();
00073             virtual const QString getClassName() const;
00074 
00075         private:
00076 
00078             bool hadError() const;
00080             const QString lastError() const;
00081 
00083             KexiDBConnectionData* data();
00085             KexiDBDriver* driver();
00086 
00088             bool connect();
00090             bool isConnected();
00092             bool disconnect();
00093 
00095             bool isReadOnly() const;
00096 
00098             bool databaseExists(const QString& dbname);
00101             const QString currentDatabase() const;
00103             const QStringList databaseNames() const;
00105             bool isDatabaseUsed() const;
00108             bool useDatabase(const QString& dbname);
00110             bool closeDatabase();
00111 
00114             const QStringList allTableNames() const;
00116             const QStringList tableNames() const;
00118             const QStringList queryNames() const;
00119 
00122             KexiDBCursor* executeQueryString(const QString& sqlquery);
00125             KexiDBCursor* executeQuerySchema(KexiDBQuerySchema* queryschema);
00126 
00127 //TODO replace following method with a proxymethod.
00129             Kross::Api::Object::Ptr insertRecord(Kross::Api::List::Ptr);
00130 
00132             bool createDatabase(const QString& dbname);
00134             bool dropDatabase(const QString& dbname);
00135 
00137             bool createTable(KexiDBTableSchema* tableschema);
00139             bool dropTable(const QString& tablename);
00142             bool alterTable(KexiDBTableSchema* fromschema, KexiDBTableSchema* toschema);
00145             bool alterTableName(KexiDBTableSchema* tableschema, const QString& newtablename);
00146 
00149             KexiDBTableSchema* tableSchema(const QString& tablename) const;
00151             bool isEmptyTable(KexiDBTableSchema* tableschema) const;
00153             KexiDBQuerySchema* querySchema(const QString& queryname) const;
00154 
00156             bool autoCommit() const;
00159             bool setAutoCommit(bool enabled);
00160 
00162             KexiDBTransaction* beginTransaction();
00164             bool commitTransaction(KexiDBTransaction* transaction);
00166             bool rollbackTransaction(KexiDBTransaction* transaction);
00168             KexiDBTransaction* defaultTransaction();
00171             void setDefaultTransaction(KexiDBTransaction* transaction);
00172 
00174             Kross::Api::List* transactions();
00175 
00177             KexiDBParser* parser();
00178 
00179         private:
00180             ::KexiDB::Connection* connection() const;
00181             ::KexiDB::Connection* m_connection;
00182 
00183             KSharedPtr<KexiDBConnectionData> m_connectiondata;
00184             KSharedPtr<KexiDBDriver> m_driver;
00185 
00187             void initialize();
00188 
00189     };
00190 
00191 }}
00192 
00193 #endif
00194 
KDE Home | KDE Accessibility Home | Description of Access Keys