|
|
#ifndef DATABASE_H #define DATABASE_H #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <qstring.h> #include <qvaluelist.h> #include "object.h" namespace KDB { class TablePtr; class RecordsetPtr; class QueryPtr; typedef QValueList<TablePtr> Tables; typedef QValueList<QueryPtr> Queries; /** * Central access point to all functionality of the single database. * * That means it provides a list of all queries and tables, and is able to execute * a command query and to return a recordset for a given query. * * Tables and queries can be accessed by name, and the class can * provide collection objects for both. * */ class Database : public Object{ Q_OBJECT public: Database( const char * name ); virtual ~Database(); /** * creates a new table for the current database. * please note that the table is not yet part of the * database until you call @ref KDB::Table::create */ virtual TablePtr newTable(const QString &name) = 0; /** * returns an existing table by name, or 0L if the * table does not exists */ TablePtr getTable(const QString &name); /** * return the list of available tables */ Tables tables(); /** * removes a table from the database. This means * that the table is dropped, and all the content * is erased */ virtual void removeTable(const QString &name) = 0; /** * creates a new query * * @param name this is the name of the query * * @param SQL this is the sql executed by the * query. if it is not given, the query can be built * with addTable, addField and so on */ virtual QueryPtr newQuery(const QString &name, const QString &SQL) = 0; /** * returns an existing query by name, or 0L if the * query does not exists */ QueryPtr getQuery(const QString &name); /** * return the list of available queries */ Queries queries(); /** * removes a query from the database. */ virtual void removeQuery(const QString &name) = 0; /** * creates a recordset based on a given query. * if the query fails, 0L is returned. you can then * check @ref errorMessage() to get a specific error * message */ virtual RecordsetPtr openRecordset(const QString &SQL) = 0; /** * exec a command query. returns the number of * records affected, or -1 if there is an error executing the * query */ virtual int execute(const QString &SQL) = 0; virtual void open() = 0; virtual void close() = 0; bool isOpen(); protected: Tables m_tables; Queries m_queries; bool m_open; QString m_name; }; } #endif
Generated by: pradu@server.rete.casa on Fri Jul 28 15:15:55 2000, using kdoc 2.0a36. |