~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/protocol.h

  • Committer: Brian Aker
  • Date: 2009-04-09 01:50:49 UTC
  • mfrom: (971.3.21 eday-dev)
  • Revision ID: brian@gaz-20090409015049-ohyn58r972hkccj2
MergeĀ Eric

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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;
 
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) {};
 
62
  virtual bool authenticate(void)=0;
 
63
  virtual bool readCommand(char **packet, uint32_t *packet_length)=0;
 
64
  virtual void sendOK()= 0;
 
65
  virtual void sendEOF()= 0;
 
66
  virtual void sendError(uint32_t sql_errno, const char *err)=0;
 
67
  virtual void close(void) {};
 
68
  virtual void prepareForResend()= 0;
 
69
  virtual void free()= 0;
 
70
  virtual bool write()= 0;
 
71
 
 
72
  enum { SEND_NUM_ROWS= 1, SEND_DEFAULTS= 2, SEND_EOF= 4 };
 
73
  virtual bool sendFields(List<Item> *list, uint32_t flags)= 0;
 
74
 
 
75
  virtual bool store(Field *from)= 0;
 
76
  virtual bool store(void)= 0;
 
77
  virtual bool store(int32_t from)= 0;
 
78
  virtual bool store(uint32_t from)= 0;
 
79
  virtual bool store(int64_t from)= 0;
 
80
  virtual bool store(uint64_t from)= 0;
 
81
  virtual bool store(double from, uint32_t decimals, String *buffer)= 0;
 
82
  virtual bool store(const DRIZZLE_TIME *from)= 0;
 
83
  virtual bool store(const char *from, const CHARSET_INFO * const cs)
 
84
  {
 
85
    if (from == NULL)
 
86
      store();
 
87
    return store(from, strlen(from), cs);
 
88
  }
 
89
  virtual bool store(const char *from, size_t length,
 
90
                     const CHARSET_INFO * const cs)= 0;
 
91
};
 
92
 
 
93
class ProtocolFactory
 
94
{
 
95
public:
 
96
  ProtocolFactory() {}
 
97
  virtual ~ProtocolFactory() {}
 
98
  virtual Protocol *operator()(void)= 0;
 
99
};
 
100
 
 
101
#endif /* DRIZZLED_PLUGIN_PROTOCOL_H */