knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
Connection.cpp
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 #include "knowrob/storage/mongo/Connection.h"
7 #include "knowrob/storage/mongo/MongoException.h"
8 #include <string>
9 
10 using namespace knowrob::mongo;
11 
12 Connection::Connection(std::string_view uri_string)
13  : uri_string_(uri_string) {
14  bson_error_t err;
15  uri_ = mongoc_uri_new_with_error(uri_string_.c_str(), &err);
16  if (!uri_) {
17  throw MongoException("invalid_uri", err);
18  }
19  pool_ = mongoc_client_pool_new(uri_);
20  // connectionWatch_ = std::make_shared<QueryWatch>(pool_);
21  mongoc_client_pool_set_error_api(pool_, 2);
22 }
23 
25  mongoc_client_pool_destroy(pool_);
26  mongoc_uri_destroy(uri_);
27  mongoc_cleanup();
28 }
Connection(std::string_view uri_string)
Definition: Connection.cpp:12
mongoc_client_pool_t * pool_
Definition: Connection.h:32