~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table_generator.h

  • Committer: Brian Aker
  • Date: 2010-07-01 23:03:22 UTC
  • mto: This revision was merged to the branch mainline in revision 1647.
  • Revision ID: brian@gaz-20100701230322-kwfewmxproqgkiby
Updated to harmonize the identifier API.

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