1
/* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Pawel Blokus
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; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
#ifndef UNITTESTS_STUB_PLUGIN_STUBS_H
23
#define UNITTESTS_STUB_PLUGIN_STUBS_H
26
#include <drizzled/plugin/client.h>
29
class ClientStub : public drizzled::plugin::Client
33
char *last_call_char_ptr;
39
last_call_char_ptr(NULL)
42
inline void set_store_ret_val(bool value)
47
inline void set_last_call_char_ptr(char *ptr)
49
last_call_char_ptr= ptr;
52
virtual ~ClientStub() {}
55
* Get attached session from the client object.
56
* @retval Session object that is attached, NULL if none.
58
virtual drizzled::Session *getSession(void)
60
return Client::getSession();
64
* Attach session to the client object.
65
* @param[in] session_arg Session object to attach, or NULL to clear.
67
virtual void setSession(drizzled::Session *session_arg)
69
Client::setSession(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) { return 0; };
79
* Check to see if the client is currently connected.
80
* @retval Boolean value representing connected state.
82
virtual bool isConnected(void) { return false; };
85
* Check to see if the client is actively reading.
86
* @retval Boolean value representing reading state.
88
virtual bool isReading(void) { return false; };
91
* Check to see if the client is actively writing.
92
* @retval Boolean value representing writing state.
94
virtual bool isWriting(void) { return false; };
97
* Flush all data that has been buffered with store() methods.
98
* @retval Boolean indicating success or failure.
100
virtual bool flush(void) { return false; };
103
* Close the client object.
105
virtual void close(void) {};
108
* Perform handshake and authorize client if needed.
110
virtual bool authenticate(void) { return false; };
113
* Read command from client.
115
virtual bool readCommand(char **packet, uint32_t *packet_length)
122
/* Send responses. */
123
virtual void sendOK(void) {};
124
virtual void sendEOF(void) {};
125
virtual void sendError(uint32_t sql_errno, const char *err)
132
* Send field list for result set.
134
virtual bool sendFields(drizzled::List<drizzled::Item> *list)
140
/* Send result fields in various forms. */
141
virtual bool store(drizzled::Field *from)
144
return store_ret_val;
146
virtual bool store(void) { return store_ret_val; };
147
virtual bool store(int32_t from)
150
return store_ret_val;
152
virtual bool store(uint32_t from)
155
return store_ret_val;
157
virtual bool store(int64_t from)
160
return store_ret_val;
162
virtual bool store(uint64_t from)
165
return store_ret_val;
167
virtual bool store(double from, uint32_t decimals, drizzled::String *buffer)
172
return store_ret_val;
174
virtual bool store(const drizzled::DRIZZLE_TIME *from)
176
return Client::store(from);
178
virtual bool store(const char *from)
180
return Client::store(from);
182
virtual bool store(const char *from, size_t length)
184
strncpy(last_call_char_ptr, from, length);
185
return store_ret_val;
187
virtual bool store(const std::string &from)
189
return Client::store(from);
192
/* Try to remove these. */
193
virtual bool haveMoreData(void) { return false; };
194
virtual bool haveError(void) { return false; };
195
virtual bool wasAborted(void) { return false;};
199
#endif /* UNITTESTS_STUB_PLUGIN_STUBS_H */