00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019
00020 #ifndef DATABASE_H
00021 #define DATABASE_H
00022
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026
00027 #include <qstring.h>
00028 #include <qstringlist.h>
00029 #include <qlist.h>
00030 #include <qvaluelist.h>
00031
00032 #include <ksharedptr.h>
00033
00034 #include <kdb/table.h>
00035 #include <kdb/query.h>
00036 #include <kdb/recordset.h>
00037
00038 #include "object.h"
00039
00040
00041 namespace KDB {
00042
00043 class Connector;
00044
00045 class Database;
00046 typedef QList<Database> DatabaseList;
00047 typedef QListIterator<Database> DatabaseIterator;
00048
00063 class Database : public Object{
00064
00065 friend class Connection;
00066
00067 Q_OBJECT
00068
00069 public:
00070
00071 Database(const Database & base);
00072
00073 virtual ~Database();
00074
00080 TablePtr newTable(const QString &name);
00081
00086 TablePtr getTable(const QString &name);
00087
00093 TableList tables(bool system = false);
00094
00100 QStringList tableNames(bool system = false);
00101
00107 bool removeTable(const QString &name);
00108
00118 QueryPtr newQuery(const QString &name, const QString &SQL = QString::null);
00119
00124 QueryPtr getQuery(const QString &name);
00125
00129 QueryList queries();
00130
00134 QStringList queryNames();
00135
00139 bool removeQuery(const QString &name);
00140
00147 RecordsetPtr openRecordset(const QString &SQL);
00148
00153 unsigned long long execute(const QString &SQL);
00154
00155 bool open();
00156
00157 void close();
00158
00159 bool isOpen();
00160
00161
00162 signals:
00163
00164 void tableAdded( Table * );
00165 void tableRemoved( Table * );
00166 void tableChanged( Table * );
00167 void queryAdded( Query * );
00168 void queryRemoved( Query * );
00169 void queryChanged( Query * );
00170 void changed();
00171 void closed();
00172 void opened();
00173
00174 protected slots:
00175
00176 void tableCreated( Table * );
00177
00178 private:
00179
00180 Connector * connector;
00181 QStringList m_tables;
00182 QStringList m_queries;
00183
00184 bool m_open;
00185
00186 Database(Connector *conn, const char * name, QObject *parent );
00187
00188 void createQueryTable();
00189
00190 };
00191
00192 }
00193
00194 #endif
00195
00196