~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/generator/table.h

Reverted 1103

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 Brian Aker
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
 
#ifndef DRIZZLED_GENERATOR_TABLE_H
22
 
#define DRIZZLED_GENERATOR_TABLE_H
23
 
 
24
 
#include "drizzled/plugin/storage_engine.h"
25
 
 
26
 
namespace drizzled {
27
 
 
28
 
class Session;
29
 
 
30
 
namespace generator {
31
 
 
32
 
class Table
33
 
{
34
 
  Session &session;
35
 
  message::table::shared_ptr table;
36
 
 
37
 
  identifier::Table::vector table_names;
38
 
  identifier::Table::vector::const_iterator table_iterator;
39
 
 
40
 
public:
41
 
 
42
 
  Table(Session &arg, const identifier::Schema &schema_identifier);
43
 
 
44
 
  operator const drizzled::message::table::shared_ptr()
45
 
  {
46
 
    while (table_iterator != table_names.end())
47
 
    {
48
 
      table->Clear();
49
 
      bool is_table_parsed= plugin::StorageEngine::getTableDefinition(session, *table_iterator, table);
50
 
      table_iterator++;
51
 
 
52
 
      if (is_table_parsed)
53
 
        return table;
54
 
    }
55
 
 
56
 
    return message::table::shared_ptr();
57
 
  }
58
 
 
59
 
  operator const drizzled::identifier::Table*()
60
 
  {
61
 
    while (table_iterator != table_names.end())
62
 
    {
63
 
      const drizzled::identifier::Table *_ptr= &(*table_iterator);
64
 
      table_iterator++;
65
 
 
66
 
      return _ptr;
67
 
    }
68
 
 
69
 
    return NULL;
70
 
  }
71
 
};
72
 
 
73
 
} /* namespace generator */
74
 
} /* namespace drizzled */
75
 
 
76
 
#endif /* DRIZZLED_GENERATOR_TABLE_H */