~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
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
971.3.13 by Eric Day
Added new Protocol plugin header.
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
971.6.1 by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way.
20
#ifndef DRIZZLED_PLUGIN_CLIENT_H
21
#define DRIZZLED_PLUGIN_CLIENT_H
971.3.13 by Eric Day
Added new Protocol plugin header.
22
23
#include <drizzled/sql_list.h>
24
#include <drizzled/item.h>
25
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
26
#include "drizzled/visibility.h"
27
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
28
namespace drizzled
29
{
971.3.13 by Eric Day
Added new Protocol plugin header.
30
class Session;
31
class String;
32
971.3.65 by Eric Day
Namespace cleanup for Protocol and Listen.
33
namespace plugin
34
{
35
971.6.1 by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way.
36
/**
37
 * This class allows new client sources to be written. This could be through
38
 * network protocols, in-process threads, or any other client source that can
39
 * provide commands and handle result sets. The current implementation is
40
 * file-descriptor based, so for non-fd client sources (like from another
41
 * thread), derived classes will need to use a pipe() for event notifications.
42
 */
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
43
class DRIZZLED_API Client
971.3.13 by Eric Day
Added new Protocol plugin header.
44
{
45
protected:
46
  Session *session;
47
48
public:
971.6.1 by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way.
49
  virtual ~Client() {}
50
51
  /**
52
   * Get attached session from the client object.
53
   * @retval Session object that is attached, NULL if none.
54
   */
55
  virtual Session *getSession(void)
56
  {
57
    return session;
58
  }
59
60
  /**
61
   * Attach session to the client object.
62
   * @param[in] session_arg Session object to attach, or NULL to clear.
63
   */
971.3.13 by Eric Day
Added new Protocol plugin header.
64
  virtual void setSession(Session *session_arg)
65
  {
66
    session= session_arg;
67
  }
68
971.6.1 by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way.
69
  /**
70
   * Get file descriptor associated with client object.
71
   * @retval File descriptor that is attached, -1 if none.
72
   */
73
  virtual int getFileDescriptor(void)= 0;
74
75
  /**
76
   * Check to see if the client is currently connected.
77
   * @retval Boolean value representing connected state.
78
   */
79
  virtual bool isConnected(void)= 0;
80
81
  /**
82
   * Check to see if the client is actively reading.
83
   * @retval Boolean value representing reading state.
84
   */
971.3.19 by Eric Day
Finished first pass at Protocol cleanup, still some things to remove but they are a bit more involved.
85
  virtual bool isReading(void)= 0;
971.6.1 by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way.
86
87
  /**
88
   * Check to see if the client is actively writing.
89
   * @retval Boolean value representing writing state.
90
   */
971.3.19 by Eric Day
Finished first pass at Protocol cleanup, still some things to remove but they are a bit more involved.
91
  virtual bool isWriting(void)= 0;
971.6.1 by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way.
92
93
  /**
94
   * Flush all data that has been buffered with store() methods.
95
   * @retval Boolean indicating success or failure.
96
   */
97
  virtual bool flush(void)= 0;
98
99
  /**
100
   * Close the client object.
101
   */
102
  virtual void close(void)= 0;
103
104
  /**
105
   * Perform handshake and authorize client if needed.
106
   */
107
  virtual bool authenticate(void)= 0;
108
2098.4.1 by Brian Aker
Make session encapsulated.
109
  virtual bool isConsole()
110
  {
111
    return false;
112
  }
113
2104.1.2 by Brian Aker
Update console to switch to different catalogs.
114
  virtual  catalog::Instance::shared_ptr catalog()
115
  {
116
    return catalog::local();
117
  }
118
971.6.1 by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way.
119
  /**
120
   * Read command from client.
121
   */
971.6.10 by Eric Day
Added NULL client for rm_tmp_table.
122
  virtual bool readCommand(char **packet, uint32_t *packet_length)= 0;
971.6.1 by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way.
123
124
  /* Send responses. */
125
  virtual void sendOK(void)= 0;
126
  virtual void sendEOF(void)= 0;
2126.3.4 by Brian Aker
Additional error cleanup (passing error correctly to the client code).
127
  virtual void sendError(const drizzled::error_t sql_errno, const char *err)= 0;
971.3.17 by Eric Day
Cleaned up int/date related store functions.
128
971.6.1 by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way.
129
  /**
130
   * Send field list for result set.
131
   */
971.3.63 by Eric Day
Removed protocol field flags.
132
  virtual bool sendFields(List<Item> *list)= 0;
971.3.17 by Eric Day
Cleaned up int/date related store functions.
133
971.6.1 by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way.
134
  /* Send result fields in various forms. */
971.3.18 by Eric Day
Finished store() cleanup.
135
  virtual bool store(Field *from)= 0;
971.3.17 by Eric Day
Cleaned up int/date related store functions.
136
  virtual bool store(void)= 0;
137
  virtual bool store(int32_t from)= 0;
138
  virtual bool store(uint32_t from)= 0;
139
  virtual bool store(int64_t from)= 0;
140
  virtual bool store(uint64_t from)= 0;
971.3.18 by Eric Day
Finished store() cleanup.
141
  virtual bool store(double from, uint32_t decimals, String *buffer)= 0;
2030.1.5 by Brian Aker
Update for moving DRIZZLE_TIME to type::Time
142
  virtual bool store(const type::Time *from);
971.7.1 by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup.
143
  virtual bool store(const char *from);
1054.2.9 by Monty Taylor
Removed CHARSET_INFO stuff from protocol plugin interface - it makes no sense.
144
  virtual bool store(const char *from, size_t length)= 0;
1245.2.4 by Monty Taylor
Fixed the store methods to take std::string properly.
145
  virtual bool store(const std::string &from)
1245.2.1 by Monty Taylor
Removed final use if I_List<> in the server.
146
  {
147
    return store(from.c_str(), from.size());
148
  }
971.6.1 by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way.
149
150
  /* Try to remove these. */
151
  virtual bool haveMoreData(void)= 0;
152
  virtual bool haveError(void)= 0;
153
  virtual bool wasAborted(void)= 0;
1192.2.2 by Monty Taylor
Added type name strings to all of the plugin types.
154
971.3.13 by Eric Day
Added new Protocol plugin header.
155
};
156
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
157
} /* namespace plugin */
158
} /* namespace drizzled */
971.3.65 by Eric Day
Namespace cleanup for Protocol and Listen.
159
971.6.1 by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way.
160
#endif /* DRIZZLED_PLUGIN_CLIENT_H */