Drizzled Public API Documentation

client.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program 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
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 #pragma once
00021 
00022 #include <drizzled/catalog/instance.h>
00023 #include <drizzled/catalog/local.h>
00024 #include <drizzled/error_t.h>
00025 #include <drizzled/item.h>
00026 #include <drizzled/visibility.h>
00027 
00028 namespace drizzled {
00029 namespace plugin {
00030 
00038 class DRIZZLED_API Client
00039 {
00040 protected:
00041   Session *session;
00042 
00043 public:
00044   virtual ~Client() {}
00045 
00050   virtual Session *getSession()
00051   {
00052     return session;
00053   }
00054 
00059   virtual void setSession(Session *session_arg)
00060   {
00061     session= session_arg;
00062   }
00063 
00068   virtual int getFileDescriptor()= 0;
00069 
00074   virtual bool isConnected()= 0;
00075 
00080   virtual bool flush()= 0;
00081 
00085   virtual void close()= 0;
00086 
00090   virtual bool authenticate()= 0;
00091 
00092   virtual bool isConsole() const
00093   {
00094     return false;
00095   }
00096 
00097   virtual bool isInteractive() const
00098   {
00099     return false;
00100   }
00101 
00102   virtual catalog::Instance::shared_ptr catalog()
00103   {
00104     return catalog::local();
00105   }
00106 
00110   virtual bool readCommand(char **packet, uint32_t& packet_length)= 0;
00111 
00112   /* Send responses. */
00113   virtual void sendOK()= 0;
00114   virtual void sendEOF()= 0;
00115   virtual void sendError(const drizzled::error_t sql_errno, const char *err)= 0;
00116 
00120   virtual void sendFields(List<Item>&)= 0;
00121 
00122   /* Send result fields in various forms. */
00123   virtual void store(Field *from)= 0;
00124   virtual void store()= 0;
00125   virtual void store(int32_t from)= 0;
00126   virtual void store(uint32_t from)= 0;
00127   virtual void store(int64_t from)= 0;
00128   virtual void store(uint64_t from)= 0;
00129   virtual void store(double from, uint32_t decimals, String *buffer)= 0;
00130   virtual void store(const type::Time *from);
00131   virtual void store(const char *from);
00132   virtual void store(const char *from, size_t length)= 0;
00133   virtual void store(str_ref from)
00134   {
00135     store(from.data(), from.size());
00136   }
00137 
00138   /* Try to remove these. */
00139   virtual bool haveError()= 0;
00140   virtual bool wasAborted()= 0;
00141 
00142 };
00143 
00144 } /* namespace plugin */
00145 } /* namespace drizzled */