knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
ChangeStream.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_CHANGE_STREAM_H
7 #define KNOWROB_MONGO_CHANGE_STREAM_H
8 
9 #include <mongoc.h>
10 #include <string>
11 #include <functional>
12 #include <memory>
13 #include "Collection.h"
14 #include "bson.h"
15 #include "bson-helper.h"
16 
17 namespace knowrob::mongo {
21  using ChangeStreamCallback = std::function<void(const bson_wrapper_ptr&)>;
22 
27  class ChangeStream {
28  public:
30  const std::shared_ptr<Collection> &collection,
31  const bson_t *query,
32  ChangeStreamCallback callback);
33 
34  ChangeStream(const ChangeStream&) = delete;
35 
37 
38  bool next();
39 
40  protected:
41  std::shared_ptr<Collection> collection_;
43  mongoc_change_stream_t *stream_;
45  };
46 
47 } // knowrob::mongo
48 
49 #endif //KNOWROB_MONGO_CHANGE_STREAM_H
mongoc_change_stream_t * stream_
Definition: ChangeStream.h:43
ChangeStream(const ChangeStream &)=delete
ChangeStream(const std::shared_ptr< Collection > &collection, const bson_t *query, ChangeStreamCallback callback)
std::shared_ptr< Collection > collection_
Definition: ChangeStream.h:41
ChangeStreamCallback callback_
Definition: ChangeStream.h:42
bson_wrapper_ptr next_ptr_
Definition: ChangeStream.h:44
std::function< void(const bson_wrapper_ptr &)> ChangeStreamCallback
Definition: ChangeStream.h:21
FunctionRule & function()
Definition: terms.cpp:140