2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
4
* Copyright (C) 2010 Brian Aker
5
* Copyright (C) 2009 Sun Microsystems
5
* Copyright (C) 2009 Sun Microsystems, Inc.
7
7
* This program is free software; you can redistribute it and/or modify
8
8
* it under the terms of the GNU General Public License as published by
30
30
This will replace Table_ident.
33
#ifndef DRIZZLED_IDENTIFIER_TABLE_H
34
#define DRIZZLED_IDENTIFIER_TABLE_H
36
35
#include <drizzled/enum.h>
37
#include "drizzled/definitions.h"
38
#include "drizzled/message/table.pb.h"
40
#include "drizzled/identifier.h"
36
#include <drizzled/definitions.h>
37
#include <drizzled/message/table.pb.h>
42
39
#include <string.h>
51
48
#include <boost/functional/hash.hpp>
50
#include <drizzled/visibility.h>
51
#include <drizzled/identifier/schema.h>
53
53
namespace drizzled {
57
class TableIdentifier : public SchemaIdentifier
54
namespace identifier {
56
class DRIZZLED_API Table : public Schema
60
59
typedef message::Table::TableType Type;
61
typedef std::vector <TableIdentifier> vector;
62
typedef const TableIdentifier& const_reference;
63
typedef TableIdentifier& reference;
132
TableIdentifier(const Table &table);
130
Table(const drizzled::Table &table);
134
TableIdentifier( const SchemaIdentifier &schema,
135
const std::string &table_name_arg,
136
Type tmp_arg= message::Table::STANDARD) :
137
SchemaIdentifier(schema),
139
table_name(table_name_arg)
144
TableIdentifier( const std::string &db_arg,
145
const std::string &table_name_arg,
146
Type tmp_arg= message::Table::STANDARD) :
147
SchemaIdentifier(db_arg),
149
table_name(table_name_arg)
154
TableIdentifier( const std::string &schema_name_arg,
132
Table(const identifier::Schema &schema,
133
const std::string &table_name_arg,
134
Type tmp_arg= message::Table::STANDARD) :
137
table_name(table_name_arg)
142
Table( const std::string &db_arg,
143
const std::string &table_name_arg,
144
Type tmp_arg= message::Table::STANDARD) :
147
table_name(table_name_arg)
152
Table( const std::string &schema_name_arg,
155
153
const std::string &table_name_arg,
156
154
const std::string &path_arg ) :
157
SchemaIdentifier(schema_name_arg),
155
Schema(schema_name_arg),
158
156
type(message::Table::TEMPORARY),
160
158
table_name(table_name_arg)
200
virtual void getSQLPath(std::string &sql_path) const;
199
virtual std::string getSQLPath() const;
202
201
virtual const std::string &getPath() const;
202
const std::string &getKeyPath() const;
204
204
void setPath(const std::string &new_path)
214
214
void copyToTableMessage(message::Table &message) const;
216
friend bool operator<(TableIdentifier::const_reference left, TableIdentifier::const_reference right)
216
friend bool operator<(const Table& left, const Table& right)
218
218
if (left.getKey() < right.getKey())
226
friend std::ostream& operator<<(std::ostream& output, TableIdentifier::const_reference identifier)
228
const char *type_str;
230
output << "TableIdentifier:(";
231
output << identifier.getSchemaName();
233
output << identifier.getTableName();
236
switch (identifier.type) {
237
case message::Table::STANDARD:
238
type_str= "standard";
240
case message::Table::INTERNAL:
241
type_str= "internal";
243
case message::Table::TEMPORARY:
244
type_str= "temporary";
246
case message::Table::FUNCTION:
247
type_str= "function";
253
output << identifier.path;
255
output << identifier.getHashValue();
258
return output; // for multiple << operators.
261
friend bool operator==(TableIdentifier::const_reference left, TableIdentifier::const_reference right)
226
friend bool operator==(const Table& left, const Table& right)
263
228
if (left.getHashValue() == right.getHashValue())
291
std::size_t hash_value(TableIdentifier const& b);
292
std::size_t hash_value(TableIdentifier::Key const& b);
256
std::ostream& operator<<(std::ostream& output, const Table& identifier);
257
std::size_t hash_value(Table const& b);
258
std::size_t hash_value(Table::Key const& b);
260
} /* namespace identifier */
294
261
} /* namespace drizzled */
296
#endif /* DRIZZLED_IDENTIFIER_TABLE_H */