knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
knowrob::mongo::MongoInterface Class Reference

#include <MongoInterface.h>

Public Member Functions

std::shared_ptr< Databaseconnect (const PlTerm &dbTerm)
 
std::shared_ptr< Collectionconnect (const PlTerm &dbTerm, const char *collectionName)
 
std::shared_ptr< Collectionconnect (const char *db_uri, const char *db_name, const char *collectionName)
 
std::shared_ptr< Cursorcursor_create (const PlTerm &db_term, const char *coll_name)
 
void cursor_destroy (const char *curser_id)
 
std::shared_ptr< Cursorcursor (const char *curser_id)
 
std::shared_ptr< Databaseconnect (const PlTerm &dbTerm)
 
std::shared_ptr< Collectionconnect (const PlTerm &dbTerm, const char *collectionName)
 
std::shared_ptr< Collectionconnect (const char *db_uri, const char *db_name, const char *collectionName)
 
std::shared_ptr< Cursorcursor_create (const PlTerm &db_term, const char *coll_name)
 
void cursor_destroy (const char *curser_id)
 
std::shared_ptr< Cursorcursor (const char *curser_id)
 

Static Public Member Functions

static MongoInterfaceget ()
 
static MongoInterfaceget ()
 

Detailed Description

Definition at line 29 of file MongoInterface.h.

Member Function Documentation

◆ connect() [1/6]

std::shared_ptr< Collection > MongoInterface::connect ( const char *  db_uri,
const char *  db_name,
const char *  collectionName 
)

Definition at line 47 of file MongoInterface.cpp.

47  {
48  auto dbConnection = getOrCreateConnection(db_uri);
49  return std::make_shared<Collection>(dbConnection, db_name, collectionName);
50 }

◆ connect() [2/6]

std::shared_ptr<Collection> knowrob::mongo::MongoInterface::connect ( const char *  db_uri,
const char *  db_name,
const char *  collectionName 
)

◆ connect() [3/6]

std::shared_ptr< Database > MongoInterface::connect ( const PlTerm &  dbTerm)

Definition at line 37 of file MongoInterface.cpp.

37  {
38  auto dbConnection = getOrCreateConnection((char *) dbTerm[1]);
39  return std::make_shared<Database>(dbConnection->pool_, (char *) dbTerm[2]);
40 }

◆ connect() [4/6]

std::shared_ptr<Database> knowrob::mongo::MongoInterface::connect ( const PlTerm &  dbTerm)

◆ connect() [5/6]

std::shared_ptr< Collection > MongoInterface::connect ( const PlTerm &  dbTerm,
const char *  collectionName 
)

Definition at line 42 of file MongoInterface.cpp.

42  {
43  return connect((char *) dbTerm[1], (char *) dbTerm[2], collectionName);
44 }
std::shared_ptr< Database > connect(const PlTerm &dbTerm)

◆ connect() [6/6]

std::shared_ptr<Collection> knowrob::mongo::MongoInterface::connect ( const PlTerm &  dbTerm,
const char *  collectionName 
)

◆ cursor() [1/2]

std::shared_ptr< Cursor > MongoInterface::cursor ( const char *  curser_id)

Definition at line 66 of file MongoInterface.cpp.

66  {
67  std::lock_guard<std::mutex> scoped_lock(mongo_mutex_);
68  return cursors_[std::string(curser_id)];
69 }
TermRule & string()
Definition: terms.cpp:63

◆ cursor() [2/2]

std::shared_ptr<Cursor> knowrob::mongo::MongoInterface::cursor ( const char *  curser_id)

◆ cursor_create() [1/2]

std::shared_ptr< Cursor > MongoInterface::cursor_create ( const PlTerm &  db_term,
const char *  coll_name 
)

Definition at line 53 of file MongoInterface.cpp.

53  {
54  auto coll = connect(db_term, coll_name);
55  auto c = std::make_shared<Cursor>(coll);
56  std::lock_guard<std::mutex> scoped_lock(mongo_mutex_);
57  cursors_[c->id()] = c;
58  return c;
59 }

◆ cursor_create() [2/2]

std::shared_ptr<Cursor> knowrob::mongo::MongoInterface::cursor_create ( const PlTerm &  db_term,
const char *  coll_name 
)

◆ cursor_destroy() [1/2]

void MongoInterface::cursor_destroy ( const char *  curser_id)

Definition at line 61 of file MongoInterface.cpp.

61  {
62  std::lock_guard<std::mutex> scoped_lock(mongo_mutex_);
63  cursors_.erase(curser_id);
64 }

◆ cursor_destroy() [2/2]

void knowrob::mongo::MongoInterface::cursor_destroy ( const char *  curser_id)

◆ get() [1/2]

MongoInterface & MongoInterface::get ( )
static

Definition at line 19 of file MongoInterface.cpp.

19  {
20  static MongoInterface singleton;
21  return singleton;
22 }

◆ get() [2/2]

static MongoInterface& knowrob::mongo::MongoInterface::get ( )
static

The documentation for this class was generated from the following files: