~drizzle-trunk/drizzle/jenkins-Drizzle-Builder-187

« back to all changes in this revision

Viewing changes to unittests/plugin/plugin_stubs.h

  • Committer: Paweł Blokus
  • Date: 2010-06-09 20:36:51 UTC
  • mto: This revision was merged to the branch mainline in revision 1620.
  • Revision ID: pawel@pawel-desktop-20100609203651-mbq5x34bt9m3kv0o
minor style fixes

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) 2010 Pawel Blokus
 
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; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
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.
 
15
 *
 
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
 
19
 */
 
20
 
 
21
 
 
22
 #ifndef UNITTESTS_STUB_PLUGIN_STUBS_H
 
23
 #define UNITTESTS_STUB_PLUGIN_STUBS_H
 
24
 
 
25
 #include "config.h"
 
26
 #include <drizzled/plugin/client.h>
 
27
 #include <cstring>
 
28
 
 
29
class ClientStub : public drizzled::plugin::Client
 
30
{
 
31
  protected:
 
32
    bool store_ret_val;
 
33
    char *last_call_char_ptr;
 
34
 
 
35
  public:
 
36
 
 
37
    ClientStub() :
 
38
    store_ret_val(false),
 
39
    last_call_char_ptr(NULL)
 
40
    {}
 
41
 
 
42
    inline void set_store_ret_val(bool value)
 
43
    {
 
44
      store_ret_val= value;
 
45
    }
 
46
 
 
47
    inline void set_last_call_char_ptr(char *ptr)
 
48
    {
 
49
      last_call_char_ptr= ptr;
 
50
    }
 
51
 
 
52
    virtual ~ClientStub() {}
 
53
    
 
54
    /**
 
55
    * Get attached session from the client object.
 
56
    * @retval Session object that is attached, NULL if none.
 
57
    */
 
58
    virtual drizzled::Session *getSession(void)
 
59
    {
 
60
      return Client::getSession();
 
61
    }
 
62
    
 
63
    /**
 
64
    * Attach session to the client object.
 
65
    * @param[in] session_arg Session object to attach, or NULL to clear.
 
66
    */
 
67
    virtual void setSession(drizzled::Session *session_arg)
 
68
    {
 
69
      Client::setSession(session_arg);
 
70
    }
 
71
    
 
72
    /**
 
73
    * Get file descriptor associated with client object.
 
74
    * @retval File descriptor that is attached, -1 if none.
 
75
    */
 
76
    virtual int getFileDescriptor(void) { return 0; };
 
77
    
 
78
    /**
 
79
    * Check to see if the client is currently connected.
 
80
    * @retval Boolean value representing connected state.
 
81
    */
 
82
    virtual bool isConnected(void) { return false; };
 
83
    
 
84
    /**
 
85
    * Check to see if the client is actively reading.
 
86
    * @retval Boolean value representing reading state.
 
87
    */
 
88
    virtual bool isReading(void) { return false; };
 
89
    
 
90
    /**
 
91
    * Check to see if the client is actively writing.
 
92
    * @retval Boolean value representing writing state.
 
93
    */
 
94
    virtual bool isWriting(void)  { return false; };
 
95
    
 
96
    /**
 
97
    * Flush all data that has been buffered with store() methods.
 
98
    * @retval Boolean indicating success or failure.
 
99
    */
 
100
    virtual bool flush(void)  { return false; };
 
101
    
 
102
    /**
 
103
    * Close the client object.
 
104
    */
 
105
    virtual void close(void) {};
 
106
    
 
107
    /**
 
108
    * Perform handshake and authorize client if needed.
 
109
    */
 
110
    virtual bool authenticate(void) { return false; };
 
111
    
 
112
    /**
 
113
    * Read command from client.
 
114
    */
 
115
    virtual bool readCommand(char **packet, uint32_t *packet_length)
 
116
    {
 
117
      (void)packet;
 
118
      (void)packet_length;
 
119
      return false;
 
120
    };
 
121
    
 
122
    /* Send responses. */
 
123
    virtual void sendOK(void) {};
 
124
    virtual void sendEOF(void) {};
 
125
    virtual void sendError(uint32_t sql_errno, const char *err)
 
126
    {
 
127
      (void)sql_errno;
 
128
      (void)err;
 
129
    };
 
130
    
 
131
    /**
 
132
    * Send field list for result set.
 
133
    */
 
134
    virtual bool sendFields(drizzled::List<drizzled::Item> *list)
 
135
    {
 
136
      (void)list;
 
137
      return false;
 
138
    };
 
139
    
 
140
    /* Send result fields in various forms. */
 
141
    virtual bool store(drizzled::Field *from)
 
142
    {
 
143
      (void)from;
 
144
      return store_ret_val;
 
145
    };
 
146
    virtual bool store(void) { return store_ret_val; };
 
147
    virtual bool store(int32_t from)
 
148
    {
 
149
      (void)from;
 
150
      return store_ret_val;
 
151
    };
 
152
    virtual bool store(uint32_t from)
 
153
    {
 
154
      (void)from;
 
155
      return store_ret_val;
 
156
    };
 
157
    virtual bool store(int64_t from)
 
158
    {
 
159
      (void)from;
 
160
      return store_ret_val;
 
161
    };
 
162
    virtual bool store(uint64_t from)
 
163
    {
 
164
      (void)from;
 
165
      return store_ret_val;
 
166
    };
 
167
    virtual bool store(double from, uint32_t decimals, drizzled::String *buffer)
 
168
    {
 
169
      (void)from;
 
170
      (void)decimals;
 
171
      (void)buffer;
 
172
      return store_ret_val;
 
173
    };
 
174
    virtual bool store(const drizzled::DRIZZLE_TIME *from)
 
175
    {
 
176
      return Client::store(from);
 
177
    }
 
178
    virtual bool store(const char *from)
 
179
    {
 
180
      return Client::store(from);
 
181
    }
 
182
    virtual bool store(const char *from, size_t length)
 
183
    {
 
184
      strncpy(last_call_char_ptr, from, length);
 
185
      return store_ret_val;
 
186
    };
 
187
    virtual bool store(const std::string &from)
 
188
    {
 
189
      return Client::store(from);
 
190
    }
 
191
    
 
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;};
 
196
};
 
197
 
 
198
 
 
199
#endif /* UNITTESTS_STUB_PLUGIN_STUBS_H */