Source: dbengine.h


Annotated List
Files
Globals
Hierarchy
Index
#ifndef DBENGINE_H
#define DBENGINE_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <qlist.h>
#include "object.h"

namespace KDB {

class Plugin;
class Connection;
class Database;

/**
 * This object manages all available plugins, and can create connections to
 * servers or databases.
 *
 * In more detail:
 * @li On first reference, loads all plugins registered in $KDEDIR/share/services.
 * @li Allows iterations trough all available plugins.
 * @li Provide functions to directly access connections and databases trough @ref openDatabase
 * and @ref openConnection
 *
 * @short Entry point for the library
 */

class DBEngine : public Object{

    Q_OBJECT

public:
    typedef QListIterator<Plugin> iterator;

public:
    virtual ~DBEngine();

    /**
     * creates, if needed, the engine object, and returns it
     */
    static DBEngine *self();

    /**
     * returns an iterator that points to the first plugin
     */
    iterator begin();

    /**
     * find a plugin by name. If no plugin is found, OL is returned
     */
    Plugin * find(const QString &name);

    /**
     * open a connection to the given host, with the given plugin, username
     * and password. if the plugin does not exists, OL is returned. This is
     * a convenience function, to avoid passing trough a plugin to get a connection
     */
    Connection * openConnection(const QString &pluginName, const QString &host, int port,
                                const QString &user, const QString &password);

    /**
     * open a database. This is a convenience function
     */
    Database * openDatabase(const QString &pluginName, const QString &host, int port,
                            const QString &user, const QString &password,
                            const QString &databaseName);

private:
    explicit DBEngine();
    static DBEngine * m_engine;

    QList<Plugin> m_plugins;
};

}
#define DBENGINE KDB::DBEngine::self()

#endif



Generated by: pradu@server.rete.casa on Fri Jul 28 15:15:55 2000, using kdoc 2.0a36.