Apache Ignite C++
query_fields_row.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_CACHE_QUERY_QUERY_FIELDS_ROW
24 #define _IGNITE_CACHE_QUERY_QUERY_FIELDS_ROW
25 
26 #include <vector>
27 
28 #include <ignite/common/concurrent.h>
29 #include <ignite/ignite_error.h>
30 
32 #include "ignite/impl/cache/query/query_fields_row_impl.h"
33 #include "ignite/impl/operations.h"
34 
35 namespace ignite
36 {
37  namespace cache
38  {
39  namespace query
40  {
50  {
51  public:
57  QueryFieldsRow() : impl(0)
58  {
59  // No-op.
60  }
61 
69  QueryFieldsRow(impl::cache::query::QueryFieldsRowImpl* impl) : impl(impl)
70  {
71  // No-op.
72  }
73 
83  bool HasNext()
84  {
85  IgniteError err;
86 
87  bool res = HasNext(err);
88 
90 
91  return res;
92  }
93 
104  bool HasNext(IgniteError& err)
105  {
106  impl::cache::query::QueryFieldsRowImpl* impl0 = impl.Get();
107 
108  if (impl0)
109  return impl0->HasNext();
110  else
111  {
113  "Instance is not usable (did you check for error?).");
114 
115  return false;
116  }
117  }
118 
132  template<typename T>
134  {
135  IgniteError err;
136 
137  T res = GetNext<T>(err);
138 
140 
141  return res;
142  }
143 
158  template<typename T>
160  {
161  impl::cache::query::QueryFieldsRowImpl* impl0 = impl.Get();
162 
163  if (impl0)
164  return impl0->GetNext<T>(err);
165  else
166  {
168  "Instance is not usable (did you check for error?).");
169 
170  return T();
171  }
172  }
173 
185  bool IsValid() const
186  {
187  return impl.IsValid();
188  }
189 
190  private:
192  ignite::common::concurrent::SharedPointer<impl::cache::query::QueryFieldsRowImpl> impl;
193  };
194  }
195  }
196 }
197 
198 #endif //_IGNITE_CACHE_QUERY_QUERY_FIELDS_ROW
QueryFieldsRow()
Default constructor.
Definition: query_fields_row.h:57
bool IsValid() const
Check if the instance is valid.
Definition: query_fields_row.h:185
QueryFieldsRow(impl::cache::query::QueryFieldsRowImpl *impl)
Constructor.
Definition: query_fields_row.h:69
bool HasNext()
Check whether next entry exists.
Definition: query_fields_row.h:83
T GetNext()
Get next entry.
Definition: query_fields_row.h:133
T GetNext(IgniteError &err)
Get next entry.
Definition: query_fields_row.h:159
static void ThrowIfNeeded(IgniteError &err)
Throw an error if code is not IGNITE_SUCCESS.
Definition: ignite_error.cpp:27
Declares ignite::cache::CacheEntry class.
Ignite error information.
Definition: ignite_error.h:89
bool HasNext(IgniteError &err)
Check whether next entry exists.
Definition: query_fields_row.h:104
Query fields cursor.
Definition: query_fields_row.h:49
Apache Ignite API.
Definition: cache.h:43
Declares ignite::IgniteError class.
static const int IGNITE_ERR_GENERIC
Generic Ignite error.
Definition: ignite_error.h:123