GridGain C++
thin-client/include/ignite/thin/cache/query/query_cursor.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 GridGain Systems, Inc. and Contributors.
3  *
4  * Licensed under the GridGain Community Edition License (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * https://www.gridgain.com/products/software/community-edition/gridgain-community-edition-license
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
22 #ifndef _IGNITE_THIN_CACHE_QUERY_QUERY_CURSOR
23 #define _IGNITE_THIN_CACHE_QUERY_QUERY_CURSOR
24 
25 #include <vector>
26 
27 #include <ignite/common/concurrent.h>
28 #include <ignite/ignite_error.h>
29 
31 
32 #include <ignite/impl/thin/readable.h>
33 #include <ignite/impl/thin/cache/query/query_cursor_proxy.h>
34 
35 namespace ignite
36 {
37  namespace thin
38  {
39  namespace cache
40  {
41  namespace query
42  {
55  template<typename K, typename V>
57  {
58  public:
63  {
64  // No-op.
65  }
66 
72  explicit QueryCursor(const impl::thin::cache::query::QueryCursorProxy& impl) :
73  impl(impl)
74  {
75  // No-op.
76  }
77 
85  bool HasNext() const
86  {
87  return impl.HasNext();
88  }
89 
98  {
99  CacheEntry<K, V> entry;
101 
102  impl.GetNext(readable);
103 
104  return entry;
105  }
106 
114  void GetAll(std::vector<CacheEntry<K, V> >& res)
115  {
116  res.clear();
117  GetAll(std::inserter(res, res.end()));
118  }
119 
127  template<typename OutIter>
128  void GetAll(OutIter iter)
129  {
130  impl::thin::ReadableContainerImpl< CacheEntry<K, V>, OutIter > collection(iter);
131 
132  while (HasNext())
133  {
134  *iter = GetNext();
135  ++iter;
136  }
137  }
138 
139  private:
141  impl::thin::cache::query::QueryCursorProxy impl;
142  };
143  }
144  }
145 
146 
147  }
148 }
149 
150 #endif //_IGNITE_THIN_CACHE_QUERY_QUERY_CURSOR
ignite
Ignite API.
Definition: cache.h:47
ignite::thin::cache::CacheEntry
Cache entry class template.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:49
ignite::thin::cache::query::QueryCursor::GetNext
CacheEntry< K, V > GetNext()
Get next entry.
Definition: thin-client/include/ignite/thin/cache/query/query_cursor.h:97
ignite::thin::cache::query::QueryCursor::GetAll
void GetAll(OutIter iter)
Get all entries.
Definition: thin-client/include/ignite/thin/cache/query/query_cursor.h:128
ignite::thin::cache::query::QueryCursor::HasNext
bool HasNext() const
Check whether next entry exists.
Definition: thin-client/include/ignite/thin/cache/query/query_cursor.h:85
ignite::thin::cache::query::QueryCursor
Query cursor class template.
Definition: thin-client/include/ignite/thin/cache/query/query_cursor.h:56
ignite::thin::cache::query::QueryCursor::GetAll
void GetAll(std::vector< CacheEntry< K, V > > &res)
Get all entries.
Definition: thin-client/include/ignite/thin/cache/query/query_cursor.h:114
ignite::thin::cache::query::QueryCursor::QueryCursor
QueryCursor()
Default constructor.
Definition: thin-client/include/ignite/thin/cache/query/query_cursor.h:62
ignite_error.h
ignite::impl::thin::ReadableImpl
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:35
ignite::thin::cache::query::QueryCursor::QueryCursor
QueryCursor(const impl::thin::cache::query::QueryCursorProxy &impl)
Constructor.
Definition: thin-client/include/ignite/thin/cache/query/query_cursor.h:72
cache_entry.h