~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/identifier/table.h

  • Committer: Andrew Hutchings
  • Date: 2011-02-01 10:23:22 UTC
  • mto: (2136.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2137.
  • Revision ID: andrew@linuxjedi.co.uk-20110201102322-oxztcyrjzg3c7yta
Fix counters cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
  This will replace Table_ident.
31
31
  */
32
32
 
33
 
#pragma once
 
33
#ifndef DRIZZLED_IDENTIFIER_TABLE_H
 
34
#define DRIZZLED_IDENTIFIER_TABLE_H
34
35
 
35
36
#include <drizzled/enum.h>
36
 
#include <drizzled/definitions.h>
37
 
#include <drizzled/message/table.pb.h>
 
37
#include "drizzled/definitions.h"
 
38
#include "drizzled/message/table.pb.h"
38
39
 
39
40
#include <string.h>
40
41
 
47
48
 
48
49
#include <boost/functional/hash.hpp>
49
50
 
50
 
#include <drizzled/visibility.h>
51
 
#include <drizzled/identifier/schema.h>
 
51
#include "drizzled/visibility.h"
52
52
 
53
53
namespace drizzled {
 
54
class Table;
 
55
 
54
56
namespace identifier {
55
57
 
56
58
class DRIZZLED_API Table : public Schema
57
59
{
58
60
public:
59
61
  typedef message::Table::TableType Type;
 
62
  typedef std::vector <Table> vector;
 
63
  typedef const Table& const_reference;
 
64
  typedef Table& reference;
60
65
 
61
66
  class Key
62
67
  {
113
118
 
114
119
  Type type;
115
120
  std::string path;
116
 
  std::string key_path;
117
121
  std::string table_name;
118
122
  Key key;
119
123
  size_t hash_value;
166
170
  {
167
171
    if (type == message::Table::TEMPORARY || type == message::Table::INTERNAL)
168
172
      return true;
169
 
 
170
173
    return false;
171
174
  }
172
175
 
196
199
    return type;
197
200
  }
198
201
 
199
 
  virtual std::string getSQLPath() const;
 
202
  virtual void getSQLPath(std::string &sql_path) const;
200
203
 
201
204
  virtual const std::string &getPath() const;
202
 
  const std::string &getKeyPath() const;
203
205
 
204
206
  void setPath(const std::string &new_path)
205
207
  {
213
215
 
214
216
  void copyToTableMessage(message::Table &message) const;
215
217
 
216
 
  friend bool operator<(const Table& left, const Table& right)
 
218
  friend bool operator<(Table::const_reference left, Table::const_reference right)
217
219
  {
218
220
    if (left.getKey() < right.getKey())
219
221
    {
223
225
    return false;
224
226
  }
225
227
 
226
 
  friend bool operator==(const Table& left, const Table& right)
 
228
  friend std::ostream& operator<<(std::ostream& output, Table::const_reference identifier)
 
229
  {
 
230
    const char *type_str;
 
231
 
 
232
    output << "Table:(";
 
233
    output <<  identifier.getSchemaName();
 
234
    output << ", ";
 
235
    output << identifier.getTableName();
 
236
    output << ", ";
 
237
 
 
238
    switch (identifier.type) {
 
239
    case message::Table::STANDARD:
 
240
      type_str= "standard";
 
241
      break;
 
242
    case message::Table::INTERNAL:
 
243
      type_str= "internal";
 
244
      break;
 
245
    case message::Table::TEMPORARY:
 
246
      type_str= "temporary";
 
247
      break;
 
248
    case message::Table::FUNCTION:
 
249
      type_str= "function";
 
250
      break;
 
251
    }
 
252
 
 
253
    output << type_str;
 
254
    output << ", ";
 
255
    output << identifier.path;
 
256
    output << ", ";
 
257
    output << identifier.getHashValue();
 
258
    output << ")";
 
259
 
 
260
    return output;  // for multiple << operators.
 
261
  }
 
262
 
 
263
  friend bool operator==(Table::const_reference left, Table::const_reference right)
227
264
  {
228
265
    if (left.getHashValue() == right.getHashValue())
229
266
    {
253
290
  }
254
291
};
255
292
 
256
 
std::ostream& operator<<(std::ostream& output, const Table& identifier);
257
293
std::size_t hash_value(Table const& b);
258
294
std::size_t hash_value(Table::Key const& b);
259
295
 
260
296
} /* namespace identifier */
261
297
} /* namespace drizzled */
 
298
 
 
299
#endif /* DRIZZLED_IDENTIFIER_TABLE_H */