Fawkes API  Fawkes Development Version
EventTriggerManager Class Reference

Manager to realize triggers on events in the robot memory. More...

#include <event_trigger_manager.h>

Public Member Functions

 EventTriggerManager (fawkes::Logger *logger, fawkes::Configuration *config, fawkes::MongoDBConnCreator *mongo_connection_manager)
 Constructor for class managing EventTriggers. More...
 
template<typename T >
EventTriggerregister_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 the query. More...
 
void remove_trigger (EventTrigger *trigger)
 Remove a previously registered trigger. More...
 

Static Public Member Functions

static std::string get_db_name (const std::string &ns)
 Split database name from namespace. More...
 

Friends

class RobotMemory
 Access for robot memory to use the check_events function in the loop. More...
 

Detailed Description

Manager to realize triggers on events in the robot memory.

Author
Frederik Zwilling

Definition at line 47 of file event_trigger_manager.h.

Constructor & Destructor Documentation

◆ EventTriggerManager()

EventTriggerManager::EventTriggerManager ( fawkes::Logger logger,
fawkes::Configuration config,
fawkes::MongoDBConnCreator mongo_connection_manager 
)

Constructor for class managing EventTriggers.

Parameters
loggerLogger
configConfiguration
mongo_connection_managerMongoDBConnCreator

Definition at line 49 of file event_trigger_manager.cpp.

References fawkes::MongoDBConnCreator::create_client(), fawkes::Configuration::exists(), fawkes::Configuration::get_bool(), fawkes::Configuration::get_string(), and fawkes::Configuration::get_strings().

Member Function Documentation

◆ get_db_name()

std::string EventTriggerManager::get_db_name ( const std::string &  ns)
static

Split database name from namespace.

Parameters
nsnamespace, format db.collection
Returns
db part of ns

Definition at line 196 of file event_trigger_manager.cpp.

◆ register_trigger()

template<typename T >
EventTrigger* EventTriggerManager::register_trigger ( const bsoncxx::document::view &  query,
std::string  dbcollection,
void(T::*)(const bsoncxx::document::view &)  callback,
T *  obj 
)
inline

Register a trigger to be notified when the robot memory is updated and the updated document matches the query.

Parameters
queryQuery the updated document has to match
dbcollectiondb.collection to use
callbackCallback function (e.g. &Class::callback)
objPointer to class the callback is a function of (usaually this)
Returns
Trigger object pointer, save it to remove the trigger later

Definition at line 68 of file event_trigger_manager.h.

References RobotMemory::query().

Referenced by RobotMemory::register_trigger().

◆ remove_trigger()

void EventTriggerManager::remove_trigger ( EventTrigger trigger)

Remove a previously registered trigger.

Parameters
triggerPointer to the trigger to remove

Definition at line 164 of file event_trigger_manager.cpp.

Friends And Related Function Documentation

◆ RobotMemory

friend class RobotMemory
friend

Access for robot memory to use the check_events function in the loop.

Definition at line 50 of file event_trigger_manager.h.


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