]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
include/frag: add encode/decode functions for fragset_t
authorYan, Zheng <zyan@redhat.com>
Sat, 23 May 2020 15:09:10 +0000 (23:09 +0800)
committerYan, Zheng <zyan@redhat.com>
Mon, 16 Nov 2020 01:02:17 +0000 (09:02 +0800)
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/include/frag.h

index 699a0698f5ca691c7e9f919d31c1ff597743dec0..a4e20bacab2246e5c194f6b38773af0b32f80592 100644 (file)
@@ -169,6 +169,7 @@ public:
 private:
   _frag_t _enc = 0;
 };
+WRITE_CLASS_ENCODER(frag_t)
 
 inline std::ostream& operator<<(std::ostream& out, const frag_t& hb)
 {
@@ -182,8 +183,6 @@ inline std::ostream& operator<<(std::ostream& out, const frag_t& hb)
   return out << '*';
 }
 
-inline void encode(const frag_t &f, ceph::buffer::list& bl) { f.encode(bl); }
-inline void decode(frag_t &f, ceph::buffer::list::const_iterator& p) { f.decode(p); }
 
 using frag_vec_t = boost::container::small_vector<frag_t, 4>;
 
@@ -558,8 +557,8 @@ class fragset_t {
 
 public:
   const std::set<frag_t> &get() const { return _set; }
-  std::set<frag_t>::iterator begin() { return _set.begin(); }
-  std::set<frag_t>::iterator end() { return _set.end(); }
+  std::set<frag_t>::const_iterator begin() const { return _set.begin(); }
+  std::set<frag_t>::const_iterator end() const { return _set.end(); }
 
   bool empty() const { return _set.empty(); }
 
@@ -593,7 +592,16 @@ public:
       }
     }
   }
+
+  void encode(ceph::buffer::list& bl) const {
+    ceph::encode(_set, bl);
+  }
+  void decode(ceph::buffer::list::const_iterator& p) {
+    ceph::decode(_set, p);
+  }
 };
+WRITE_CLASS_ENCODER(fragset_t)
+
 
 inline std::ostream& operator<<(std::ostream& out, const fragset_t& fs) 
 {