GridGain C++ Client Library
query_fields_cursor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) GridGain Systems. All Rights Reserved.
3  * _________ _____ __________________ _____
4  * __ ____/___________(_)______ /__ ____/______ ____(_)_______
5  * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
6  * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
7  * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
8  */
9 
15 #ifndef _GRIDGAIN_CACHE_QUERY_FIELDS_CURSOR
16 #define _GRIDGAIN_CACHE_QUERY_FIELDS_CURSOR
17 
18 #include <vector>
19 
20 #include <ignite/common/concurrent.h>
21 
23 #include "gridgain/grid_error.h"
25 #include "gridgain/impl/cache/query/query_impl.h"
26 #include "gridgain/impl/operations.h"
27 
28 namespace gridgain
29 {
30  namespace cache
31  {
32  namespace query
33  {
38  {
39  public:
43  QueryFieldsCursor() : impl(NULL)
44  {
45  // No-op.
46  }
47 
53  QueryFieldsCursor(impl::cache::query::QueryCursorImpl* impl) : impl(impl)
54  {
55  // No-op.
56  }
57 
63  bool HasNext()
64  {
65  GridError err;
66 
67  bool res = HasNext(err);
68 
70 
71  return res;
72  }
73 
80  bool HasNext(GridError& err)
81  {
82  impl::cache::query::QueryCursorImpl* impl0 = impl.Get();
83 
84  if (impl0)
85  return impl0->HasNext(&err);
86  else
87  {
89  "Instance is not usable (did you check for error?).");
90 
91  return false;
92  }
93  }
94 
101  {
102  GridError err;
103 
104  QueryFieldsRow res = GetNext(err);
105 
107 
108  return res;
109  }
110 
118  {
119  impl::cache::query::QueryCursorImpl* impl0 = impl.Get();
120 
121  if (impl0)
122  return impl0->GetNextRow(&err);
123  else
124  {
126  "Instance is not usable (did you check for error?).");
127 
128  return QueryFieldsRow();
129  }
130  }
131 
137  bool IsValid()
138  {
139  return impl.IsValid();
140  }
141 
142  private:
144  ignite::common::concurrent::SharedPointer<impl::cache::query::QueryCursorImpl> impl;
145  };
146  }
147  }
148 }
149 
150 #endif
Query fields cursor.
Definition: query_fields_row.h:36
static const int GG_ERR_GENERIC
Generic GridGain error.
Definition: grid_error.h:104
QueryFieldsRow GetNext()
Get next entry.
Definition: query_fields_cursor.h:100
Query fields cursor.
Definition: query_fields_cursor.h:37
bool HasNext()
Check whether next entry exists.
Definition: query_fields_cursor.h:63
QueryFieldsCursor(impl::cache::query::QueryCursorImpl *impl)
Constructor.
Definition: query_fields_cursor.h:53
bool IsValid()
Check if the instance is valid.
Definition: query_fields_cursor.h:137
bool HasNext(GridError &err)
Check whether next entry exists.
Definition: query_fields_cursor.h:80
Declares gridgain::GridError class.
Declares gridgain::cache::query::QueryFieldsRow class.
Declares gridgain::cache::CacheEntry class.
QueryFieldsRow GetNext(GridError &err)
Get next entry.
Definition: query_fields_cursor.h:117
static void ThrowIfNeeded(GridError &err)
Throw an error if code is not GG_SUCCESS.
Definition: grid_error.cpp:22
GridGain API.
Definition: cache.h:35
QueryFieldsCursor()
Default constructor.
Definition: query_fields_cursor.h:43
Grid error information.
Definition: grid_error.h:70