]> git.proxmox.com Git - ceph.git/blame - ceph/src/os/filestore/SequencerPosition.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / os / filestore / SequencerPosition.h
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3
4#ifndef __CEPH_OS_SEQUENCERPOSITION_H
5#define __CEPH_OS_SEQUENCERPOSITION_H
6
7#include "include/types.h"
8#include "include/cmp.h"
9#include "include/encoding.h"
10#include "common/Formatter.h"
11
12#include <ostream>
13
14/**
15 * transaction and op offset
16 */
17struct SequencerPosition {
18 uint64_t seq; ///< seq
19 uint32_t trans; ///< transaction in that seq (0-based)
20 uint32_t op; ///< op in that transaction (0-based)
21
22 SequencerPosition(uint64_t s=0, int32_t t=0, int32_t o=0) : seq(s), trans(t), op(o) {}
23
f67539c2 24 void encode(ceph::buffer::list& bl) const {
7c673cae 25 ENCODE_START(1, 1, bl);
11fdf7f2
TL
26 encode(seq, bl);
27 encode(trans, bl);
28 encode(op, bl);
7c673cae
FG
29 ENCODE_FINISH(bl);
30 }
f67539c2 31 void decode(ceph::buffer::list::const_iterator& p) {
7c673cae 32 DECODE_START(1, p);
11fdf7f2
TL
33 decode(seq, p);
34 decode(trans, p);
35 decode(op, p);
7c673cae
FG
36 DECODE_FINISH(p);
37 }
f67539c2 38 void dump(ceph::Formatter *f) const {
7c673cae
FG
39 f->dump_unsigned("seq", seq);
40 f->dump_unsigned("trans", trans);
41 f->dump_unsigned("op", op);
42 }
f67539c2 43 static void generate_test_instances(std::list<SequencerPosition*>& o) {
7c673cae
FG
44 o.push_back(new SequencerPosition);
45 o.push_back(new SequencerPosition(1, 2, 3));
46 o.push_back(new SequencerPosition(4, 5, 6));
47 }
48};
49WRITE_CLASS_ENCODER(SequencerPosition)
50
f67539c2 51inline std::ostream& operator<<(std::ostream& out, const SequencerPosition& t) {
7c673cae
FG
52 return out << t.seq << "." << t.trans << "." << t.op;
53}
54
55WRITE_EQ_OPERATORS_3(SequencerPosition, seq, trans, op)
56WRITE_CMP_OPERATORS_3(SequencerPosition, seq, trans, op)
57
58
59#endif