| Apache Ignite C++

thin-client/include/ignite/thin/cache/query/query_cursor.h
Go to the documentation of this file.
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
23 #ifndef _IGNITE_THIN_CACHE_QUERY_QUERY_CURSOR
24 #define _IGNITE_THIN_CACHE_QUERY_QUERY_CURSOR
25
26 #include <vector>
27
28 #include <ignite/common/concurrent.h>
29 #include <ignite/ignite_error.h>
30
31 #include <ignite/thin/cache/cache_entry.h>
32
33 #include <ignite/impl/thin/readable.h>
34 #include <ignite/impl/thin/cache/query/query_cursor_proxy.h>
35
36 namespace ignite
37 {
38 namespace thin
39 {
40 namespace cache
41 {
42 namespace query
43 {
56 template<typename K, typename V>
57 class QueryCursor
58 {
59 public:
63 QueryCursor()
64 {
65 // No-op.
66 }
67
73 explicit QueryCursor(const impl::thin::cache::query::QueryCursorProxy& impl) :
74 impl(impl)
75 {
76 // No-op.
77 }
78
86 bool HasNext() const
87 {
88 return impl.HasNext();
89 }
90
98 CacheEntry<K, V> GetNext()
99 {
100 CacheEntry<K, V> entry;
101 impl::thin::ReadableImpl< CacheEntry<K, V> > readable(entry);
102
103 impl.GetNext(readable);
104
105 return entry;
106 }
107
115 void GetAll(std::vector<CacheEntry<K, V> >& res)
116 {
117 res.clear();
118 GetAll(std::inserter(res, res.end()));
119 }
120
128 template<typename OutIter>
129 void GetAll(OutIter iter)
130 {
131 impl::thin::ReadableContainerImpl< CacheEntry<K, V>, OutIter > collection(iter);
132
133 while (HasNext())
134 {
135 *iter = GetNext();
136 ++iter;
137 }
138 }
139
140 private:
142 impl::thin::cache::query::QueryCursorProxy impl;
143 };
144 }
145 }
146
147
148 }
149 }
150
151 #endif //_IGNITE_THIN_CACHE_QUERY_QUERY_CURSOR
ignite
Apache Ignite API.
Definition: cache.h:48
ignite::thin::cache::CacheEntry
Cache entry class template.
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:50
ignite::thin::cache::query::QueryCursor::GetNext
CacheEntry< K, V > GetNext()
Get next entry.
Definition: thin-client/include/ignite/thin/cache/query/query_cursor.h:98
ignite::thin::cache::query::QueryCursor::GetAll
void GetAll(OutIter iter)
Get all entries.
Definition: thin-client/include/ignite/thin/cache/query/query_cursor.h:129
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:86
ignite::thin::cache::query::QueryCursor
Query cursor class template.
Definition: thin-client/include/ignite/thin/cache/query/query_cursor.h:57
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:115
ignite::thin::cache::query::QueryCursor::QueryCursor
QueryCursor()
Default constructor.
Definition: thin-client/include/ignite/thin/cache/query/query_cursor.h:63
ignite_error.h
ignite::impl::thin::ReadableImpl
Definition: thin-client/include/ignite/thin/cache/cache_entry.h:36
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:73
cache_entry.h