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

connector.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 CONNECTOR_H
00021 #define CONNECTOR_H
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026 
00027 #include <qstring.h>
00028 #include <qstringlist.h>
00029 
00030 #include "exception.h"
00031 #include "kdb.h"
00032 
00033 #define QUERYTABLE "__KDBQueries"
00034 
00035 namespace KDB {
00036 
00037 class Exception;
00038 class Handler;
00039 class Table;
00040 
00041 class Connector {
00042 
00043  public:
00044     Connector();
00045     Connector(const Connector& c);
00046     virtual ~Connector();
00047 
00048     // nonvirtual methods
00049     void setHost(const QString & host);
00050     void setPort(int port);
00051     void setUser(const QString & user);
00052     void setPassword(const QString & pwd);
00053 
00054     QString host() const;
00055     int port() const;
00056     QString user() const;
00057     QString password() const;
00058     bool isConnected() const;
00059     // virtual methods: must be overridden in the subclass
00060 
00064     virtual void close();
00065 
00069     virtual bool connect() = 0;
00070 
00074     virtual QString protocol() const = 0;
00075 
00080     virtual QStringList databases() = 0;
00081 
00086     virtual QStringList tables() = 0;
00091     virtual QStringList queries() = 0;
00092 
00097     virtual QStringList fields(const QString & tableName) = 0;
00098 
00103     virtual unsigned long long execute(const QString &sql) = 0;
00104 
00108     virtual bool createDatabase(const QString & name) = 0;
00109 
00113     virtual bool createTable(const Table & tab) = 0;
00114 
00119     virtual Connector * clone() = 0;
00120 
00125     virtual bool setCurrentDatabase(const QString &name) = 0;
00126 
00130     virtual DataType nativeToKDB(const QString &type) = 0;
00131 
00135     virtual QString KDBToNative(DataType type) = 0;
00136 
00141     virtual Handler *query(const QString &SQL) = 0;
00142 
00143  protected:
00144 
00149     void setConnected(bool conn);
00150 
00151  private:
00152 
00153     QString _host;
00154     int _port;
00155     QString _user;
00156     QString _pwd;
00157 
00158     bool _connected;
00159 
00160 };
00161 
00162 };
00163 #endif
00164 
00165 

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