]> git.proxmox.com Git - ceph.git/blob - ceph/src/os/filestore/SequencerPosition.h
update sources to v12.2.3
[ceph.git] / ceph / src / os / filestore / SequencerPosition.h
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 */
17 struct 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
24 void encode(bufferlist& bl) const {
25 ENCODE_START(1, 1, bl);
26 ::encode(seq, bl);
27 ::encode(trans, bl);
28 ::encode(op, bl);
29 ENCODE_FINISH(bl);
30 }
31 void decode(bufferlist::iterator& p) {
32 DECODE_START(1, p);
33 ::decode(seq, p);
34 ::decode(trans, p);
35 ::decode(op, p);
36 DECODE_FINISH(p);
37 }
38 void dump(Formatter *f) const {
39 f->dump_unsigned("seq", seq);
40 f->dump_unsigned("trans", trans);
41 f->dump_unsigned("op", op);
42 }
43 static void generate_test_instances(list<SequencerPosition*>& o) {
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 };
49 WRITE_CLASS_ENCODER(SequencerPosition)
50
51 inline ostream& operator<<(ostream& out, const SequencerPosition& t) {
52 return out << t.seq << "." << t.trans << "." << t.op;
53 }
54
55 WRITE_EQ_OPERATORS_3(SequencerPosition, seq, trans, op)
56 WRITE_CMP_OPERATORS_3(SequencerPosition, seq, trans, op)
57
58
59 #endif