Drizzled Public API Documentation

catalog.h
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 #pragma once
22 
23 #include <drizzled/enum.h>
24 #include <drizzled/definitions.h>
25 #include <drizzled/util/data_ref.h>
26 #include <cstring>
27 #include <cassert>
28 #include <ostream>
29 #include <vector>
30 #include <algorithm>
31 #include <functional>
32 #include <iosfwd>
33 #include <boost/algorithm/string.hpp>
34 
35 namespace drizzled {
36 namespace identifier {
37 
38 class Catalog : public Identifier
39 {
40 public:
42  bool isValid() const;
43  bool compare(const std::string &arg) const;
44 
45  const std::string &getPath() const
46  {
47  return path;
48  }
49 
50  const std::string &getName() const
51  {
52  return _name;
53  }
54 
55  const std::string &name() const
56  {
57  return _name;
58  }
59 
60  virtual std::string getSQLPath() const
61  {
62  return _name;
63  }
64 
65  size_t getHashValue() const
66  {
67  return hash_value;
68  }
69 
70  friend bool operator<(const Catalog &left, const Catalog &right)
71  {
72  return boost::ilexicographical_compare(left.getName(), right.getName());
73  }
74 
75  friend std::ostream& operator<<(std::ostream& output, const Catalog &identifier)
76  {
77  return output << "Catalog:(" << identifier.getName() << ", " << identifier.getPath() << ")";
78  }
79 
80  friend bool operator==(const Catalog &left, const Catalog &right)
81  {
82  return boost::iequals(left.getName(), right.getName());
83  }
84 
85  void resetPath()
86  {
87  init();
88  }
89 
90 private:
91  void init();
92 
93  std::string _name;
94  std::string path;
95  size_t hash_value;
96 };
97 
98 inline std::size_t hash_value(Catalog const& b)
99 {
100  return b.getHashValue();
101 }
102 
103 } /* namespace identifier */
104 } /* namespace drizzled */