~drizzle-trunk/drizzle/development

1960.1.5 by Brian Aker
Merging in the first pass through the catalog work.
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
2200 by Brian Aker
Testing pragma once for build farm.
21
#pragma once
1960.1.5 by Brian Aker
Merging in the first pass through the catalog work.
22
23
#include <drizzled/enum.h>
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
24
#include <drizzled/definitions.h>
1960.1.5 by Brian Aker
Merging in the first pass through the catalog work.
25
#include <string.h>
26
2371.1.1 by Brian Aker
Fedora fix/use fwd header for iostream.
27
#include <cassert>
1960.1.5 by Brian Aker
Merging in the first pass through the catalog work.
28
29
#include <ostream>
2060.4.1 by Brian Aker
Merge in trunk to catalogs.
30
#include <vector>
1960.1.5 by Brian Aker
Merging in the first pass through the catalog work.
31
#include <algorithm>
32
#include <functional>
2371.1.1 by Brian Aker
Fedora fix/use fwd header for iostream.
33
#include <iosfwd>
1960.1.5 by Brian Aker
Merging in the first pass through the catalog work.
34
35
#include <boost/algorithm/string.hpp>
36
37
namespace drizzled {
38
namespace identifier {
39
2060.4.1 by Brian Aker
Merge in trunk to catalogs.
40
class Catalog : public Identifier
1960.1.5 by Brian Aker
Merging in the first pass through the catalog work.
41
{
42
public:
43
  Catalog(const std::string &name_arg);
2073.1.2 by Brian Aker
Basic DDL for catalog.
44
  Catalog(const drizzled::lex_string_t &name_arg);
2240.2.2 by Olaf van der Spek
Refactor
45
  bool isValid() const;
46
  bool compare(const std::string &arg) const;
47
48
  const std::string &getPath() const
49
  {
50
    return path;
51
  }
1960.1.5 by Brian Aker
Merging in the first pass through the catalog work.
52
53
  const std::string &getName() const
54
  {
2039.6.6 by Brian Aker
Update so that CATALOG is correctly being displayed.
55
    return _name;
56
  }
57
58
  const std::string &name() const
59
  {
60
    return _name;
1960.1.5 by Brian Aker
Merging in the first pass through the catalog work.
61
  }
62
2246.4.2 by Olaf van der Spek
Refactor Identifier::getSQLPath()
63
  virtual std::string getSQLPath() const
2240.2.2 by Olaf van der Spek
Refactor
64
  {
2246.4.2 by Olaf van der Spek
Refactor Identifier::getSQLPath()
65
    return _name;
2240.2.2 by Olaf van der Spek
Refactor
66
  }
1960.1.5 by Brian Aker
Merging in the first pass through the catalog work.
67
68
  size_t getHashValue() const
69
  {
70
    return hash_value;
71
  }
72
73
  friend bool operator<(const Catalog &left, const Catalog &right)
74
  {
2240.2.2 by Olaf van der Spek
Refactor
75
    return boost::ilexicographical_compare(left.getName(), right.getName());
1960.1.5 by Brian Aker
Merging in the first pass through the catalog work.
76
  }
77
1960.1.8 by Brian Aker
Big hunk of burning create/drop work.
78
  friend std::ostream& operator<<(std::ostream& output, const Catalog &identifier)
1960.1.5 by Brian Aker
Merging in the first pass through the catalog work.
79
  {
2240.2.2 by Olaf van der Spek
Refactor
80
    return output << "Catalog:(" <<  identifier.getName() << ", " << identifier.getPath() << ")";
1960.1.5 by Brian Aker
Merging in the first pass through the catalog work.
81
  }
82
2240.2.2 by Olaf van der Spek
Refactor
83
  friend bool operator==(const Catalog &left, const Catalog &right)
1960.1.5 by Brian Aker
Merging in the first pass through the catalog work.
84
  {
85
    return boost::iequals(left.getName(), right.getName());
86
  }
87
private:
2240.2.2 by Olaf van der Spek
Refactor
88
  void init();
89
90
  std::string _name;
91
  std::string path;
1960.1.5 by Brian Aker
Merging in the first pass through the catalog work.
92
  size_t hash_value;
93
};
94
2240.2.2 by Olaf van der Spek
Refactor
95
inline std::size_t hash_value(Catalog const& b)
96
{
97
  return b.getHashValue();
98
}
1960.1.5 by Brian Aker
Merging in the first pass through the catalog work.
99
100
} /* namespace identifier */
101
} /* namespace drizzled */