1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef __CEPH_OS_SEQUENCERPOSITION_H
5 #define __CEPH_OS_SEQUENCERPOSITION_H
7 #include "include/types.h"
8 #include "include/cmp.h"
9 #include "include/encoding.h"
10 #include "common/Formatter.h"
15 * transaction and op offset
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)
22 SequencerPosition(uint64_t s=0, int32_t t=0, int32_t o=0) : seq(s), trans(t), op(o) {}
24 void encode(bufferlist& bl) const {
25 ENCODE_START(1, 1, bl);
31 void decode(bufferlist::iterator& p) {
38 void dump(Formatter *f) const {
39 f->dump_unsigned("seq", seq);
40 f->dump_unsigned("trans", trans);
41 f->dump_unsigned("op", op);
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));
49 WRITE_CLASS_ENCODER(SequencerPosition)
51 inline ostream& operator<<(ostream& out, const SequencerPosition& t) {
52 return out << t.seq << "." << t.trans << "." << t.op;
55 WRITE_EQ_OPERATORS_3(SequencerPosition, seq, trans, op)
56 WRITE_CMP_OPERATORS_3(SequencerPosition, seq, trans, op)