]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
{common, rgw}: Build ceph-osd without namespace pollution in headers
authorAdam C. Emerson <aemerson@redhat.com>
Thu, 2 Apr 2020 23:31:21 +0000 (19:31 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Mon, 6 Apr 2020 15:15:06 +0000 (11:15 -0400)
This is part of a series of commits to clean up using namespace at top
level in headers.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/common/AsyncReserver.h
src/common/map_cacher.hpp
src/rgw/rgw_basic_types.h

index 8632a5f0857b41ebe35d9fe5fe8e52b04ab12168..bbc8b72a1f7d8e97787cc19a27d6c8ac0839c82e 100644 (file)
@@ -43,21 +43,21 @@ class AsyncReserver {
     Reservation() {}
     Reservation(T i, unsigned pr, Context *g, Context *p = 0)
       : item(i), prio(pr), grant(g), preempt(p) {}
-    void dump(Formatter *f) const {
+    void dump(ceph::Formatter *f) const {
       f->dump_stream("item") << item;
       f->dump_unsigned("prio", prio);
       f->dump_bool("can_preempt", !!preempt);
     }
-    friend ostream& operator<<(ostream& out, const Reservation& r) {
+    friend std::ostream& operator<<(std::ostream& out, const Reservation& r) {
       return out << r.item << "(prio " << r.prio << " grant " << r.grant
                 << " preempt " << r.preempt << ")";
     }
   };
 
-  map<unsigned, list<Reservation>> queues;
-  map<T, pair<unsigned, typename list<Reservation>::iterator>> queue_pointers;
-  map<T,Reservation> in_progress;
-  set<pair<unsigned,T>> preempt_by_prio;  ///< in_progress that can be preempted
+  std::map<unsigned, std::list<Reservation>> queues;
+  std::map<T, std::pair<unsigned, typename std::list<Reservation>::iterator>> queue_pointers;
+  std::map<T,Reservation> in_progress;
+  std::set<std::pair<unsigned,T>> preempt_by_prio;  ///< in_progress that can be preempted
 
   void preempt_one() {
     ceph_assert(!preempt_by_prio.empty());
@@ -73,7 +73,7 @@ class AsyncReserver {
 
   void do_queues() {
     rdout(20) << __func__ << ":\n";
-    JSONFormatter jf(true);
+    ceph::JSONFormatter jf(true);
     jf.open_object_section("queue");
     _dump(&jf);
     jf.close_section();
@@ -115,7 +115,7 @@ class AsyncReserver {
       p.grant = nullptr;
       in_progress[p.item] = p;
       if (p.preempt) {
-       preempt_by_prio.insert(make_pair(p.prio, p.item));
+       preempt_by_prio.insert(std::make_pair(p.prio, p.item));
       }
     }
   }
@@ -178,8 +178,8 @@ public:
           !in_progress.count(item));
       r.prio = newprio;
       queues[newprio].push_back(r);
-      queue_pointers.insert(make_pair(item,
-                                   make_pair(newprio,--(queues[newprio]).end())));
+      queue_pointers.insert(std::make_pair(item,
+                                   std::make_pair(newprio,--(queues[newprio]).end())));
     } else {
       auto p = in_progress.find(item);
       if (p != in_progress.end()) {
@@ -200,9 +200,9 @@ public:
                        << " lowered priority let do_queues() preempt it" << dendl;
             }
           }
-         preempt_by_prio.erase(make_pair(p->second.prio, p->second.item));
+         preempt_by_prio.erase(std::make_pair(p->second.prio, p->second.item));
           p->second.prio = newprio;
-         preempt_by_prio.insert(make_pair(p->second.prio, p->second.item));
+         preempt_by_prio.insert(std::make_pair(p->second.prio, p->second.item));
        } else {
           p->second.prio = newprio;
         }
@@ -214,11 +214,11 @@ public:
     return;
   }
 
-  void dump(Formatter *f) {
+  void dump(ceph::Formatter *f) {
     std::lock_guard l(lock);
     _dump(f);
   }
-  void _dump(Formatter *f) {
+  void _dump(ceph::Formatter *f) {
     f->dump_unsigned("max_allowed", max_allowed);
     f->dump_unsigned("min_priority", min_priority);
     f->open_array_section("queues");
@@ -260,8 +260,8 @@ public:
     ceph_assert(!queue_pointers.count(item) &&
           !in_progress.count(item));
     queues[prio].push_back(r);
-    queue_pointers.insert(make_pair(item,
-                                   make_pair(prio,--(queues[prio]).end())));
+    queue_pointers.insert(std::make_pair(item,
+                                   std::make_pair(prio,--(queues[prio]).end())));
     do_queues();
   }
 
@@ -294,7 +294,7 @@ public:
        rdout(10) << __func__ << " cancel " << p->second
                  << " (was in progress)" << dendl;
        if (p->second.preempt) {
-         preempt_by_prio.erase(make_pair(p->second.prio, p->second.item));
+         preempt_by_prio.erase(std::make_pair(p->second.prio, p->second.item));
          delete p->second.preempt;
        }
        in_progress.erase(p);
index e95edfb5c74555be9fb974f153dcc6b320441f51..4698eb78bba85146b760efa77723590966cde496 100644 (file)
@@ -25,9 +25,9 @@ namespace MapCacher {
 template<typename K, typename V>
 class Transaction {
 public:
-  /// Set keys according to map
+  /// Std::set keys according to map
   virtual void set_keys(
-    const std::map<K, V> &keys ///< [in] keys/values to set
+    const std::map<K, V> &keys ///< [in] keys/values to std::set
     ) = 0;
 
   /// Remove keys
@@ -57,7 +57,7 @@ public:
   /// Returns next key
   virtual int get_next(
     const K &key,       ///< [in] key after which to get next
-    pair<K, V> *next    ///< [out] first key after key
+    std::pair<K, V> *next    ///< [out] first key after key
     ) = 0; ///< @return 0 on success, -ENOENT if there is no next
 
   virtual ~StoreDriver() {}
@@ -75,19 +75,19 @@ private:
 
   SharedPtrRegistry<K, boost::optional<V> > in_progress;
   typedef typename SharedPtrRegistry<K, boost::optional<V> >::VPtr VPtr;
-  typedef ContainerContext<set<VPtr> > TransHolder;
+  typedef ContainerContext<std::set<VPtr> > TransHolder;
 
 public:
   MapCacher(StoreDriver<K, V> *driver) : driver(driver) {}
 
-  /// Fetch first key/value pair after specified key
+  /// Fetch first key/value std::pair after specified key
   int get_next(
     K key,               ///< [in] key after which to get next
-    pair<K, V> *next     ///< [out] next key
+    std::pair<K, V> *next     ///< [out] next key
     ) {
     while (true) {
-      pair<K, boost::optional<V> > cached;
-      pair<K, V> store;
+      std::pair<K, boost::optional<V> > cached;
+      std::pair<K, V> store;
       bool got_cached = in_progress.get_next(key, &cached);
 
       bool got_store = false;
@@ -123,13 +123,11 @@ public:
 
   /// Adds operation setting keys to Transaction
   void set_keys(
-    const map<K, V> &keys,  ///< [in] keys/values to set
+    const std::map<K, V> &keys,  ///< [in] keys/values to std::set
     Transaction<K, V> *t    ///< [out] transaction to use
     ) {
     std::set<VPtr> vptrs;
-    for (typename map<K, V>::const_iterator i = keys.begin();
-        i != keys.end();
-        ++i) {
+    for (auto i = keys.begin(); i != keys.end(); ++i) {
       VPtr ip = in_progress.lookup_or_create(i->first, i->second);
       *ip = i->second;
       vptrs.insert(ip);
@@ -140,13 +138,11 @@ public:
 
   /// Adds operation removing keys to Transaction
   void remove_keys(
-    const set<K> &keys,  ///< [in]
+    const std::set<K> &keys,  ///< [in]
     Transaction<K, V> *t ///< [out] transaction to use
     ) {
     std::set<VPtr> vptrs;
-    for (typename set<K>::const_iterator i = keys.begin();
-        i != keys.end();
-        ++i) {
+    for (auto i = keys.begin(); i != keys.end(); ++i) {
       boost::optional<V> empty;
       VPtr ip = in_progress.lookup_or_create(*i, empty);
       *ip = empty;
@@ -158,12 +154,12 @@ public:
 
   /// Gets keys, uses cached values for unstable keys
   int get_keys(
-    const set<K> &keys_to_get, ///< [in] set of keys to fetch
-    map<K, V> *got             ///< [out] keys gotten
+    const std::set<K> &keys_to_get, ///< [in] std::set of keys to fetch
+    std::map<K, V> *got             ///< [out] keys gotten
     ) {
-    set<K> to_get;
-    map<K, V> _got;
-    for (typename set<K>::const_iterator i = keys_to_get.begin();
+    std::set<K> to_get;
+    std::map<K, V> _got;
+    for (auto i = keys_to_get.begin();
         i != keys_to_get.end();
         ++i) {
       VPtr val = in_progress.lookup(*i);
@@ -178,9 +174,7 @@ public:
     int r = driver->get_keys(to_get, &_got);
     if (r < 0)
       return r;
-    for (typename map<K, V>::iterator i = _got.begin();
-        i != _got.end();
-        ++i) {
+    for (auto i = _got.begin(); i != _got.end(); ++i) {
       got->insert(*i);
     }
     return 0;
index 0ba03bd0e27f860ac243f0013dcfb42b6a051cf3..238fa223bbd276bb47fea762d8102931e852f263 100644 (file)
@@ -28,13 +28,13 @@ struct rgw_user {
       id(std::move(id)) {
   }
 
-  void encode(bufferlist& bl) const {
+  void encode(ceph::buffer::list& bl) const {
     ENCODE_START(1, 1, bl);
     encode(tenant, bl);
     encode(id, bl);
     ENCODE_FINISH(bl);
   }
-  void decode(bufferlist::const_iterator& bl) {
+  void decode(ceph::buffer::list::const_iterator& bl) {
     DECODE_START(1, bl);
     decode(tenant, bl);
     decode(id, bl);
@@ -58,8 +58,8 @@ struct rgw_user {
     return id.empty();
   }
 
-  string to_str() const {
-    string s;
+  std::string to_str() const {
+    std::string s;
     to_str(s);
     return s;
   }
@@ -75,7 +75,7 @@ struct rgw_user {
     }
   }
 
-  rgw_user& operator=(const string& str) {
+  rgw_user& operator=(const std::string& str) {
     from_str(str);
     return *this;
   }
@@ -87,7 +87,7 @@ struct rgw_user {
 
     return id.compare(u.id);
   }
-  int compare(const string& str) const {
+  int compare(const std::string& str) const {
     rgw_user u(str);
     return compare(u);
   }
@@ -106,8 +106,8 @@ struct rgw_user {
     }
     return (id < rhs.id);
   }
-  void dump(Formatter *f) const;
-  static void generate_test_instances(list<rgw_user*>& o);
+  void dump(ceph::Formatter *f) const;
+  static void generate_test_instances(std::list<rgw_user*>& o);
 };
 WRITE_CLASS_ENCODER(rgw_user)
 
@@ -118,15 +118,15 @@ struct rgw_pool {
   rgw_pool() = default;
   rgw_pool(const rgw_pool& _p) : name(_p.name), ns(_p.ns) {}
   rgw_pool(rgw_pool&&) = default;
-  rgw_pool(const string& _s) {
+  rgw_pool(const std::string& _s) {
     from_str(_s);
   }
-  rgw_pool(const string& _name, const string& _ns) : name(_name), ns(_ns) {}
+  rgw_pool(const std::string& _name, const std::string& _ns) : name(_name), ns(_ns) {}
 
-  string to_str() const;
-  void from_str(const string& s);
+  std::string to_str() const;
+  void from_str(const std::string& s);
 
-  void init(const string& _s) {
+  void init(const std::string& _s) {
     from_str(_s);
   }
 
@@ -142,16 +142,16 @@ struct rgw_pool {
     return ns.compare(p.ns);
   }
 
-  void encode(bufferlist& bl) const {
+  void encode(ceph::buffer::list& bl) const {
      ENCODE_START(10, 10, bl);
     encode(name, bl);
     encode(ns, bl);
     ENCODE_FINISH(bl);
   }
 
-  void decode_from_bucket(bufferlist::const_iterator& bl);
+  void decode_from_bucket(ceph::buffer::list::const_iterator& bl);
 
-  void decode(bufferlist::const_iterator& bl) {
+  void decode(ceph::buffer::list::const_iterator& bl) {
     DECODE_START_LEGACY_COMPAT_LEN(10, 3, 3, bl);
 
     decode(name, bl);
@@ -191,7 +191,7 @@ struct rgw_pool {
 };
 WRITE_CLASS_ENCODER(rgw_pool)
 
-inline ostream& operator<<(ostream& out, const rgw_pool& p) {
+inline std::ostream& operator<<(std::ostream& out, const rgw_pool& p) {
   out << p.to_str();
   return out;
 }
@@ -235,7 +235,7 @@ struct rgw_data_placement_target {
     return index_pool.compare(t.index_pool);
   };
 
-  void dump(Formatter *f) const;
+  void dump(ceph::Formatter *f) const;
   void decode_json(JSONObj *obj);
 };
 
@@ -281,7 +281,7 @@ struct rgw_bucket {
 
   void convert(cls_user_bucket *b) const;
 
-  void encode(bufferlist& bl) const {
+  void encode(ceph::buffer::list& bl) const {
      ENCODE_START(10, 10, bl);
     encode(name, bl);
     encode(marker, bl);
@@ -296,7 +296,7 @@ struct rgw_bucket {
     }
     ENCODE_FINISH(bl);
   }
-  void decode(bufferlist::const_iterator& bl) {
+  void decode(ceph::buffer::list::const_iterator& bl) {
     DECODE_START_LEGACY_COMPAT_LEN(10, 3, 3, bl);
     decode(name, bl);
     if (struct_v < 10) {
@@ -339,7 +339,7 @@ struct rgw_bucket {
     DECODE_FINISH(bl);
   }
 
-  void update_bucket_id(const string& new_bucket_id) {
+  void update_bucket_id(const std::string& new_bucket_id) {
     bucket_id = new_bucket_id;
   }
 
@@ -352,9 +352,9 @@ struct rgw_bucket {
     return explicit_placement.get_data_extra_pool();
   }
 
-  void dump(Formatter *f) const;
+  void dump(ceph::Formatter *f) const;
   void decode_json(JSONObj *obj);
-  static void generate_test_instances(list<rgw_bucket*>& o);
+  static void generate_test_instances(std::list<rgw_bucket*>& o);
 
   rgw_bucket& operator=(const rgw_bucket&) = default;
 
@@ -385,7 +385,7 @@ struct rgw_bucket {
 };
 WRITE_CLASS_ENCODER(rgw_bucket)
 
-inline ostream& operator<<(ostream& out, const rgw_bucket &b) {
+inline std::ostream& operator<<(std::ostream& out, const rgw_bucket &b) {
   out << b.tenant << ":" << b.name << "[" << b.bucket_id << "])";
   return out;
 }
@@ -416,7 +416,7 @@ struct rgw_bucket_shard {
   }
 };
 
-inline ostream& operator<<(ostream& out, const rgw_bucket_shard& bs) {
+inline std::ostream& operator<<(std::ostream& out, const rgw_bucket_shard& bs) {
   if (bs.shard_id <= 0) {
     return out << bs.bucket;
   }
@@ -426,18 +426,18 @@ inline ostream& operator<<(ostream& out, const rgw_bucket_shard& bs) {
 
 
 struct rgw_zone_id {
-  string id;
+  std::string id;
 
   rgw_zone_id() {}
-  rgw_zone_id(const string& _id) : id(_id) {}
-  rgw_zone_id(string&& _id) : id(std::move(_id)) {}
+  rgw_zone_id(const std::string& _id) : id(_id) {}
+  rgw_zone_id(std::string&& _id) : id(std::move(_id)) {}
 
-  void encode(bufferlist& bl) const {
+  void encode(ceph::buffer::list& bl) const {
     /* backward compatiblity, not using ENCODE_{START,END} macros */
     ceph::encode(id, bl);
   }
 
-  void decode(bufferlist::const_iterator& bl) {
+  void decode(ceph::buffer::list::const_iterator& bl) {
     /* backward compatiblity, not using DECODE_{START,END} macros */
     ceph::decode(id, bl);
   }
@@ -446,7 +446,7 @@ struct rgw_zone_id {
     id.clear();
   }
 
-  bool operator==(const string& _id) const {
+  bool operator==(const std::string& _id) const {
     return (id == _id);
   }
   bool operator==(const rgw_zone_id& zid) const {
@@ -468,12 +468,12 @@ struct rgw_zone_id {
 };
 WRITE_CLASS_ENCODER(rgw_zone_id)
 
-static inline ostream& operator<<(ostream& os, const rgw_zone_id& zid) {
+inline std::ostream& operator<<(std::ostream& os, const rgw_zone_id& zid) {
   os << zid.id;
   return os;
 }
 
-void encode_json_impl(const char *name, const rgw_zone_id& zid, Formatter *f);
+void encode_json_impl(const char *name, const rgw_zone_id& zid, ceph::Formatter *f);
 void decode_json_obj(rgw_zone_id& zid, JSONObj *obj);
 
 
@@ -489,7 +489,7 @@ class Principal {
   enum types { User, Role, Tenant, Wildcard, OidcProvider };
   types t;
   rgw_user u;
-  string idp_url;
+  std::string idp_url;
 
   explicit Principal(types t)
     : t(t) {}
@@ -497,7 +497,7 @@ class Principal {
   Principal(types t, std::string&& n, std::string i)
     : t(t), u(std::move(n), std::move(i)) {}
 
-  Principal(string&& idp_url)
+  Principal(std::string&& idp_url)
     : t(OidcProvider), idp_url(std::move(idp_url)) {}
 
 public:
@@ -518,7 +518,7 @@ public:
     return Principal(Tenant, std::move(t), {});
   }
 
-  static Principal oidc_provider(string&& idp_url) {
+  static Principal oidc_provider(std::string&& idp_url) {
     return Principal(std::move(idp_url));
   }
 
@@ -550,7 +550,7 @@ public:
     return u.id;
   }
 
-  const string& get_idp_url() const {
+  const std::string& get_idp_url() const {
     return idp_url;
   }
 
@@ -570,11 +570,11 @@ std::ostream& operator <<(std::ostream& m, const Principal& p);
 class JSONObj;
 
 void decode_json_obj(rgw_user& val, JSONObj *obj);
-void encode_json(const char *name, const rgw_user& val, Formatter *f);
-void encode_xml(const char *name, const rgw_user& val, Formatter *f);
+void encode_json(const char *name, const rgw_user& val, ceph::Formatter *f);
+void encode_xml(const char *name, const rgw_user& val, ceph::Formatter *f);
 
-inline ostream& operator<<(ostream& out, const rgw_user &u) {
-  string s;
+inline std::ostream& operator<<(std::ostream& out, const rgw_user &u) {
+  std::string s;
   u.to_str(s);
   return out << s;
 }