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> 30 #include <mongo/client/dbclient.h> 32 #include <boost/bind.hpp> 63 const std::string & collection,
64 std::list<mongo::BSONObj> (T::*compute_func)(
const mongo::BSONObj &,
67 double caching_time = 0.0,
71 query_to_compute, collection, boost::bind(compute_func, obj, _1, _2), caching_time, priority);
73 std::list<Computable *>::iterator pos = computables.begin();
74 while (pos != computables.end() && priority < (*pos)->get_priority())
76 computables.insert(pos, comp);
81 std::string name =
"RobotMemory ComputablesManager";
85 std::list<Computable *> computables;
86 std::string matching_test_collection_;
88 std::map<std::tuple<std::string, std::string>,
long long> cached_querries_;
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.
Class holding information for a single computable this class also enhances computed documents by addi...
ComputablesManager(fawkes::Configuration *config, RobotMemory *robot_memory)
Constructor for class managing computables with refereces to plugin objects.
void remove_computable(Computable *computable)
Remove previously registered computable.
Computable * register_computable(const mongo::Query &query_to_compute, const std::string &collection, std::list< mongo::BSONObj >(T::*compute_func)(const mongo::BSONObj &, 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.
bool check_and_compute(mongo::Query query, std::string collection)
Checks if computable knowledge is queried and calls the compute functions in this case.