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 |
||
21 |
#ifndef DRIZZLED_IDENTIFIER_CATALOG_H
|
|
22 |
#define DRIZZLED_IDENTIFIER_CATALOG_H
|
|
23 |
||
24 |
#include <drizzled/enum.h> |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
25 |
#include <drizzled/definitions.h> |
1960.1.5
by Brian Aker
Merging in the first pass through the catalog work. |
26 |
#include <string.h> |
27 |
||
28 |
#include <assert.h> |
|
29 |
||
30 |
#include <ostream> |
|
2060.4.1
by Brian Aker
Merge in trunk to catalogs. |
31 |
#include <vector> |
1960.1.5
by Brian Aker
Merging in the first pass through the catalog work. |
32 |
#include <algorithm> |
33 |
#include <functional> |
|
34 |
#include <iostream> |
|
35 |
||
36 |
#include <boost/algorithm/string.hpp> |
|
37 |
||
38 |
namespace drizzled { |
|
2060.4.1
by Brian Aker
Merge in trunk to catalogs. |
39 |
|
2073.1.2
by Brian Aker
Basic DDL for catalog. |
40 |
class lex_string_t; |
41 |
||
1960.1.5
by Brian Aker
Merging in the first pass through the catalog work. |
42 |
namespace identifier { |
43 |
||
2060.4.1
by Brian Aker
Merge in trunk to catalogs. |
44 |
class Catalog : public Identifier |
1960.1.5
by Brian Aker
Merging in the first pass through the catalog work. |
45 |
{
|
2039.6.6
by Brian Aker
Update so that CATALOG is correctly being displayed. |
46 |
std::string _name; |
1960.1.5
by Brian Aker
Merging in the first pass through the catalog work. |
47 |
std::string path; |
48 |
||
2073.1.2
by Brian Aker
Basic DDL for catalog. |
49 |
void init(); |
1960.1.5
by Brian Aker
Merging in the first pass through the catalog work. |
50 |
|
51 |
public: |
|
1960.1.6
by Brian Aker
Adding in the engine interface. The filesystem catalog will now handle |
52 |
typedef std::vector<Catalog> vector; |
2039.6.3
by Brian Aker
Update for session to have a catalog object. |
53 |
typedef const Catalog& const_reference; |
54 |
typedef Catalog& reference; |
|
1960.1.6
by Brian Aker
Adding in the engine interface. The filesystem catalog will now handle |
55 |
|
1960.1.5
by Brian Aker
Merging in the first pass through the catalog work. |
56 |
Catalog(const std::string &name_arg); |
2073.1.2
by Brian Aker
Basic DDL for catalog. |
57 |
Catalog(const drizzled::lex_string_t &name_arg); |
1960.1.5
by Brian Aker
Merging in the first pass through the catalog work. |
58 |
|
59 |
virtual ~Catalog() |
|
60 |
{ } |
|
61 |
||
62 |
const std::string &getPath() const; |
|
63 |
||
64 |
const std::string &getName() const |
|
65 |
{
|
|
2039.6.6
by Brian Aker
Update so that CATALOG is correctly being displayed. |
66 |
return _name; |
67 |
}
|
|
68 |
||
69 |
const std::string &name() const |
|
70 |
{
|
|
71 |
return _name; |
|
1960.1.5
by Brian Aker
Merging in the first pass through the catalog work. |
72 |
}
|
73 |
||
2126.2.1
by Brian Aker
Merge in changes for catalogs usage of constants for identifier. |
74 |
virtual void getSQLPath(std::string &sql_path) const; |
75 |
||
1960.1.5
by Brian Aker
Merging in the first pass through the catalog work. |
76 |
bool isValid() const; |
77 |
bool compare(const std::string &arg) const; |
|
78 |
||
79 |
size_t getHashValue() const |
|
80 |
{
|
|
81 |
return hash_value; |
|
82 |
}
|
|
83 |
||
84 |
friend bool operator<(const Catalog &left, const Catalog &right) |
|
85 |
{
|
|
86 |
return boost::algorithm::to_upper_copy(left.getName()) < boost::algorithm::to_upper_copy(right.getName()); |
|
87 |
}
|
|
88 |
||
1960.1.8
by Brian Aker
Big hunk of burning create/drop work. |
89 |
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. |
90 |
{
|
91 |
output << "Catalog:("; |
|
92 |
output << identifier.getName(); |
|
93 |
output << ", "; |
|
94 |
output << identifier.getPath(); |
|
95 |
output << ")"; |
|
96 |
||
97 |
return output; // for multiple << operators. |
|
98 |
}
|
|
99 |
||
100 |
friend bool operator==(const Catalog &left, |
|
101 |
const Catalog &right) |
|
102 |
{
|
|
103 |
return boost::iequals(left.getName(), right.getName()); |
|
104 |
}
|
|
105 |
||
106 |
private: |
|
107 |
size_t hash_value; |
|
108 |
||
109 |
};
|
|
110 |
||
111 |
std::size_t hash_value(Catalog const& b); |
|
112 |
||
113 |
} /* namespace identifier */ |
|
114 |
} /* namespace drizzled */ |
|
115 |
||
116 |
#endif /* DRIZZLED_IDENTIFIER_CATALOG_H */ |