1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
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.
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.
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
20
#ifndef DRIZZLED_PLUGIN_CLIENT_H
21
#define DRIZZLED_PLUGIN_CLIENT_H
23
#include <drizzled/catalog/instance.h>
24
#include <drizzled/catalog/local.h>
25
#include <drizzled/error_t.h>
26
#include <drizzled/item.h>
27
#include <drizzled/sql_list.h>
29
#include "drizzled/visibility.h"
40
* This class allows new client sources to be written. This could be through
41
* network protocols, in-process threads, or any other client source that can
42
* provide commands and handle result sets. The current implementation is
43
* file-descriptor based, so for non-fd client sources (like from another
44
* thread), derived classes will need to use a pipe() for event notifications.
46
class DRIZZLED_API Client
55
* Get attached session from the client object.
56
* @retval Session object that is attached, NULL if none.
58
virtual Session *getSession(void)
64
* Attach session to the client object.
65
* @param[in] session_arg Session object to attach, or NULL to clear.
67
virtual void setSession(Session *session_arg)
73
* Get file descriptor associated with client object.
74
* @retval File descriptor that is attached, -1 if none.
76
virtual int getFileDescriptor(void)= 0;
79
* Check to see if the client is currently connected.
80
* @retval Boolean value representing connected state.
82
virtual bool isConnected(void)= 0;
85
* Check to see if the client is actively reading.
86
* @retval Boolean value representing reading state.
88
virtual bool isReading(void)= 0;
91
* Check to see if the client is actively writing.
92
* @retval Boolean value representing writing state.
94
virtual bool isWriting(void)= 0;
97
* Flush all data that has been buffered with store() methods.
98
* @retval Boolean indicating success or failure.
100
virtual bool flush(void)= 0;
103
* Close the client object.
105
virtual void close(void)= 0;
108
* Perform handshake and authorize client if needed.
110
virtual bool authenticate(void)= 0;
112
virtual bool isConsole()
117
virtual catalog::Instance::shared_ptr catalog()
119
return catalog::local();
123
* Read command from client.
125
virtual bool readCommand(char **packet, uint32_t *packet_length)= 0;
127
/* Send responses. */
128
virtual void sendOK(void)= 0;
129
virtual void sendEOF(void)= 0;
130
virtual void sendError(const drizzled::error_t sql_errno, const char *err)= 0;
133
* Send field list for result set.
135
virtual bool sendFields(List<Item> *list)= 0;
137
/* Send result fields in various forms. */
138
virtual bool store(Field *from)= 0;
139
virtual bool store(void)= 0;
140
virtual bool store(int32_t from)= 0;
141
virtual bool store(uint32_t from)= 0;
142
virtual bool store(int64_t from)= 0;
143
virtual bool store(uint64_t from)= 0;
144
virtual bool store(double from, uint32_t decimals, String *buffer)= 0;
145
virtual bool store(const type::Time *from);
146
virtual bool store(const char *from);
147
virtual bool store(const char *from, size_t length)= 0;
148
virtual bool store(const std::string &from)
150
return store(from.c_str(), from.size());
153
/* Try to remove these. */
154
virtual bool haveMoreData(void)= 0;
155
virtual bool haveError(void)= 0;
156
virtual bool wasAborted(void)= 0;
160
} /* namespace plugin */
161
} /* namespace drizzled */
163
#endif /* DRIZZLED_PLUGIN_CLIENT_H */