~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/identifier/catalog.h

Merge in Catalogs to current trunk.

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