~drizzle-trunk/drizzle/development

1415 by Brian Aker
Mass overhaul to use schema_identifier.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2009 Sun Microsystems
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
/* 
22
  This is a "work in progress". The concept needs to be replicated throughout
23
  the code, but we will start with baby steps for the moment. To not incur
24
  cost until we are complete, for the moment it will do no allocation.
25
26
  This is mainly here so that it can be used in the SE interface for
27
  the time being.
28
29
  This will replace Table_ident.
30
  */
31
32
#ifndef DRIZZLED_SCHEMA_IDENTIFIER_H
33
#define DRIZZLED_SCHEMA_IDENTIFIER_H
34
35
#include <drizzled/enum.h>
36
#include "drizzled/definitions.h"
37
#include "drizzled/message/table.pb.h"
38
#include <string.h>
39
40
#include <assert.h>
41
42
#include <ostream>
43
#include <list>
44
#include <algorithm>
45
#include <functional>
46
#include <iostream>
47
1643.3.9 by Brian Aker
Updated to hold tables in I_S.
48
1415 by Brian Aker
Mass overhaul to use schema_identifier.
49
namespace drizzled {
50
1643.3.9 by Brian Aker
Updated to hold tables in I_S.
51
static std::string catalog("");
52
1415 by Brian Aker
Mass overhaul to use schema_identifier.
53
class SchemaIdentifier
54
{
55
  std::string db;
56
  std::string db_path;
57
  std::string lower_db;
58
1643.3.9 by Brian Aker
Updated to hold tables in I_S.
59
1415 by Brian Aker
Mass overhaul to use schema_identifier.
60
  // @note this should be changed to protected once Session contains an
61
  // identifier for current db.
62
public:
63
1596.1.4 by Monty Taylor
Fixed TableIdentifier sorting. The customer operator<() wasn't getting called on Sun Studio.
64
  const std::string &getLower() const
1415 by Brian Aker
Mass overhaul to use schema_identifier.
65
  {
1596.1.4 by Monty Taylor
Fixed TableIdentifier sorting. The customer operator<() wasn't getting called on Sun Studio.
66
    return lower_db;
1415 by Brian Aker
Mass overhaul to use schema_identifier.
67
  }
68
69
public:
1613 by Brian Aker
Fix solaris warning.
70
  SchemaIdentifier(const std::string &db_arg);
1415 by Brian Aker
Mass overhaul to use schema_identifier.
71
72
  virtual ~SchemaIdentifier()
73
  { }
74
75
  virtual const std::string &getSQLPath();
1613 by Brian Aker
Fix solaris warning.
76
  const std::string &getPath() const;
1415 by Brian Aker
Mass overhaul to use schema_identifier.
77
78
  const std::string &getSchemaName() const
79
  {
80
    return db;
81
  }
82
1643.3.9 by Brian Aker
Updated to hold tables in I_S.
83
  const std::string &getCatalogName() const
84
  {
85
    return catalog;
86
  }
87
1613 by Brian Aker
Fix solaris warning.
88
  bool isValid() const;
1418.1.2 by Monty Taylor
Fixed Solaris issue with the operator< by adding some constness. While I was
89
  bool compare(std::string arg) const;
1415 by Brian Aker
Mass overhaul to use schema_identifier.
90
1418.1.2 by Monty Taylor
Fixed Solaris issue with the operator< by adding some constness. While I was
91
  friend bool operator<(const SchemaIdentifier &left, const SchemaIdentifier &right)
1415 by Brian Aker
Mass overhaul to use schema_identifier.
92
  {
93
    return left.lower_db < right.lower_db;
94
  }
95
1418.1.2 by Monty Taylor
Fixed Solaris issue with the operator< by adding some constness. While I was
96
  friend std::ostream& operator<<(std::ostream& output,
97
                                  SchemaIdentifier &identifier)
1415 by Brian Aker
Mass overhaul to use schema_identifier.
98
  {
99
    output << "SchemaIdentifier:(";
100
    output <<  identifier.db;
101
    output << ", ";
102
    output << identifier.getPath();
103
    output << ")";
104
105
    return output;  // for multiple << operators.
106
  }
107
1418.1.2 by Monty Taylor
Fixed Solaris issue with the operator< by adding some constness. While I was
108
  friend bool operator==(const SchemaIdentifier &left,
109
                         const SchemaIdentifier &right)
1415 by Brian Aker
Mass overhaul to use schema_identifier.
110
  {
111
    if (left.lower_db == right.lower_db)
112
    {
113
      return true;
114
    }
115
116
    return false;
117
  }
118
119
};
120
1643.3.13 by Brian Aker
Remove sort() and add in DEBUG mode to randomize the results of generators.
121
typedef std::vector <SchemaIdentifier> SchemaIdentifiers;
1415 by Brian Aker
Mass overhaul to use schema_identifier.
122
123
} /* namespace drizzled */
124
125
#endif /* DRIZZLED_SCHEMA_IDENTIFIER_H */