22 #ifndef FAWKES_SRC_PLUGINS_ROBOT_MEMORY_EVENT_TRIGGER_MANAGER_H_
23 #define FAWKES_SRC_PLUGINS_ROBOT_MEMORY_EVENT_TRIGGER_MANAGER_H_
25 #include "event_trigger.h"
27 #include <aspect/configurable.h>
28 #include <aspect/logging.h>
29 #include <core/exception.h>
30 #include <core/threading/mutex_locker.h>
31 #include <plugin/loader.h>
32 #include <plugins/mongodb/aspect/mongodb_conncreator.h>
33 #include <plugins/mongodb/utils.h>
35 #include <boost/bind/bind.hpp>
36 #include <bsoncxx/builder/basic/document.hpp>
40 #ifdef USE_TIMETRACKER
45 using namespace boost::placeholders;
69 std::string dbcollection,
70 void (T::*callback)(
const bsoncxx::document::view &),
82 mongocxx::client *con;
83 if (std::find(dbnames_distributed_.begin(),
84 dbnames_distributed_.end(),
85 get_db_name(dbcollection))
86 != dbnames_distributed_.end()) {
91 auto db_coll_pair = split_db_collection_string(dbcollection);
92 auto collection = con->database(db_coll_pair.first)[db_coll_pair.second];
96 boost::bind(callback, obj, _1));
97 triggers.push_back(trigger);
103 static std::string get_db_name(
const std::string &ns);
107 mongocxx::change_stream create_change_stream(mongocxx::collection & collection,
108 bsoncxx::document::view
query);
110 std::string name =
"RobotMemory EventTriggerManager";
117 mongocxx::client *con_local_;
118 mongocxx::client *con_replica_;
120 std::vector<std::string> dbnames_distributed_;
121 std::vector<std::string> dbnames_local_;
124 std::list<EventTrigger *> triggers;
126 #ifdef USE_TIMETRACKER
128 unsigned int tt_loopcount_;
129 unsigned int ttc_trigger_loop_;
130 unsigned int ttc_callback_loop_;
131 unsigned int ttc_callback_;
132 unsigned int ttc_reinit_;
Manager to realize triggers on events in the robot memory.
EventTrigger * register_trigger(const bsoncxx::document::view &query, std::string dbcollection, void(T::*callback)(const bsoncxx::document::view &), T *obj)
Register a trigger to be notified when the robot memory is updated and the updated document matches t...
Class holding all information about an EventTrigger.
Access to the robot memory based on mongodb.
void remove_trigger(EventTrigger *trigger)
Remove a previously registered trigger.
mongocxx::cursor query(bsoncxx::document::view query, const std::string &collection_name="", mongocxx::options::find query_options=mongocxx::options::find())
Query information from the robot memory.
Interface for configuration handling.
Base class for exceptions in Fawkes.
Interface for a MongoDB connection creator.
Mutex mutual exclusion lock.
Fawkes library namespace.