0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MetaLogEntityHeader.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_Lib_MetaLogEntityHeader_h
29 #define Hypertable_Lib_MetaLogEntityHeader_h
30 
31 #include <iostream>
32 
33 #include <mutex>
34 
35 namespace Hypertable {
36 
37  namespace MetaLog {
38 
54  class EntityHeader {
55 
56  public:
57 
59  enum {
60  FLAG_REMOVE = 0x00000001,
61  LENGTH = 32
62  };
63 
67  EntityHeader();
68 
75  EntityHeader(int32_t type_);
76 
84  EntityHeader(const EntityHeader &other);
85 
94  bool operator<(const EntityHeader &other) const;
95 
109  void encode(uint8_t **bufp) const;
110 
118  void decode(const uint8_t **bufp, size_t *remainp);
119 
128  void display(std::ostream &os);
129 
131  int32_t type {};
132 
134  int32_t checksum {};
135 
137  int64_t id {};
138 
140  int64_t timestamp {};
141 
143  int32_t flags {};
144 
146  int32_t length {};
147 
149  static bool display_timestamp;
150 
151  private:
152 
154  static int64_t ms_next_id;
155 
158  };
160  }
161 }
162 
163 #endif // Hypertable_Lib_MetaLogEntityHeader_h
static std::mutex ms_mutex
Mutex for serializing access to ms_next_id
static std::mutex mutex
Definition: Logger.cc:43
int32_t flags
Flags (either FLAG_REMOVE or 0)
int32_t length
Length of entity header plus serialized state.
void encode(uint8_t **bufp) const
Encodes (serializes) header to a buffer.
bool operator<(const EntityHeader &other) const
Less than operator for comparing this header with another.
int64_t timestamp
Creation timestmp of entity header.
Static length of entity header.
static int64_t ms_next_id
Global counter for generating unique entity IDs
int32_t type
Entity type defined within the context of a Definition
void display(std::ostream &os)
Display human-readable representation of header to an ostream.
Hypertable definitions
static bool display_timestamp
Controls whether or not timestamp is printed by display()
int32_t checksum
Checksum of serialized entity state
void decode(const uint8_t **bufp, size_t *remainp)
Decodes serialzed header from buffer.