0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TableParts.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3 of the
9  * License, or any later version.
10  *
11  * Hypertable 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 Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
26 
27 #ifndef HYPERTABLE_TABLEPARTS_H
28 #define HYPERTABLE_TABLEPARTS_H
29 
30 #include <Common/Serializable.h>
31 
32 #include <string>
33 
34 namespace Hypertable {
35 
38 
47  class TableParts : public Serializable {
48 
49  public:
50 
52  enum {
54  PRIMARY = 0x01,
56  VALUE_INDEX = 0x02,
60  ALL = 0x07
61  };
62 
65  TableParts(int8_t parts=0) : m_parts(parts) { }
66 
70  inline bool primary() const { return m_parts & PRIMARY; }
71 
75  inline bool value_index() const { return m_parts & VALUE_INDEX; }
76 
80  inline bool qualifier_index() const { return m_parts & QUALIFIER_INDEX; }
81 
84  const std::string to_string() const;
85 
89  operator bool () const { return m_parts != 0; }
90 
92  void clear() { m_parts = 0; }
93 
94  private:
95 
96  uint8_t encoding_version() const override;
97 
98  size_t encoded_length_internal() const override;
99 
100  void encode_internal(uint8_t **bufp) const override;
101 
102  void decode_internal(uint8_t version, const uint8_t **bufp,
103  size_t *remainp) override;
104 
106  int8_t m_parts {};
107  };
108 
110 }
111 
112 
113 #endif // HYPERTABLE_TABLEPARTS_H
size_t encoded_length_internal() const override
Returns internal serialized length.
Definition: TableParts.cc:40
int8_t m_parts
Bitmask representing table parts.
Definition: TableParts.h:106
Represents a set of table parts (sub-tables).
Definition: TableParts.h:47
void decode_internal(uint8_t version, const uint8_t **bufp, size_t *remainp) override
Reads serialized representation of object from a buffer.
Definition: TableParts.cc:57
void clear()
Clears all parts.
Definition: TableParts.h:92
Declarations for Serializable.
bool primary() const
Test if primary table is included in set.
Definition: TableParts.h:70
uint8_t encoding_version() const override
Returns encoding version.
Definition: TableParts.cc:36
Hypertable definitions
Mixin class that provides a standard serialization interface.
Definition: Serializable.h:65
void encode_internal(uint8_t **bufp) const override
Serialized format is as follows:
Definition: TableParts.cc:53
bool value_index() const
Test if value index is included in set.
Definition: TableParts.h:75
const std::string to_string() const
Returns human readable string describing table parts.
Definition: TableParts.cc:63
TableParts(int8_t parts=0)
Constructor.
Definition: TableParts.h:65
bool qualifier_index() const
Test if qualifier index is included in set.
Definition: TableParts.h:80