0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BlockHeaderCommitLog.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 
28 #ifndef HYPERTABLE_BLOCKHEADERCOMMITLOG_H
29 #define HYPERTABLE_BLOCKHEADERCOMMITLOG_H
30 
32 
33 #include <utility>
34 
35 namespace Hypertable {
36 
37  using namespace std::rel_ops;
38 
48 
49  public:
50 
51  static const uint16_t LatestVersion = 1;
52 
58  BlockHeaderCommitLog(uint16_t version=LatestVersion);
59 
67  BlockHeaderCommitLog(const char *magic, int64_t revision,
68  uint64_t cluster_id);
69 
77  void set_revision(int64_t revision) { m_revision = revision; }
78 
82  int64_t get_revision() { return m_revision; }
83 
91  void set_cluster_id(uint64_t cluster_id) { m_cluster_id = cluster_id; }
92 
96  uint64_t get_cluster_id() { return m_cluster_id; }
97 
102  virtual size_t encoded_length();
103 
127  virtual void encode(uint8_t **bufp);
128 
136  virtual void decode(const uint8_t **bufp, size_t *remainp);
137 
144  bool equals(const BlockHeaderCommitLog &other) const;
145 
146  private:
148  int64_t m_revision;
149 
151  uint64_t m_cluster_id;
152 
154  uint16_t m_version;
155  };
156 
163  inline bool operator==(const BlockHeaderCommitLog &lhs,
164  const BlockHeaderCommitLog &rhs) {
165  return lhs.equals(rhs);
166  }
167 
170 }
171 
172 #endif // HYPERTABLE_BLOCKHEADERCOMMITLOG_H
uint64_t get_cluster_id()
Gets the cluster ID field.
int64_t m_revision
Revision number of the most recent cell found in the block.
Declarations for BlockHeader.
void set_revision(int64_t revision)
Sets the revision number field.
void set_cluster_id(uint64_t cluster_id)
Sets the cluster ID field.
bool operator==(const directory_entry< _Key, _Tp > &lhs, const directory_entry< _Key, _Tp > &rhs)
Definition: directory.h:112
uint64_t m_cluster_id
Originating cluster ID.
Hypertable definitions
bool equals(const BlockHeaderCommitLog &other) const
Equality test.
Base class for block headers.
Definition: BlockHeader.h:48
int64_t get_revision()
Gets the revision number field.
uint16_t m_version
Serialization format version number