knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
Cursor.h
Go to the documentation of this file.
1 /*
2  * This file is part of KnowRob, please consult
3  * https://github.com/knowrob/knowrob for license details.
4  */
5 
6 #ifndef KNOWROB_MONGO_CURSOR_H
7 #define KNOWROB_MONGO_CURSOR_H
8 
9 #include <mongoc.h>
10 #include <string>
11 #include <memory>
12 #include <knowrob/storage/mongo/Collection.h>
13 
14 namespace knowrob::mongo {
18  class Cursor {
19  public:
20  explicit Cursor(const std::shared_ptr<Collection> &collection);
21 
22  Cursor(const Cursor &) = delete;
23 
25 
29  const auto &id() { return id_; };
30 
35  void limit(unsigned int limit);
36 
41  void ascending(const char *key);
42 
47  void descending(const char *key);
48 
53  void filter(const bson_t *query_doc);
54 
59  void aggregate(const bson_t *query_doc);
60 
67  bool next(const bson_t **doc, bool ignore_empty = false);
68 
73  bool erase();
74 
78  const auto *query() const { return query_; }
79 
80  private:
81  std::shared_ptr<Collection> collection_;
82  mongoc_cursor_t *cursor_;
83  bson_t *query_;
84  bson_t *opts_;
85  std::string id_;
86  bool isAggregateQuery_;
87  int64_t limit_;
88  };
89 }
90 
91 #endif //KNOWROB_MONGO_CURSOR_H
void filter(const bson_t *query_doc)
void limit(unsigned int limit)
Definition: Cursor.cpp:44
void descending(const char *key)
Cursor(const Cursor &)=delete
void ascending(const char *key)
const auto & id()
Definition: Cursor.h:29
Cursor(const std::shared_ptr< Collection > &collection)
const auto * query() const
Definition: Cursor.h:78
bool next(const bson_t **doc, bool ignore_empty=false)
void limit(unsigned int limit)
void aggregate(const bson_t *query_doc)
TermRule & string()
Definition: terms.cpp:63