[Fawkes Git] branch/fzwilling/robot-memory: 3 revs updated. (0.5.0-3105-gff3303d)

Frederik Zwilling zwilling at kbsg.rwth-aachen.de
Thu Sep 1 17:44:29 CEST 2016


Changes have been pushed for the project "Fawkes Robotics Software Framework".

Gitweb: http://git.fawkesrobotics.org/fawkes.git
Trac:   http://trac.fawkesrobotics.org

The branch, fzwilling/robot-memory has been updated
        to  ff3303de647e0d78566794be4ffb90899dd0929d (commit)
       via  0e4f76c33d71402aaf71764d1d6baed0fad5f968 (commit)
       via  b5a15aed242fabf348b6afc85b370240f422a4f3 (commit)
      from  b7c0f54f638b28e485729f3460b0678e45905195 (commit)

http://git.fawkesrobotics.org/fawkes.git/fzwilling/robot-memory

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- *Log* ---------------------------------------------------------------
commit b5a15aed242fabf348b6afc85b370240f422a4f3
Author:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
AuthorDate: Thu Sep 1 15:00:10 2016 +0200
Commit:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
CommitDate: Thu Sep 1 17:44:15 2016 +0200

    robot-memory: add upsert option in update function
    
    When executing an update, the upsert option defines if the document
    should be inserted if it is not already in the database.

http://git.fawkesrobotics.org/fawkes.git/commit/b5a15ae
http://trac.fawkesrobotics.org/changeset/b5a15ae

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 0e4f76c33d71402aaf71764d1d6baed0fad5f968
Author:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
AuthorDate: Thu Sep 1 16:25:04 2016 +0200
Commit:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
CommitDate: Thu Sep 1 17:44:19 2016 +0200

    robot-memory: removed setting type in document for testing

http://git.fawkesrobotics.org/fawkes.git/commit/0e4f76c
http://trac.fawkesrobotics.org/changeset/0e4f76c

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit ff3303de647e0d78566794be4ffb90899dd0929d
Author:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
AuthorDate: Thu Sep 1 17:42:09 2016 +0200
Commit:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
CommitDate: Thu Sep 1 17:44:24 2016 +0200

    clips-robot-memory: adjusted plugin to use the robot memory

http://git.fawkesrobotics.org/fawkes.git/commit/ff3303d
http://trac.fawkesrobotics.org/changeset/ff3303d

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


- *Summary* -----------------------------------------------------------
 .../clips_robot_memory_thread.cpp                  |  113 +++++++++-----------
 .../clips-robot-memory/clips_robot_memory_thread.h |   21 ++--
 src/plugins/robot-memory/robot_memory.cpp          |   10 +-
 src/plugins/robot-memory/robot_memory.h            |    4 +-
 .../robot-memory/test-plugin/robot_memory_test.cpp |   10 ++
 5 files changed, 76 insertions(+), 82 deletions(-)


- *Diffs* -------------------------------------------------------------

- *commit* b5a15aed242fabf348b6afc85b370240f422a4f3 - - - - - - - - - -
Author:  Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
Date:    Thu Sep 1 15:00:10 2016 +0200
Subject: robot-memory: add upsert option in update function

 src/plugins/robot-memory/robot_memory.cpp          |    8 ++++----
 src/plugins/robot-memory/robot_memory.h            |    4 ++--
 .../robot-memory/test-plugin/robot_memory_test.cpp |   10 ++++++++++
 3 files changed, 16 insertions(+), 6 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/robot-memory/robot_memory.cpp b/src/plugins/robot-memory/robot_memory.cpp
index d273ce2..9a4e65d 100644
--- a/src/plugins/robot-memory/robot_memory.cpp
+++ b/src/plugins/robot-memory/robot_memory.cpp
@@ -148,7 +148,7 @@ int RobotMemory::insert(std::string obj_str, std::string collection)
   return insert(fromjson(obj_str), collection);
 }
 
