22#ifndef FAWKES_SRC_PLUGINS_ROBOT_MEMORY_COMPUTABLES_COMPUTABLES_MANAGER_H_
23#define FAWKES_SRC_PLUGINS_ROBOT_MEMORY_COMPUTABLES_COMPUTABLES_MANAGER_H_
25#include "computable.h"
27#include <aspect/clock.h>
28#include <aspect/configurable.h>
29#include <aspect/logging.h>
31#include <boost/bind/bind.hpp>
33#include <mongocxx/client.hpp>
46using namespace boost::placeholders;
54 bool check_and_compute(
const bsoncxx::document::view &query, std::string collection);
71 const std::string & collection,
72 std::list<bsoncxx::document::value> (
73 T::*compute_func)(
const bsoncxx::document::view &,
const std::string &),
75 double caching_time = 0.0,
79 query_to_compute, collection, boost::bind(compute_func, obj, _1, _2), caching_time, priority);
81 std::list<Computable *>::iterator pos = computables.begin();
82 while (pos != computables.end() && priority < (*pos)->get_priority())
84 computables.insert(pos, comp);
92 std::string name =
"RobotMemory ComputablesManager";
96 std::list<Computable *> computables;
97 std::string matching_test_collection_;
99 std::map<std::tuple<std::string, std::string>,
long long> cached_querries_;
100#ifdef USE_TIMETRACKER
102 unsigned int tt_loopcount_;
103 unsigned int ttc_cleanup_;
104 unsigned int ttc_cleanup_inner_loop_;
105 unsigned int ttc_cleanup_remove_query_;
Class holding information for a single computable this class also enhances computed documents by addi...
This class manages registering computables and can check if any computables are invoced by a query.
void cleanup_computed_docs()
Clean up all collections containing documents computed on demand.
void remove_computable(Computable *computable)
Remove previously registered computable.
ComputablesManager(fawkes::Configuration *config, RobotMemory *robot_memory)
Constructor for class managing computables with refereces to plugin objects.
bool check_and_compute(const bsoncxx::document::view &query, std::string collection)
Checks if computable knowledge is queried and calls the compute functions in this case.
Computable * register_computable(bsoncxx::document::value &&query_to_compute, const std::string &collection, std::list< bsoncxx::document::value >(T::*compute_func)(const bsoncxx::document::view &, const std::string &), T *obj, double caching_time=0.0, int priority=0)
Registers a Computable which provides information in the robot memory that is computed on demand.
Access to the robot memory based on mongodb.
Interface for configuration handling.
Fawkes library namespace.