]>
Commit | Line | Data |
---|---|---|
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 | */ | |
7c673cae FG |
14 | |
15 | #ifndef CEPH_LIBRADOS_LISTOBJECTIMPL_H | |
16 | #define CEPH_LIBRADOS_LISTOBJECTIMPL_H | |
17 | ||
f67539c2 | 18 | #include <string> |
7c673cae FG |
19 | #include <include/rados/librados.hpp> |
20 | ||
f67539c2 TL |
21 | #include "include/cmp.h" |
22 | ||
7c673cae FG |
23 | namespace librados { |
24 | struct ListObjectImpl { | |
25 | std::string nspace; | |
26 | std::string oid; | |
27 | std::string locator; | |
28 | ||
29 | ListObjectImpl() {} | |
30 | ListObjectImpl(std::string n, std::string o, std::string l): | |
31 | nspace(n), oid(o), locator(l) {} | |
32 | ||
33 | const std::string& get_nspace() const { return nspace; } | |
34 | const std::string& get_oid() const { return oid; } | |
35 | const std::string& get_locator() const { return locator; } | |
36 | }; | |
37 | WRITE_EQ_OPERATORS_3(ListObjectImpl, nspace, oid, locator) | |
38 | WRITE_CMP_OPERATORS_3(ListObjectImpl, nspace, oid, locator) | |
39 | inline std::ostream& operator<<(std::ostream& out, const struct ListObjectImpl& lop) { | |
40 | out << (lop.nspace.size() ? lop.nspace + "/" : "") << lop.oid | |
41 | << (lop.locator.size() ? "@" + lop.locator : ""); | |
42 | return out; | |
43 | } | |
44 | ||
7c673cae FG |
45 | class 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; } | |
7c673cae FG |
59 | |
60 | /// get current hash position of the iterator, rounded to the current pg | |
61 | uint32_t get_pg_hash_position() const; | |
62 | ||
63 | /// move the iterator to a given hash position. this may (will!) be rounded to the nearest pg. | |
64 | uint32_t seek(uint32_t pos); | |
65 | ||
66 | /// move the iterator to a given cursor position | |
67 | uint32_t seek(const librados::ObjectCursor& cursor); | |
68 | ||
69 | /// get current cursor position | |
70 | librados::ObjectCursor get_cursor(); | |
71 | ||
72 | void set_filter(const bufferlist &bl); | |
73 | ||
7c673cae FG |
74 | NObjectIteratorImpl(ObjListCtx *ctx_); |
75 | void get_next(); | |
11fdf7f2 | 76 | std::shared_ptr < ObjListCtx > ctx; |
7c673cae FG |
77 | ListObject cur_obj; |
78 | }; | |
79 | ||
80 | } | |
81 | #endif |