-int RobotMemory::update(Query query, BSONObj update, std::string collection)
+int RobotMemory::update(Query query, BSONObj update, std::string collection, bool upsert)
 {
   if(collection == "")
   {
@@ -161,7 +161,7 @@ int RobotMemory::update(Query query, BSONObj update, std::string collection)
 
   //actually execute update
   try{
-    mongodb_client_->update(collection, query, update);
+    mongodb_client_->update(collection, query, update, upsert);
   } catch (DBException &e) {
     log_deb(std::string("Error for update "+update.toString()+" for query "+query.toString()+"\n Exception: "+e.toString()), "error");
     return 0;
@@ -170,9 +170,9 @@ int RobotMemory::update(Query query, BSONObj update, std::string collection)
   return 1;
 }
 
-int RobotMemory::update(Query query, std::string update_str, std::string collection)
+int RobotMemory::update(Query query, std::string update_str, std::string collection, bool upsert)
 {
-  return update(query, fromjson(update_str), collection);
+  return update(query, fromjson(update_str), collection, upsert);
 }
 
 int RobotMemory::remove(Query query, std::string collection)
diff --git a/src/plugins/robot-memory/robot_memory.h b/src/plugins/robot-memory/robot_memory.h
index 58c17f7..2ad892b 100644
--- a/src/plugins/robot-memory/robot_memory.h
+++ b/src/plugins/robot-memory/robot_memory.h
@@ -55,8 +55,8 @@ class RobotMemory
     QResCursor query(mongo::Query query, std::string collection = "");
     int insert(mongo::BSONObj obj, std::string collection = "");
     int insert(std::string obj_str, std::string collection = "");
-    int update(mongo::Query query, mongo::BSONObj update, std::string collection = "");
-    int update(mongo::Query query, std::string update_str, std::string collection = "");
+    int update(mongo::Query query, mongo::BSONObj update, std::string collection = "", bool upsert = false);
+    int update(mongo::Query query, std::string update_str, std::string collection = "", bool upsert = false);
     int remove(mongo::Query query, std::string collection = "");
     int drop_collection(std::string collection);
     int clear_memory();
diff --git a/src/plugins/robot-memory/test-plugin/robot_memory_test.cpp b/src/plugins/robot-memory/test-plugin/robot_memory_test.cpp
index 1e35e04..a24e29e 100644
--- a/src/plugins/robot-memory/test-plugin/robot_memory_test.cpp
+++ b/src/plugins/robot-memory/test-plugin/robot_memory_test.cpp
@@ -87,6 +87,16 @@ TEST_F(RobotMemoryTest, StoreRemoveQuery)
   ASSERT_FALSE(qres->more());
 }
 
+TEST_F(RobotMemoryTest, Upsert)
+{
+  ASSERT_TRUE(robot_memory->update("{upsert:'not existing'}", "{upsert:'should not exist'}", "", false));
+  QResCursor qres = robot_memory->query("{upsert:'should not exist'}");
+  ASSERT_FALSE(qres->more());
+  ASSERT_TRUE(robot_memory->update("{upsert:'not existing'}", "{upsert:'should exist'}", "", true));
+  qres = robot_memory->query("{upsert:'should exist'}");
+  ASSERT_TRUE(qres->more());
+}
+
 TEST_F(RobotMemoryTest, QueryInvalid)
 {
   ASSERT_THROW(robot_memory->query("{key-:+'not existing'}"), mongo::DBException);

- *commit* 0e4f76c33d71402aaf71764d1d6baed0fad5f968 - - - - - - - - - -
Author:  Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
Date:    Thu Sep 1 16:25:04 2016 +0200
Subject: robot-memory: removed setting type in document for testing

 src/plugins/robot-memory/robot_memory.cpp |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/robot-memory/robot_memory.cpp b/src/plugins/robot-memory/robot_memory.cpp
index 9a4e65d..dce9510 100644
--- a/src/plugins/robot-memory/robot_memory.cpp
+++ b/src/plugins/robot-memory/robot_memory.cpp
@@ -128,8 +128,6 @@ int RobotMemory::insert(BSONObj obj, std::string collection)
   //only one query at a time
   MutexLocker lock(mutex_);
 
-  set_fields(obj, "{type: \"test\"}");
-
   //actually execute insert
   try{
     mongodb_client_->insert(collection, obj);

- *commit* ff3303de647e0d78566794be4ffb90899dd0929d - - - - - - - - - -
Author:  Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
Date:    Thu Sep 1 17:42:09 2016 +0200
Subject: clips-robot-memory: adjusted plugin to use the robot memory

 .../clips_robot_memory_thread.cpp                  |  113 +++++++++-----------
 .../clips-robot-memory/clips_robot_memory_thread.h |   21 ++--
 2 files changed, 60 insertions(+), 74 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/clips-robot-memory/clips_robot_memory_thread.cpp b/src/plugins/clips-robot-memory/clips_robot_memory_thread.cpp
index 725ae1f..fdd9231 100644
--- a/src/plugins/clips-robot-memory/clips_robot_memory_thread.cpp
+++ b/src/plugins/clips-robot-memory/clips_robot_memory_thread.cpp
@@ -62,32 +62,32 @@ ClipsRobotMemoryThread::clips_context_init(const std::string &env_name,
 
   clips.lock();
 
-  clips_->add_function("bson-create", sigc::slot<CLIPS::Value>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_create)));
-  clips_->add_function("bson-parse", sigc::slot<CLIPS::Value, std::string>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_parse)));
-  clips_->add_function("bson-destroy", sigc::slot<void, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_destroy)));
-  clips_->add_function("bson-append", sigc::slot<void, void *, std::string, CLIPS::Value>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_append)));
-  clips_->add_function("bson-append-array", sigc::slot<void, void *, std::string, CLIPS::Values>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_append_array)));
-  clips_->add_function("bson-array-start", sigc::slot<CLIPS::Value, void *, std::string>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_array_start)));
-  clips_->add_function("bson-array-finish", sigc::slot<void, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_array_finish)));
-  clips_->add_function("bson-array-append", sigc::slot<void, void *, CLIPS::Value>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_array_append)));
-
-  clips_->add_function("bson-append-time", sigc::slot<void, void *, std::string, CLIPS::Values>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_append_time)));
-  clips_->add_function("bson-tostring", sigc::slot<std::string, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_tostring)));
-  clips_->add_function("mongodb-insert", sigc::slot<void, std::string, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_mongodb_insert)));
-  clips_->add_function("mongodb-upsert", sigc::slot<void, std::string, void *, CLIPS::Value>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_mongodb_upsert)));
-  clips_->add_function("mongodb-update", sigc::slot<void, std::string, void *, CLIPS::Value>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_mongodb_update)));
-  clips_->add_function("mongodb-replace", sigc::slot<void, std::string, void *, CLIPS::Value>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_mongodb_replace)));
-  clips_->add_function("mongodb-query", sigc::slot<CLIPS::Value, std::string, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_mongodb_query)));
-  clips_->add_function("mongodb-query-sort", sigc::slot<CLIPS::Value, std::string, void *, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_mongodb_query_sort)));
-  clips_->add_function("mongodb-cursor-destroy", sigc::slot<void, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_mongodb_cursor_destroy)));
-  clips_->add_function("mongodb-cursor-more", sigc::slot<CLIPS::Value, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_mongodb_cursor_more)));
-  clips_->add_function("mongodb-cursor-next", sigc::slot<CLIPS::Value, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_mongodb_cursor_next)));
-  clips_->add_function("bson-field-names", sigc::slot<CLIPS::Values, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_field_names)));
-  clips_->add_function("bson-get", sigc::slot<CLIPS::Value, void *, std::string>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_get)));
-  clips_->add_function("bson-get-array", sigc::slot<CLIPS::Values, void *, std::string>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_get_array)));
-  clips_->add_function("bson-get-time", sigc::slot<CLIPS::Values, void *, std::string>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_get_time)));
-
-  clips_->build("(deffacts have-feature-mongodb (have-feature MongoDB))");
+  clips->add_function("bson-create", sigc::slot<CLIPS::Value>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_create)));
+  clips->add_function("bson-parse", sigc::slot<CLIPS::Value, std::string>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_parse)));
+  clips->add_function("bson-destroy", sigc::slot<void, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_destroy)));
+  clips->add_function("bson-append", sigc::slot<void, void *, std::string, CLIPS::Value>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_append)));
+  clips->add_function("bson-append-array", sigc::slot<void, void *, std::string, CLIPS::Values>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_append_array)));
+  clips->add_function("bson-array-start", sigc::slot<CLIPS::Value, void *, std::string>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_array_start)));
+  clips->add_function("bson-array-finish", sigc::slot<void, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_array_finish)));
+  clips->add_function("bson-array-append", sigc::slot<void, void *, CLIPS::Value>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_array_append)));
+
+  clips->add_function("bson-append-time", sigc::slot<void, void *, std::string, CLIPS::Values>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_append_time)));
+  clips->add_function("bson-tostring", sigc::slot<std::string, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_tostring)));
+  clips->add_function("robmem-insert", sigc::slot<void, std::string, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_robotmemory_insert)));
+  clips->add_function("robmem-upsert", sigc::slot<void, std::string, void *, CLIPS::Value>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_robotmemory_upsert)));
+  clips->add_function("robmem-update", sigc::slot<void, std::string, void *, CLIPS::Value>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_robotmemory_update)));
+  clips->add_function("robmem-replace", sigc::slot<void, std::string, void *, CLIPS::Value>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_robotmemory_replace)));
+  clips->add_function("robmem-query", sigc::slot<CLIPS::Value, std::string, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_robotmemory_query)));
+  clips->add_function("robmem-query-sort", sigc::slot<CLIPS::Value, std::string, void *, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_robotmemory_query_sort)));
+  clips->add_function("robmem-cursor-destroy", sigc::slot<void, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_robotmemory_cursor_destroy)));
+  clips->add_function("robmem-cursor-more", sigc::slot<CLIPS::Value, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_robotmemory_cursor_more)));
+  clips->add_function("robmem-cursor-next", sigc::slot<CLIPS::Value, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_robotmemory_cursor_next)));
+  clips->add_function("bson-field-names", sigc::slot<CLIPS::Values, void *>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_field_names)));
+  clips->add_function("bson-get", sigc::slot<CLIPS::Value, void *, std::string>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_get)));
+  clips->add_function("bson-get-array", sigc::slot<CLIPS::Values, void *, std::string>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_get_array)));
+  clips->add_function("bson-get-time", sigc::slot<CLIPS::Values, void *, std::string>(sigc::mem_fun(*this, &ClipsRobotMemoryThread::clips_bson_get_time)));
+
+  clips->build("(deffacts have-feature-mongodb (have-feature MongoDB))");
 
   //TODO: clips->batch_evaluate(SRCDIR"/plugins/clips-robot-memory/robot_memory.clp");
 
