Groonga 3.0.9 Source Code Document
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
node.hpp
Go to the documentation of this file.
1 /* -*- c-basic-offset: 2 -*- */
2 /* Copyright(C) 2011 Brazil
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License version 2.1 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Lesser General Public License for more details.
12 
13  You should have received a copy of the GNU Lesser General Public
14  License along with this library; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef GRN_DAT_NODE_HPP_
19 #define GRN_DAT_NODE_HPP_
20 
21 // See base.hpp and check.hpp for details.
22 #include "base.hpp"
23 #include "check.hpp"
24 
25 namespace grn {
26 namespace dat {
27 
29  public:
30  Node() : base_(), check_() {}
31 
32  Base base() const {
33  return base_;
34  }
35  bool is_linker() const {
36  GRN_DAT_DEBUG_THROW_IF(is_phantom());
37  return base_.is_linker();
38  }
39  UInt32 offset() const {
40  GRN_DAT_DEBUG_THROW_IF(is_phantom());
41  return base_.offset();
42  }
43  UInt32 key_pos() const {
44  GRN_DAT_DEBUG_THROW_IF(is_phantom());
45  return base_.key_pos();
46  }
47 
48  Check check() const {
49  return check_;
50  }
51  bool is_offset() const {
52  return check_.is_offset();
53  }
55  return check_.except_is_offset();
56  }
57  bool is_phantom() const {
58  return check_.is_phantom();
59  }
60  UInt32 next() const {
61  return check_.next();
62  }
63  UInt32 prev() const {
64  return check_.prev();
65  }
66  UInt32 label() const {
67  return check_.label();
68  }
69  UInt32 child() const {
70  return check_.child();
71  }
72  UInt32 sibling() const {
73  return check_.sibling();
74  }
75 
76  void set_base(Base x) {
77  GRN_DAT_DEBUG_THROW_IF(is_phantom());
78  base_ = x;
79  }
80  void set_offset(UInt32 x) {
81  GRN_DAT_DEBUG_THROW_IF(is_phantom());
82  base_.set_offset(x);
83  }
84  void set_key_pos(UInt32 x) {
85  GRN_DAT_DEBUG_THROW_IF(is_phantom());
86  base_.set_key_pos(x);
87  }
88 
89  void set_check(Check x) {
90  check_ = x;
91  }
92  void set_is_offset(bool x) {
93  check_.set_is_offset(x);
94  }
96  check_.set_except_is_offset(x);
97  }
98  void set_is_phantom(bool x) {
99  GRN_DAT_DEBUG_THROW_IF(base_.offset() != INVALID_OFFSET);
100  check_.set_is_phantom(x);
101  }
102  void set_next(UInt32 x) {
103  GRN_DAT_DEBUG_THROW_IF(base_.offset() != INVALID_OFFSET);
104  check_.set_next(x);
105  }
106  void set_prev(UInt32 x) {
107  GRN_DAT_DEBUG_THROW_IF(base_.offset() != INVALID_OFFSET);
108  check_.set_prev(x);
109  }
110  void set_label(UInt32 x) {
112  check_.set_label(x);
113  }
114  void set_child(UInt32 x) {
115  check_.set_child(x);
116  }
117  void set_sibling(UInt32 x) {
118  check_.set_sibling(x);
119  }
120 
121  private:
122  Base base_;
123  Check check_;
124 };
125 
126 } // namespace dat
127 } // namespace grn
128 
129 #endif // GRN_DAT_NODE_HPP_