summaryrefslogtreecommitdiffstats
path: root/src/journal/Entry.h
blob: 52d9e67b45a681113c0018566039808bf1e4cc00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#ifndef CEPH_JOURNAL_ENTRY_H
#define CEPH_JOURNAL_ENTRY_H

#include "include/int_types.h"
#include "include/buffer.h"
#include "include/encoding.h"
#include <iosfwd>
#include <string>

namespace ceph {
class Formatter;
}

namespace journal {

class Entry {
public:
  Entry() : m_tag_tid(0), m_entry_tid() {}
  Entry(uint64_t tag_tid, uint64_t entry_tid, const bufferlist &data)
    : m_tag_tid(tag_tid), m_entry_tid(entry_tid), m_data(data)
  {
  }

  static uint32_t get_fixed_size();

  inline uint64_t get_tag_tid() const {
    return m_tag_tid;
  }
  inline uint64_t get_entry_tid() const {
    return m_entry_tid;
  }
  inline const bufferlist &get_data() const {
    return m_data;
  }

  void encode(bufferlist &bl) const;
  void decode(bufferlist::const_iterator &iter);
  void dump(ceph::Formatter *f) const;

  bool operator==(const Entry& rhs) const;

  static bool is_readable(bufferlist::const_iterator iter, uint32_t *bytes_needed);
  static void generate_test_instances(std::list<Entry *> &o);

private:
  static const uint64_t preamble = 0x3141592653589793;

  uint64_t m_tag_tid;
  uint64_t m_entry_tid;
  bufferlist m_data;
};

std::ostream &operator<<(std::ostream &os, const Entry &entry);
WRITE_CLASS_ENCODER(journal::Entry)

} // namespace journal


#endif // CEPH_JOURNAL_ENTRY_H