~drizzle-trunk/drizzle/development

971.3.13 by Eric Day
Added new Protocol plugin header.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2008 Sun Microsystems
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
20
#ifndef DRIZZLED_PLUGIN_PROTOCOL_H
21
#define DRIZZLED_PLUGIN_PROTOCOL_H
22
23
#include <drizzled/sql_list.h>
24
#include <drizzled/item.h>
25
26
class Session;
27
class String;
28
29
class Protocol
30
{
31
protected:
32
  Session *session;
33
34
public:
35
  Protocol() {}
36
  virtual ~Protocol() {}
37
38
  virtual void setSession(Session *session_arg)
39
  {
40
    session= session_arg;
41
  }
42
43
  virtual Session *getSession(void)
44
  {
45
    return session;
46
  }
47
48
  virtual bool isConnected()= 0;
971.3.19 by Eric Day
Finished first pass at Protocol cleanup, still some things to remove but they are a bit more involved.
49
  virtual void setReadTimeout(uint32_t timeout)= 0;
50
  virtual void setWriteTimeout(uint32_t timeout)= 0;
51
  virtual void setRetryCount(uint32_t count)= 0;
52
  virtual void setError(char error)= 0;
53
  virtual bool haveError(void)= 0;
54
  virtual bool wasAborted(void)= 0;
55
  virtual void enableCompression(void)= 0;
56
  virtual bool haveMoreData(void)= 0;
57
  virtual bool isReading(void)= 0;
58
  virtual bool isWriting(void)= 0;
59
  virtual bool setFileDescriptor(int fd)=0;
60
  virtual int fileDescriptor(void)=0;
61
  virtual void setRandom(uint64_t, uint64_t) {};
971.3.13 by Eric Day
Added new Protocol plugin header.
62
  virtual bool authenticate(void)=0;
971.3.19 by Eric Day
Finished first pass at Protocol cleanup, still some things to remove but they are a bit more involved.
63
  virtual bool readCommand(char **packet, uint32_t *packet_length)=0;
971.3.13 by Eric Day
Added new Protocol plugin header.
64
  virtual void sendOK()= 0;
65
  virtual void sendEOF()= 0;
66
  virtual void sendError(uint32_t sql_errno, const char *err)=0;
971.3.23 by Eric Day
May have fixed shutdown problems.
67
  virtual void close()= 0;
68
  virtual void forceClose()= 0;
971.3.19 by Eric Day
Finished first pass at Protocol cleanup, still some things to remove but they are a bit more involved.
69
  virtual void prepareForResend()= 0;
971.3.17 by Eric Day
Cleaned up int/date related store functions.
70
  virtual void free()= 0;
71
  virtual bool write()= 0;
72
73
  enum { SEND_NUM_ROWS= 1, SEND_DEFAULTS= 2, SEND_EOF= 4 };
971.3.19 by Eric Day
Finished first pass at Protocol cleanup, still some things to remove but they are a bit more involved.
74
  virtual bool sendFields(List<Item> *list, uint32_t flags)= 0;
971.3.17 by Eric Day
Cleaned up int/date related store functions.
75
971.3.18 by Eric Day
Finished store() cleanup.
76
  virtual bool store(Field *from)= 0;
971.3.17 by Eric Day
Cleaned up int/date related store functions.
77
  virtual bool store(void)= 0;
78
  virtual bool store(int32_t from)= 0;
79
  virtual bool store(uint32_t from)= 0;
80
  virtual bool store(int64_t from)= 0;
81
  virtual bool store(uint64_t from)= 0;
971.3.18 by Eric Day
Finished store() cleanup.
82
  virtual bool store(double from, uint32_t decimals, String *buffer)= 0;
83
  virtual bool store(const DRIZZLE_TIME *from)= 0;
84
  virtual bool store(const char *from, const CHARSET_INFO * const cs)
85
  {
997.1.1 by cd
fixed crash in show processlist
86
    if (from == NULL) 
87
      return store();
971.3.18 by Eric Day
Finished store() cleanup.
88
    return store(from, strlen(from), cs);
89
  }
90
  virtual bool store(const char *from, size_t length,
91
                     const CHARSET_INFO * const cs)= 0;
971.3.13 by Eric Day
Added new Protocol plugin header.
92
};
93
971.3.16 by Eric Day
Cleaned up Protocol plugin interface (now a class factory) and moved libdrizzlclient to oldlibdrizzle to be clear.
94
class ProtocolFactory
95
{
971.1.46 by Monty Taylor
Made plugin registration go through Plugin_registry.
96
  std::string name;
971.3.16 by Eric Day
Cleaned up Protocol plugin interface (now a class factory) and moved libdrizzlclient to oldlibdrizzle to be clear.
97
public:
971.1.46 by Monty Taylor
Made plugin registration go through Plugin_registry.
98
  ProtocolFactory(std::string name_arg): name(name_arg) {}
99
  ProtocolFactory(const char *name_arg): name(name_arg) {}
971.3.16 by Eric Day
Cleaned up Protocol plugin interface (now a class factory) and moved libdrizzlclient to oldlibdrizzle to be clear.
100
  virtual ~ProtocolFactory() {}
101
  virtual Protocol *operator()(void)= 0;
971.1.46 by Monty Taylor
Made plugin registration go through Plugin_registry.
102
  std::string getName() {return name;}
971.3.16 by Eric Day
Cleaned up Protocol plugin interface (now a class factory) and moved libdrizzlclient to oldlibdrizzle to be clear.
103
};
104
971.3.13 by Eric Day
Added new Protocol plugin header.
105
#endif /* DRIZZLED_PLUGIN_PROTOCOL_H */