1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2014 David Zafman <dzafman@redhat.com>
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
16 #ifndef CEPH_LIBRADOS_LISTOBJECTIMPL_H
17 #define CEPH_LIBRADOS_LISTOBJECTIMPL_H
19 #include <include/rados/librados.hpp>
22 struct ListObjectImpl {
28 ListObjectImpl(std::string n, std::string o, std::string l):
29 nspace(n), oid(o), locator(l) {}
31 const std::string& get_nspace() const { return nspace; }
32 const std::string& get_oid() const { return oid; }
33 const std::string& get_locator() const { return locator; }
35 WRITE_EQ_OPERATORS_3(ListObjectImpl, nspace, oid, locator)
36 WRITE_CMP_OPERATORS_3(ListObjectImpl, nspace, oid, locator)
37 inline std::ostream& operator<<(std::ostream& out, const struct ListObjectImpl& lop) {
38 out << (lop.nspace.size() ? lop.nspace + "/" : "") << lop.oid
39 << (lop.locator.size() ? "@" + lop.locator : "");
45 class NObjectIteratorImpl {
47 NObjectIteratorImpl() {}
48 ~NObjectIteratorImpl();
49 NObjectIteratorImpl(const NObjectIteratorImpl &rhs);
50 NObjectIteratorImpl& operator=(const NObjectIteratorImpl& rhs);
52 bool operator==(const NObjectIteratorImpl& rhs) const;
53 bool operator!=(const NObjectIteratorImpl& rhs) const;
54 const ListObject& operator*() const;
55 const ListObject* operator->() const;
56 NObjectIteratorImpl &operator++(); // Preincrement
57 NObjectIteratorImpl operator++(int); // Postincrement
58 const ListObject *get_listobjectp() { return &cur_obj; }
60 friend struct ListObjectImpl;
61 //friend class ListObject;
62 friend class NObjectIterator;
64 /// get current hash position of the iterator, rounded to the current pg
65 uint32_t get_pg_hash_position() const;
67 /// move the iterator to a given hash position. this may (will!) be rounded to the nearest pg.
68 uint32_t seek(uint32_t pos);
70 /// move the iterator to a given cursor position
71 uint32_t seek(const librados::ObjectCursor& cursor);
73 /// get current cursor position
74 librados::ObjectCursor get_cursor();
76 void set_filter(const bufferlist &bl);
79 NObjectIteratorImpl(ObjListCtx *ctx_);
81 ceph::shared_ptr < ObjListCtx > ctx;