2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
4
* Copyright (C) 2010 Brian Aker
5
* Copyright (C) 2009 Sun Microsystems, Inc.
5
* Copyright (C) 2009 Sun Microsystems
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
49
51
#include <boost/functional/hash.hpp>
51
#include "drizzled/visibility.h"
53
53
namespace drizzled {
56
namespace identifier {
58
class DRIZZLED_API Table : public Schema
57
class TableIdentifier : public SchemaIdentifier
61
60
typedef message::Table::TableType Type;
62
typedef std::vector <Table> vector;
63
typedef const Table& const_reference;
64
typedef Table& reference;
135
Table(const drizzled::Table &table);
130
TableIdentifier(const Table &table);
137
Table(const identifier::Schema &schema,
138
const std::string &table_name_arg,
139
Type tmp_arg= message::Table::STANDARD) :
142
table_name(table_name_arg)
147
Table( const std::string &db_arg,
148
const std::string &table_name_arg,
149
Type tmp_arg= message::Table::STANDARD) :
152
table_name(table_name_arg)
157
Table( const std::string &schema_name_arg,
132
TableIdentifier( const SchemaIdentifier &schema,
133
const std::string &table_name_arg,
134
Type tmp_arg= message::Table::STANDARD) :
135
SchemaIdentifier(schema),
137
table_name(table_name_arg)
142
TableIdentifier( const std::string &db_arg,
143
const std::string &table_name_arg,
144
Type tmp_arg= message::Table::STANDARD) :
145
SchemaIdentifier(db_arg),
147
table_name(table_name_arg)
152
TableIdentifier( const std::string &schema_name_arg,
158
153
const std::string &table_name_arg,
159
154
const std::string &path_arg ) :
160
Schema(schema_name_arg),
155
SchemaIdentifier(schema_name_arg),
161
156
type(message::Table::TEMPORARY),
163
158
table_name(table_name_arg)
204
virtual void getSQLPath(std::string &sql_path) const;
198
const std::string &getSQLPath();
206
virtual const std::string &getPath() const;
207
const std::string &getKeyPath() const;
200
const std::string &getPath() const;
209
202
void setPath(const std::string &new_path)
219
212
void copyToTableMessage(message::Table &message) const;
221
friend bool operator<(Table::const_reference left, Table::const_reference right)
214
friend bool operator<(const TableIdentifier &left, const TableIdentifier &right)
223
216
if (left.getKey() < right.getKey())
231
friend bool operator==(Table::const_reference left, Table::const_reference right)
224
friend std::ostream& operator<<(std::ostream& output, const TableIdentifier &identifier)
226
const char *type_str;
228
output << "TableIdentifier:(";
229
output << identifier.getSchemaName();
231
output << identifier.getTableName();
234
switch (identifier.type) {
235
case message::Table::STANDARD:
236
type_str= "standard";
238
case message::Table::INTERNAL:
239
type_str= "internal";
241
case message::Table::TEMPORARY:
242
type_str= "temporary";
244
case message::Table::FUNCTION:
245
type_str= "function";
251
output << identifier.path;
253
output << identifier.getHashValue();
256
return output; // for multiple << operators.
259
friend bool operator==(TableIdentifier &left, TableIdentifier &right)
233
261
if (left.getHashValue() == right.getHashValue())
261
std::ostream& operator<<(std::ostream& output, Table::const_reference identifier);
262
std::size_t hash_value(Table const& b);
263
std::size_t hash_value(Table::Key const& b);
265
} /* namespace identifier */
288
std::size_t hash_value(TableIdentifier const& b);
289
std::size_t hash_value(TableIdentifier::Key const& b);
291
typedef std::vector <TableIdentifier> TableIdentifiers;
266
293
} /* namespace drizzled */
268
295
#endif /* DRIZZLED_IDENTIFIER_TABLE_H */