~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/client.h

  • Committer: Toru Maesaka
  • Date: 2008-12-11 07:45:27 UTC
  • mto: (670.1.11 devel)
  • mto: This revision was merged to the branch mainline in revision 672.
  • Revision ID: dev@torum.net-20081211074527-yu0cpi5pumqifgg5
Added namespacing for std to .cc files that needed it

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_CLIENT_H
21
 
#define DRIZZLED_PLUGIN_CLIENT_H
22
 
 
23
 
#include <drizzled/sql_list.h>
24
 
#include <drizzled/item.h>
25
 
 
26
 
namespace drizzled
27
 
{
28
 
class Session;
29
 
class String;
30
 
 
31
 
namespace plugin
32
 
{
33
 
 
34
 
/**
35
 
 * This class allows new client sources to be written. This could be through
36
 
 * network protocols, in-process threads, or any other client source that can
37
 
 * provide commands and handle result sets. The current implementation is
38
 
 * file-descriptor based, so for non-fd client sources (like from another
39
 
 * thread), derived classes will need to use a pipe() for event notifications.
40
 
 */
41
 
class Client
42
 
{
43
 
protected:
44
 
  Session *session;
45
 
 
46
 
public:
47
 
  virtual ~Client() {}
48
 
 
49
 
  /**
50
 
   * Get attached session from the client object.
51
 
   * @retval Session object that is attached, NULL if none.
52
 
   */
53
 
  virtual Session *getSession(void)
54
 
  {
55
 
    return session;
56
 
  }
57
 
 
58
 
  /**
59
 
   * Attach session to the client object.
60
 
   * @param[in] session_arg Session object to attach, or NULL to clear.
61
 
   */
62
 
  virtual void setSession(Session *session_arg)
63
 
  {
64
 
    session= session_arg;
65
 
  }
66
 
 
67
 
  /**
68
 
   * Get file descriptor associated with client object.
69
 
   * @retval File descriptor that is attached, -1 if none.
70
 
   */
71
 
  virtual int getFileDescriptor(void)= 0;
72
 
 
73
 
  /**
74
 
   * Check to see if the client is currently connected.
75
 
   * @retval Boolean value representing connected state.
76
 
   */
77
 
  virtual bool isConnected(void)= 0;
78
 
 
79
 
  /**
80
 
   * Check to see if the client is actively reading.
81
 
   * @retval Boolean value representing reading state.
82
 
   */
83
 
  virtual bool isReading(void)= 0;
84
 
 
85
 
  /**
86
 
   * Check to see if the client is actively writing.
87
 
   * @retval Boolean value representing writing state.
88
 
   */
89
 
  virtual bool isWriting(void)= 0;
90
 
 
91
 
  /**
92
 
   * Flush all data that has been buffered with store() methods.
93
 
   * @retval Boolean indicating success or failure.
94
 
   */
95
 
  virtual bool flush(void)= 0;
96
 
 
97
 
  /**
98
 
   * Close the client object.
99
 
   */
100
 
  virtual void close(void)= 0;
101
 
 
102
 
  /**
103
 
   * Perform handshake and authorize client if needed.
104
 
   */
105
 
  virtual bool authenticate(void)= 0;
106
 
 
107
 
  /**
108
 
   * Read command from client.
109
 
   */
110
 
  virtual bool readCommand(char **packet, uint32_t *packet_length)= 0;
111
 
 
112
 
  /* Send responses. */
113
 
  virtual void sendOK(void)= 0;
114
 
  virtual void sendEOF(void)= 0;
115
 
  virtual void sendError(uint32_t sql_errno, const char *err)= 0;
116
 
 
117
 
  /**
118
 
   * Send field list for result set.
119
 
   */
120
 
  virtual bool sendFields(List<Item> *list)= 0;
121
 
 
122
 
  /* Send result fields in various forms. */
123
 
  virtual bool store(Field *from)= 0;
124
 
  virtual bool store(void)= 0;
125
 
  virtual bool store(int32_t from)= 0;
126
 
  virtual bool store(uint32_t from)= 0;
127
 
  virtual bool store(int64_t from)= 0;
128
 
  virtual bool store(uint64_t from)= 0;
129
 
  virtual bool store(double from, uint32_t decimals, String *buffer)= 0;
130
 
  virtual bool store(const DRIZZLE_TIME *from);
131
 
  virtual bool store(const char *from);
132
 
  virtual bool store(const char *from, size_t length)= 0;
133
 
  virtual bool store(const std::string &from)
134
 
  {
135
 
    return store(from.c_str(), from.size());
136
 
  }
137
 
 
138
 
  /* Try to remove these. */
139
 
  virtual bool haveMoreData(void)= 0;
140
 
  virtual bool haveError(void)= 0;
141
 
  virtual bool wasAborted(void)= 0;
142
 
 
143
 
};
144
 
 
145
 
} /* namespace plugin */
146
 
} /* namespace drizzled */
147
 
 
148
 
#endif /* DRIZZLED_PLUGIN_CLIENT_H */