]> git.proxmox.com Git - ceph.git/blame - ceph/src/librados/ListObjectImpl.h
bump version to 12.2.12-pve1
[ceph.git] / ceph / src / librados / ListObjectImpl.h
CommitLineData
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 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2014 David Zafman <dzafman@redhat.com>
7 *
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.
12 *
13 */
14#include <string>
15
16#ifndef CEPH_LIBRADOS_LISTOBJECTIMPL_H
17#define CEPH_LIBRADOS_LISTOBJECTIMPL_H
18
19#include <include/rados/librados.hpp>
20
21namespace librados {
22struct ListObjectImpl {
23 std::string nspace;
24 std::string oid;
25 std::string locator;
26
27 ListObjectImpl() {}
28 ListObjectImpl(std::string n, std::string o, std::string l):
29 nspace(n), oid(o), locator(l) {}
30
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; }
34};
35WRITE_EQ_OPERATORS_3(ListObjectImpl, nspace, oid, locator)
36WRITE_CMP_OPERATORS_3(ListObjectImpl, nspace, oid, locator)
37inline 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 : "");
40 return out;
41}
42
43struct ObjListCtx;
44
45class NObjectIteratorImpl {
46 public:
47 NObjectIteratorImpl() {}
48 ~NObjectIteratorImpl();
49 NObjectIteratorImpl(const NObjectIteratorImpl &rhs);
50 NObjectIteratorImpl& operator=(const NObjectIteratorImpl& rhs);
51
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; }
59 friend class IoCtx;
60 friend struct ListObjectImpl;
61 //friend class ListObject;
62 friend class NObjectIterator;
63
64 /// get current hash position of the iterator, rounded to the current pg
65 uint32_t get_pg_hash_position() const;
66
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);
69
70 /// move the iterator to a given cursor position
71 uint32_t seek(const librados::ObjectCursor& cursor);
72
73 /// get current cursor position
74 librados::ObjectCursor get_cursor();
75
76 void set_filter(const bufferlist &bl);
77
78 private:
79 NObjectIteratorImpl(ObjListCtx *ctx_);
80 void get_next();
81 ceph::shared_ptr < ObjListCtx > ctx;
82 ListObject cur_obj;
83};
84
85}
86#endif