~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/identifier/catalog.h

Merge in trunk to catalogs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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>
 
25
#include "drizzled/definitions.h"
 
26
#include <string.h>
 
27
 
 
28
#include <assert.h>
 
29
 
 
30
#include <ostream>
 
31
#include <vector>
 
32
#include <algorithm>
 
33
#include <functional>
 
34
#include <iostream>
 
35
 
 
36
#include <boost/algorithm/string.hpp>
 
37
 
 
38
namespace drizzled {
 
39
 
 
40
namespace identifier {
 
41
 
 
42
class Catalog : public Identifier
 
43
{
 
44
  std::string _name;
 
45
  std::string path;
 
46
 
 
47
 
 
48
public:
 
49
  typedef std::vector<Catalog> vector;
 
50
  typedef const Catalog& const_reference;
 
51
  typedef Catalog& reference;
 
52
 
 
53
  Catalog(const std::string &name_arg);
 
54
 
 
55
  virtual ~Catalog()
 
56
  { }
 
57
 
 
58
  const std::string &getPath() const;
 
59
 
 
60
  const std::string &getName() const
 
61
  {
 
62
    return _name;
 
63
  }
 
64
 
 
65
  const std::string &name() const
 
66
  {
 
67
    return _name;
 
68
  }
 
69
 
 
70
  bool isValid() const;
 
71
  bool compare(const std::string &arg) const;
 
72
 
 
73
  size_t getHashValue() const
 
74
  {
 
75
    return hash_value;
 
76
  }
 
77
 
 
78
  friend bool operator<(const Catalog &left, const Catalog &right)
 
79
  {
 
80
    return  boost::algorithm::to_upper_copy(left.getName()) < boost::algorithm::to_upper_copy(right.getName());
 
81
  }
 
82
 
 
83
  friend std::ostream& operator<<(std::ostream& output, const Catalog &identifier)
 
84
  {
 
85
    output << "Catalog:(";
 
86
    output <<  identifier.getName();
 
87
    output << ", ";
 
88
    output << identifier.getPath();
 
89
    output << ")";
 
90
 
 
91
    return output;  // for multiple << operators.
 
92
  }
 
93
 
 
94
  friend bool operator==(const Catalog &left,
 
95
                         const Catalog &right)
 
96
  {
 
97
    return boost::iequals(left.getName(), right.getName());
 
98
  }
 
99
 
 
100
private:
 
101
  size_t hash_value;
 
102
 
 
103
};
 
104
 
 
105
std::size_t hash_value(Catalog const& b);
 
106
 
 
107
} /* namespace identifier */
 
108
} /* namespace drizzled */
 
109
 
 
110
#endif /* DRIZZLED_IDENTIFIER_CATALOG_H */