]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
use WRITE_CLASS_ENCOER macro when possible
authorSage Weil <sage@newdream.net>
Wed, 19 Oct 2011 04:26:46 +0000 (21:26 -0700)
committerSage Weil <sage@newdream.net>
Wed, 19 Oct 2011 05:25:55 +0000 (22:25 -0700)
src/include/types.h
src/mds/mdstypes.h
src/msg/msg_types.h
src/radosacl.cc

index 3092f378112c3fcd941e11a79bd0f701355815a4..c87ac5fe4d71c5c7389f3d19d1f25b0b15bdbbc6 100644 (file)
@@ -296,10 +296,15 @@ struct inodeno_t {
   inodeno_t(_inodeno_t v) : val(v) {}
   inodeno_t operator+=(inodeno_t o) { val += o.val; return *this; }
   operator _inodeno_t() const { return val; }
-} __attribute__ ((__may_alias__));
 
-inline void encode(inodeno_t i, bufferlist &bl) { encode(i.val, bl); }
-inline void decode(inodeno_t &i, bufferlist::iterator &p) { decode(i.val, p); }
+  void encode(bufferlist& bl) const {
+    ::encode(val, bl);
+  }
+  void decode(bufferlist::iterator& p) {
+    ::decode(val, p);
+  }
+} __attribute__ ((__may_alias__));
+WRITE_CLASS_ENCODER(inodeno_t)
 
 inline ostream& operator<<(ostream& out, inodeno_t ino) {
   return out << hex << ino.val << dec;
index 32f597277a175d91285f34357d0171c55329f710..eeedf6e8b4f3e3cb1c86c75cbb6f50b2be9d6448 100644 (file)
@@ -755,18 +755,16 @@ struct metareqid_t {
   uint64_t tid;
   metareqid_t() : tid(0) {}
   metareqid_t(entity_name_t n, tid_t t) : name(n), tid(t) {}
+  void encode(bufferlist& bl) const {
+    ::encode(name, bl);
+    ::encode(tid, bl);
+  }
+  void decode(bufferlist::iterator &p) {
+    ::decode(name, p);
+    ::decode(tid, p);
+  }
 };
-
-static inline void encode(const metareqid_t &r, bufferlist &bl)
-{
-  ::encode(r.name, bl);
-  ::encode(r.tid, bl);
-}
-static inline void decode( metareqid_t &r, bufferlist::iterator &p)
-{
-  ::decode(r.name, p);
-  ::decode(r.tid, p);
-}
+WRITE_CLASS_ENCODER(metareqid_t)
 
 inline ostream& operator<<(ostream& out, const metareqid_t& r) {
   return out << r.name << ":" << r.tid;
@@ -887,16 +885,17 @@ struct dirfrag_t {
 
   dirfrag_t() : ino(0) { }
   dirfrag_t(inodeno_t i, frag_t f) : ino(i), frag(f) { }
-};
 
-inline void encode(const dirfrag_t &f, bufferlist& bl) { 
-  encode(f.ino, bl);
-  encode(f.frag, bl);
-}
-inline void decode(dirfrag_t &f, bufferlist::iterator& p) { 
-  decode(f.ino, p);
-  decode(f.frag, p);
-}
+  void encode(bufferlist& bl) const {
+    ::encode(ino, bl);
+    ::encode(frag, bl);
+  }
+  void decode(bufferlist::iterator& bl) {
+    ::decode(ino, bl);
+    ::decode(frag, bl);
+  }
+};
+WRITE_CLASS_ENCODER(dirfrag_t)
 
 
 inline ostream& operator<<(ostream& out, const dirfrag_t df) {
index d520e3554f7286bc0cfb5ff95abeef4577b8097e..ad58772fe2c1b33222a0e0ee4327f4d4f2797a07 100644 (file)
@@ -93,17 +93,16 @@ public:
     return true;
   }
 
+  void encode(bufferlist& bl) const {
+    ::encode(_type, bl);
+    ::encode(_num, bl);
+  }
+  void decode(bufferlist::iterator& bl) {
+    ::decode(_type, bl);
+    ::decode(_num, bl);
+  }
 };
-
-inline void encode(const entity_name_t &a, bufferlist& bl) {
-  encode(a._type, bl);
-  encode(a._num, bl);
-}
-
-inline void decode(entity_name_t &a, bufferlist::iterator& p) {
-  decode(a._type, p);
-  decode(a._num, p);
-}
+WRITE_CLASS_ENCODER(entity_name_t)
 
 inline bool operator== (const entity_name_t& l, const entity_name_t& r) { 
   return (l.type() == r.type()) && (l.num() == r.num()); }
@@ -320,16 +319,18 @@ struct entity_inst_t {
     ceph_entity_inst i = {name, addr};
     return i;
   }
+
+  void encode(bufferlist& bl) const {
+    ::encode(name, bl);
+    ::encode(addr, bl);
+  }
+  void decode(bufferlist::iterator& bl) {
+    ::decode(name, bl);
+    ::decode(addr, bl);
+  }
 };
+WRITE_CLASS_ENCODER(entity_inst_t)
 
-inline void encode(const entity_inst_t &i, bufferlist& bl) {
-  encode(i.name, bl);
-  encode(i.addr, bl);
-}
-inline void decode(entity_inst_t &i, bufferlist::iterator& p) {
-  decode(i.name, p);
-  decode(i.addr, p);
-}
 
 inline bool operator==(const entity_inst_t& a, const entity_inst_t& b) { 
   return a.name == b.name && a.addr == b.addr;
index 521634f4efa136c67c8e8865d65d1e3166274a1f..d2f7ca5c488fced174e7b49a2d017e44067061cc 100644 (file)
@@ -38,19 +38,18 @@ void buf_to_hex(const unsigned char *buf, int len, char *str)
 
 struct ACLID {
   char id[ID_SIZE + 1];
+
+  void encode(bufferlist& bl) const {
+    bl.append((const char *)id, ID_SIZE);
+  }
+  void decode(bufferlist::iterator& iter) {
+    iter.copy(ID_SIZE, (char *)id);
+  }
 };
+WRITE_CLASS_ENCODER(ACLID)
 
 typedef __u32 ACLFlags;
 
-void encode(const ACLID& id, bufferlist& bl)
-{
-  bl.append((const char *)id.id, ID_SIZE);
-}
-
-void decode(ACLID& id, bufferlist::iterator& iter)
-{
-  iter.copy(ID_SIZE, (char *)id.id);
-}
 
 inline bool operator<(const ACLID& l, const ACLID& r)
 {