Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

dbengine.h

Go to the documentation of this file.
00001 /*
00002    This file is part of the KDB libraries
00003    Copyright (c) 2000 Praduroux Alessandro <pradu@thekompany.com>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library 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 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.
00019 */
00020 #ifndef DBENGINE_H
00021 #define DBENGINE_H
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026 
00027 #include <qlist.h>
00028 #include <qstringlist.h>
00029 
00030 #include <ktrader.h>
00031 
00032 #include "object.h"
00033 #include "plugin.h"
00034 #include "connection.h"
00035 
00036 class KConfigBase;
00037 
00038 namespace KDB {
00039 
00040 class Database;
00041 
00059 class DBEngine : public Object{
00060 
00061     Q_OBJECT
00062 
00063  public:
00064     virtual ~DBEngine();
00065 
00069     static DBEngine *self();
00070 
00074     PluginIterator beginPlugins();
00075 
00079     Plugin * findPlugin(const QString &name);
00080 
00084     QStringList pluginNames();
00085 
00091     Connection * openConnection(const QString &pluginName, const QString &host, int port,
00092                                 const QString &user, const QString &password = QString::null);
00093 
00098     Connection * openConnection(const QString &name);
00099 
00103     virtual Connection * addConnection (const QString &pluginName,
00104                                         const QString &host,
00105                                         int port = 0,
00106                                         const QString &user = QString::null,
00107                                         const QString &password = QString::null);
00108 
00114     void remove(Connection *);
00115 
00121     Connection * findConnection(const QString &plugin,
00122                                 const QString &host,
00123                                 const int port,
00124                                 const QString &user);
00128     Connection * findConnection(const QString &name);
00129 
00134     ConnectionIterator beginConnections();
00135 
00141     void loadConnections(KConfigBase *config = 0L);
00142 
00148     void saveConnections(KConfigBase *config = 0L);
00149 
00153     Database * openDatabase(const QString &pluginName, const QString &host, int port,
00154                             const QString &user, const QString &password,
00155                             const QString &databaseName);
00156 
00157  protected:
00158 
00162     bool loadPlugin(const QString&);
00163     
00164  protected slots:
00165 
00166     void slotConnectionClosed(Connection *);
00167  
00168     void slotDeleteConnection();
00169 
00170  private:
00171 
00172     explicit DBEngine();
00173     static DBEngine * m_engine;
00174 
00175     KTrader::OfferList m_pluginData;
00176     PluginList  m_plugins;
00177 
00178     ConnectionList m_connections;
00179     Connection * m_connToDelete;
00180 };
00181 
00182 }
00183 #define DBENGINE KDB::DBEngine::self()
00184 
00185 #endif

Generated at Fri Sep 29 16:32:21 2000 for KDB by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000