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