]>
Commit | Line | Data |
---|---|---|
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_CLS_TIMEINDEX_OPS_H | |
5 | #define CEPH_CLS_TIMEINDEX_OPS_H | |
6 | ||
7c673cae FG |
7 | #include "cls_timeindex_types.h" |
8 | ||
9 | struct cls_timeindex_add_op { | |
f67539c2 | 10 | std::list<cls_timeindex_entry> entries; |
7c673cae FG |
11 | |
12 | cls_timeindex_add_op() {} | |
13 | ||
f67539c2 | 14 | void encode(ceph::buffer::list& bl) const { |
7c673cae | 15 | ENCODE_START(1, 1, bl); |
11fdf7f2 | 16 | encode(entries, bl); |
7c673cae FG |
17 | ENCODE_FINISH(bl); |
18 | } | |
19 | ||
f67539c2 | 20 | void decode(ceph::buffer::list::const_iterator& bl) { |
7c673cae | 21 | DECODE_START(1, bl); |
11fdf7f2 | 22 | decode(entries, bl); |
7c673cae FG |
23 | DECODE_FINISH(bl); |
24 | } | |
25 | }; | |
26 | WRITE_CLASS_ENCODER(cls_timeindex_add_op) | |
27 | ||
28 | struct cls_timeindex_list_op { | |
29 | utime_t from_time; | |
f67539c2 | 30 | std::string marker; /* if not empty, overrides from_time */ |
7c673cae FG |
31 | utime_t to_time; /* not inclusive */ |
32 | int max_entries; /* upperbound to returned num of entries | |
33 | might return less than that and still be truncated */ | |
34 | ||
35 | cls_timeindex_list_op() : max_entries(0) {} | |
36 | ||
f67539c2 | 37 | void encode(ceph::buffer::list& bl) const { |
7c673cae | 38 | ENCODE_START(1, 1, bl); |
11fdf7f2 TL |
39 | encode(from_time, bl); |
40 | encode(marker, bl); | |
41 | encode(to_time, bl); | |
42 | encode(max_entries, bl); | |
7c673cae FG |
43 | ENCODE_FINISH(bl); |
44 | } | |
45 | ||
f67539c2 | 46 | void decode(ceph::buffer::list::const_iterator& bl) { |
7c673cae | 47 | DECODE_START(1, bl); |
11fdf7f2 TL |
48 | decode(from_time, bl); |
49 | decode(marker, bl); | |
50 | decode(to_time, bl); | |
51 | decode(max_entries, bl); | |
7c673cae FG |
52 | DECODE_FINISH(bl); |
53 | } | |
54 | }; | |
55 | WRITE_CLASS_ENCODER(cls_timeindex_list_op) | |
56 | ||
57 | struct cls_timeindex_list_ret { | |
f67539c2 TL |
58 | std::list<cls_timeindex_entry> entries; |
59 | std::string marker; | |
7c673cae FG |
60 | bool truncated; |
61 | ||
62 | cls_timeindex_list_ret() : truncated(false) {} | |
63 | ||
f67539c2 | 64 | void encode(ceph::buffer::list& bl) const { |
7c673cae | 65 | ENCODE_START(1, 1, bl); |
11fdf7f2 TL |
66 | encode(entries, bl); |
67 | encode(marker, bl); | |
68 | encode(truncated, bl); | |
7c673cae FG |
69 | ENCODE_FINISH(bl); |
70 | } | |
71 | ||
f67539c2 | 72 | void decode(ceph::buffer::list::const_iterator& bl) { |
7c673cae | 73 | DECODE_START(1, bl); |
11fdf7f2 TL |
74 | decode(entries, bl); |
75 | decode(marker, bl); | |
76 | decode(truncated, bl); | |
7c673cae FG |
77 | DECODE_FINISH(bl); |
78 | } | |
79 | }; | |
80 | WRITE_CLASS_ENCODER(cls_timeindex_list_ret) | |
81 | ||
82 | ||
83 | /* | |
84 | * operation will return 0 when successfully removed but not done. Will return | |
85 | * -ENODATA when done, so caller needs to repeat sending request until that. | |
86 | */ | |
87 | struct cls_timeindex_trim_op { | |
88 | utime_t from_time; | |
89 | utime_t to_time; /* inclusive */ | |
f67539c2 TL |
90 | std::string from_marker; |
91 | std::string to_marker; | |
7c673cae FG |
92 | |
93 | cls_timeindex_trim_op() {} | |
94 | ||
f67539c2 | 95 | void encode(ceph::buffer::list& bl) const { |
7c673cae | 96 | ENCODE_START(1, 1, bl); |
11fdf7f2 TL |
97 | encode(from_time, bl); |
98 | encode(to_time, bl); | |
99 | encode(from_marker, bl); | |
100 | encode(to_marker, bl); | |
7c673cae FG |
101 | ENCODE_FINISH(bl); |
102 | } | |
103 | ||
f67539c2 | 104 | void decode(ceph::buffer::list::const_iterator& bl) { |
7c673cae | 105 | DECODE_START(1, bl); |
11fdf7f2 TL |
106 | decode(from_time, bl); |
107 | decode(to_time, bl); | |
108 | decode(from_marker, bl); | |
109 | decode(to_marker, bl); | |
7c673cae FG |
110 | DECODE_FINISH(bl); |
111 | } | |
112 | }; | |
113 | WRITE_CLASS_ENCODER(cls_timeindex_trim_op) | |
114 | ||
115 | #endif /* CEPH_CLS_TIMEINDEX_OPS_H */ |