@@ -118,7 +118,7 @@ ClipsRobotMemoryThread::clips_bson_parse(std::string document)
 #ifdef HAVE_MONGODB_VERSION_H
   } catch (mongo::MsgAssertionException &e) {
 #else
-  } catch (bson::assertion &e) {
+  } catch (mongo::AssertionException &e) {
 #endif
     logger->log_error("MongoDB", "Parsing JSON doc failed: %s\n%s",
            e.what(), document.c_str());
@@ -175,7 +175,7 @@ ClipsRobotMemoryThread::clips_bson_append(void *bson, std::string field_name, CL
 #ifdef HAVE_MONGODB_VERSION_H
   } catch (mongo::MsgAssertionException &e) {
 #else
-  } catch (bson::assertion &e) {
+  } catch (mongo::AssertionException &e) {
 #endif
     logger->log_error("MongoDB", "Failed to append array value to field %s: %s",
            field_name.c_str(), e.what());
@@ -224,7 +224,7 @@ ClipsRobotMemoryThread::clips_bson_append_array(void *bson,
 #ifdef HAVE_MONGODB_VERSION_H
   } catch (mongo::MsgAssertionException &e) {
 #else
-  } catch (bson::assertion &e) {
+  } catch (mongo::AssertionException &e) {
 #endif
     logger->log_error("MongoDB", "Failed to append array value to field %s: %s",
            field_name.c_str(), e.what());
@@ -282,7 +282,7 @@ ClipsRobotMemoryThread::clips_bson_array_append(void *barr, CLIPS::Value value)
 #ifdef HAVE_MONGODB_VERSION_H
   } catch (mongo::MsgAssertionException &e) {
 #else
-  } catch (bson::assertion &e) {
+  } catch (mongo::AssertionException &e) {
 #endif
     logger->log_error("MongoDB", "Failed to append to array: %s", e.what());
   }
@@ -309,7 +309,7 @@ ClipsRobotMemoryThread::clips_bson_append_time(void *bson, std::string field_nam
 #ifdef HAVE_MONGODB_VERSION_H
   } catch (mongo::MsgAssertionException &e) {
 #else
-  } catch (bson::assertion &e) {
+  } catch (mongo::AssertionException &e) {
 #endif
     logger->log_error("MongoDB", "Failed to append time value to field %s: %s",
            field_name.c_str(), e.what());
@@ -317,17 +317,12 @@ ClipsRobotMemoryThread::clips_bson_append_time(void *bson, std::string field_nam
 }
 
 void
-ClipsRobotMemoryThread::clips_mongodb_insert(std::string collection, void *bson)
+ClipsRobotMemoryThread::clips_robotmemory_insert(std::string collection, void *bson)
 {
-  if (! cfg_mongodb_enabled_) {
-    logger->log_warn("MongoDB", "Insert requested while MongoDB disabled");
-    return;
-  }
-
   mongo::BSONObjBuilder *b = static_cast<mongo::BSONObjBuilder *>(bson);
 
   try {
-    mongodb_->insert(collection, b->asTempObj());
+    robot_memory->insert(b->asTempObj(), collection);
   } catch (mongo::DBException &e) {
     logger->log_warn("MongoDB", "Insert failed: %s", e.what());
   }
@@ -335,14 +330,9 @@ ClipsRobotMemoryThread::clips_mongodb_insert(std::string collection, void *bson)
 
 
 void
-ClipsRobotMemoryThread::mongodb_update(std::string &collection, mongo::BSONObj obj,
+ClipsRobotMemoryThread::robotmemory_update(std::string &collection, mongo::BSONObj obj,
          CLIPS::Value &query, bool upsert)
 {
-  if (! cfg_mongodb_enabled_) {
-    logger->log_warn("MongoDB", "Update requested while MongoDB disabled");
-    return;
-  }
-
   try {
     mongo::BSONObj query_obj;
     if (query.type() == CLIPS::TYPE_STRING) {
@@ -355,11 +345,11 @@ ClipsRobotMemoryThread::mongodb_update(std::string &collection, mongo::BSONObj o
       return;
     }
 
-    mongodb_->update(collection, query_obj, obj, upsert);
+    robot_memory->update(query_obj, obj, collection, upsert);
 #ifdef HAVE_MONGODB_VERSION_H
   } catch (mongo::MsgAssertionException &e) {
 #else
-  } catch (bson::assertion &e) {
+  } catch (mongo::AssertionException &e) {
 #endif
     logger->log_warn("MongoDB", "Compiling query failed: %s", e.what());
   } catch (mongo::DBException &e) {
@@ -369,18 +359,18 @@ ClipsRobotMemoryThread::mongodb_update(std::string &collection, mongo::BSONObj o
 
 
 void
-ClipsRobotMemoryThread::clips_mongodb_upsert(std::string collection, void *bson, CLIPS::Value query)
+ClipsRobotMemoryThread::clips_robotmemory_upsert(std::string collection, void *bson, CLIPS::Value query)
 {
   mongo::BSONObjBuilder *b = static_cast<mongo::BSONObjBuilder *>(bson);
   if (! b) {
     logger->log_warn("MongoDB", "Invalid BSON Obj Builder passed");
     return;
   }
-  mongodb_update(collection, b->asTempObj(), query, true);
+  robotmemory_update(collection, b->asTempObj(), query, true);
 }
 
 void
-ClipsRobotMemoryThread::clips_mongodb_update(std::string collection, void *bson, CLIPS::Value query)
+ClipsRobotMemoryThread::clips_robotmemory_update(std::string collection, void *bson, CLIPS::Value query)
 {
   mongo::BSONObjBuilder *b = static_cast<mongo::BSONObjBuilder *>(bson);
   if (! b) {
@@ -391,25 +381,20 @@ ClipsRobotMemoryThread::clips_mongodb_update(std::string collection, void *bson,
   mongo::BSONObjBuilder update_doc;
   update_doc.append("$set", b->asTempObj());
 
-  mongodb_update(collection, update_doc.obj(), query, false);
+  robotmemory_update(collection, update_doc.obj(), query, false);
 }
 
 void
-ClipsRobotMemoryThread::clips_mongodb_replace(std::string collection, void *bson, CLIPS::Value query)
+ClipsRobotMemoryThread::clips_robotmemory_replace(std::string collection, void *bson, CLIPS::Value query)
 {
   mongo::BSONObjBuilder *b = static_cast<mongo::BSONObjBuilder *>(bson);
   if (! b) logger->log_warn("MongoDB", "Invalid BSON Obj Builder passed");
-  mongodb_update(collection, b->asTempObj(), query, false);
+  robotmemory_update(collection, b->asTempObj(), query, false);
 }
 
 CLIPS::Value
-ClipsRobotMemoryThread::clips_mongodb_query_sort(std::string collection, void *bson, void *bson_sort)
+ClipsRobotMemoryThread::clips_robotmemory_query_sort(std::string collection, void *bson, void *bson_sort)
 {
-  if (! cfg_mongodb_enabled_) {
-    logger->log_warn("MongoDB", "Query requested while MongoDB disabled");
-    return CLIPS::Value("FALSE", CLIPS::TYPE_SYMBOL);
-  }
-
   mongo::BSONObjBuilder *b = static_cast<mongo::BSONObjBuilder *>(bson);
 
   try {
@@ -420,7 +405,7 @@ ClipsRobotMemoryThread::clips_mongodb_query_sort(std::string collection, void *b
     }
 
 #if __cplusplus >= 201103L
-    std::unique_ptr<mongo::DBClientCursor> c = mongodb_->query(collection, q);
+    std::unique_ptr<mongo::DBClientCursor> c = robot_memory->query(q, collection);
 
     return CLIPS::Value(new std::unique_ptr<mongo::DBClientCursor>(std::move(c)),
                         CLIPS::TYPE_EXTERNAL_ADDRESS);
@@ -438,13 +423,13 @@ ClipsRobotMemoryThread::clips_mongodb_query_sort(std::string collection, void *b
 }
 
 CLIPS::Value
-ClipsRobotMemoryThread::clips_mongodb_query(std::string collection, void *bson)
+ClipsRobotMemoryThread::clips_robotmemory_query(std::string collection, void *bson)
 {
-  return clips_mongodb_query_sort(collection, bson, NULL);
+  return clips_robotmemory_query_sort(collection, bson, NULL);
 }
 
 void
-ClipsRobotMemoryThread::clips_mongodb_cursor_destroy(void *cursor)
+ClipsRobotMemoryThread::clips_robotmemory_cursor_destroy(void *cursor)
 {
 #if __cplusplus >= 201103L
   std::unique_ptr<mongo::DBClientCursor> *c =
@@ -463,7 +448,7 @@ ClipsRobotMemoryThread::clips_mongodb_cursor_destroy(void *cursor)
 }
 
 CLIPS::Value
-ClipsRobotMemoryThread::clips_mongodb_cursor_more(void *cursor)
+ClipsRobotMemoryThread::clips_robotmemory_cursor_more(void *cursor)
 {
 #if __cplusplus >= 201103L
   std::unique_ptr<mongo::DBClientCursor> *c =
@@ -482,7 +467,7 @@ ClipsRobotMemoryThread::clips_mongodb_cursor_more(void *cursor)
 }
 
 CLIPS::Value
-ClipsRobotMemoryThread::clips_mongodb_cursor_next(void *cursor)
+ClipsRobotMemoryThread::clips_robotmemory_cursor_next(void *cursor)
 {
 #if __cplusplus >= 201103L
   std::unique_ptr<mongo::DBClientCursor> *c =
diff --git a/src/plugins/clips-robot-memory/clips_robot_memory_thread.h b/src/plugins/clips-robot-memory/clips_robot_memory_thread.h
index 25b2b84..6b43d48 100644
--- a/src/plugins/clips-robot-memory/clips_robot_memory_thread.h
+++ b/src/plugins/clips-robot-memory/clips_robot_memory_thread.h
@@ -28,6 +28,7 @@
 #include <core/threading/thread.h>
 #include <aspect/logging.h>
 #include <aspect/configurable.h>
+#include <plugins/clips/aspect/clips_feature.h>
 #include <plugins/robot-memory/aspect/robot_memory_aspect.h>
 
 #include <string>
@@ -74,17 +75,17 @@ class ClipsRobotMemoryThread
   void          clips_bson_array_finish(void *barr);
   void          clips_bson_array_append(void *barr, CLIPS::Value value);
   std::string   clips_bson_tostring(void *bson);
-  void          clips_mongodb_upsert(std::string collection, void *bson, CLIPS::Value query);
-  void          clips_mongodb_update(std::string collection, void *bson, CLIPS::Value query);
-  void          clips_mongodb_replace(std::string collection, void *bson, CLIPS::Value query);
-  void          clips_mongodb_insert(std::string collection, void *bson);
-  void          mongodb_update(std::string &collection, mongo::BSONObj obj,
+  void          clips_robotmemory_upsert(std::string collection, void *bson, CLIPS::Value query);
+  void          clips_robotmemory_update(std::string collection, void *bson, CLIPS::Value query);
+  void          clips_robotmemory_replace(std::string collection, void *bson, CLIPS::Value query);
+  void          clips_robotmemory_insert(std::string collection, void *bson);
+  void          robotmemory_update(std::string &collection, mongo::BSONObj obj,
                                CLIPS::Value &query, bool upsert);
-  CLIPS::Value  clips_mongodb_query_sort(std::string collection, void *bson, void *bson_sort);
-  CLIPS::Value  clips_mongodb_query(std::string collection, void *bson);
-  CLIPS::Value  clips_mongodb_cursor_more(void *cursor);
-  CLIPS::Value  clips_mongodb_cursor_next(void *cursor);
-  void          clips_mongodb_cursor_destroy(void *cursor);
+  CLIPS::Value  clips_robotmemory_query_sort(std::string collection, void *bson, void *bson_sort);
+  CLIPS::Value  clips_robotmemory_query(std::string collection, void *bson);
+  CLIPS::Value  clips_robotmemory_cursor_more(void *cursor);
+  CLIPS::Value  clips_robotmemory_cursor_next(void *cursor);
+  void          clips_robotmemory_cursor_destroy(void *cursor);
   CLIPS::Values clips_bson_field_names(void *bson);
   CLIPS::Value  clips_bson_get(void *bson, std::string field_name);
   CLIPS::Values clips_bson_get_array(void *bson, std::string field_name);




-- 
Fawkes Robotics Framework                 http://www.fawkesrobotics.org


More information about the fawkes-commits mailing list